This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Properly dump addend in readelf
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Fri, 1 Oct 2010 23:02:48 -0700
- Subject: PATCH: Properly dump addend in readelf
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
"readelf -r" failed to dump addend in 32bit ELF with 64bit VMA. It
happpens on Linux/mips64:
FAIL: ld-mips-elf/reloc-1-n32
Also we can't assume long is always 64bit. This patch uses long long
instead. OK to install?
Thanks.
H.J.
----
2010-10-01 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (dump_relocations): Properly dump addend.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index b91c5ba..876827d 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -1410,12 +1410,17 @@ dump_relocations (FILE * file,
if (is_rela)
{
- long off = (long) (bfd_signed_vma) rels[i].r_addend;
+ long long off;
+
+ if (is_32bit_elf)
+ off = (long long) (int) rels[i].r_addend;
+ else
+ off = rels[i].r_addend;
if (off < 0)
- printf (" - %lx", - off);
+ printf (" - %llx", - off);
else
- printf (" + %lx", off);
+ printf (" + %llx", off);
}
}
}