diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2010-10-09 05:52:29 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2010-10-09 05:52:29 +0000 |
commit | 598aaa7684fc8ffdbd9a22bef5e321e09ef8a54d (patch) | |
tree | 58a1487ec5e2dda9322cc736ca0f510a4d7db1e6 | |
parent | 6ed3211e19f2ca09ba2c39b1a94e58612e492ffe (diff) | |
download | gdb-598aaa7684fc8ffdbd9a22bef5e321e09ef8a54d.zip gdb-598aaa7684fc8ffdbd9a22bef5e321e09ef8a54d.tar.gz gdb-598aaa7684fc8ffdbd9a22bef5e321e09ef8a54d.tar.bz2 |
Use BYTE_GET_SIGNED on r_addend.
2010-10-08 H.J. Lu <hongjiu.lu@intel.com>
* 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.
-rw-r--r-- | binutils/ChangeLog | 10 | ||||
-rw-r--r-- | binutils/dwarf.c | 2 | ||||
-rw-r--r-- | binutils/dwarf.h | 1 | ||||
-rw-r--r-- | binutils/readelf.c | 13 |
4 files changed, 19 insertions, 7 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 1d9d875..de3d3e9 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,13 @@ +2010-10-08 H.J. Lu <hongjiu.lu@intel.com> + + * 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. + 2010-10-08 Joseph Myers <joseph@codesourcery.com> * nm.c (value_format_64bit): Define appropriately for __MSVCRT__. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index ebe7271..60aa7d1 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -163,7 +163,7 @@ byte_get_big_endian (unsigned char *field, int size) } } -static dwarf_vma +dwarf_vma byte_get_signed (unsigned char *field, int size) { dwarf_vma x = byte_get (field, size); diff --git a/binutils/dwarf.h b/binutils/dwarf.h index df90ae0..1c47c5e 100644 --- a/binutils/dwarf.h +++ b/binutils/dwarf.h @@ -101,6 +101,7 @@ typedef struct debug_info; extern dwarf_vma (*byte_get) (unsigned char *, int); +extern dwarf_vma byte_get_signed (unsigned char *, int); extern dwarf_vma byte_get_little_endian (unsigned char *, int); extern dwarf_vma byte_get_big_endian (unsigned char *, int); 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); } } } |