aboutsummaryrefslogtreecommitdiff
path: root/binutils/readelf.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2010-10-09 05:52:29 +0000
committerH.J. Lu <hjl.tools@gmail.com>2010-10-09 05:52:29 +0000
commit598aaa7684fc8ffdbd9a22bef5e321e09ef8a54d (patch)
tree58a1487ec5e2dda9322cc736ca0f510a4d7db1e6 /binutils/readelf.c
parent6ed3211e19f2ca09ba2c39b1a94e58612e492ffe (diff)
downloadgdb-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.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r--binutils/readelf.c13
1 files changed, 7 insertions, 6 deletions
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);
}
}
}