This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Properly dump addend in readelf


"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);
 		}
 	    }
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]