From 598aaa7684fc8ffdbd9a22bef5e321e09ef8a54d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 9 Oct 2010 05:52:29 +0000 Subject: Use BYTE_GET_SIGNED on r_addend. 2010-10-08 H.J. Lu * dwarf.c (byte_get_signed): Make it extern. * dwarf.h (byte_get_signed): New. * readelf.c (BYTE_GET_SIGNED): New. (slurp_rela_relocs): Use BYTE_GET_SIGNED on r_addend. (dump_relocations): Properly dump r_addend. --- binutils/readelf.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'binutils/readelf.c') diff --git a/binutils/readelf.c b/binutils/readelf.c index b91c5ba..1f50ae5 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -272,7 +272,8 @@ static void (* byte_put) (unsigned char *, bfd_vma, int); #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ -#define BYTE_GET(field) byte_get (field, sizeof (field)) +#define BYTE_GET(field) byte_get (field, sizeof (field)) +#define BYTE_GET_SIGNED(field) byte_get_signed (field, sizeof (field)) #define GET_ELF_SYMBOLS(file, section) \ (is_32bit_elf ? get_32bit_elf_symbols (file, section) \ @@ -734,7 +735,7 @@ slurp_rela_relocs (FILE * file, { relas[i].r_offset = BYTE_GET (erelas[i].r_offset); relas[i].r_info = BYTE_GET (erelas[i].r_info); - relas[i].r_addend = BYTE_GET (erelas[i].r_addend); + relas[i].r_addend = BYTE_GET_SIGNED (erelas[i].r_addend); } free (erelas); @@ -764,7 +765,7 @@ slurp_rela_relocs (FILE * file, { relas[i].r_offset = BYTE_GET (erelas[i].r_offset); relas[i].r_info = BYTE_GET (erelas[i].r_info); - relas[i].r_addend = BYTE_GET (erelas[i].r_addend); + relas[i].r_addend = BYTE_GET_SIGNED (erelas[i].r_addend); /* The #ifdef BFD64 below is to prevent a compile time warning. We know that if we do not have a 64 bit data @@ -1410,12 +1411,12 @@ dump_relocations (FILE * file, if (is_rela) { - long off = (long) (bfd_signed_vma) rels[i].r_addend; + bfd_signed_vma off = rels[i].r_addend; if (off < 0) - printf (" - %lx", - off); + printf (" - %" BFD_VMA_FMT "x", - off); else - printf (" + %lx", off); + printf (" + %" BFD_VMA_FMT "x", off); } } } -- cgit v1.1