This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix objdump -p not to truncate 64-bit values
- From: Adam Nemet <anemet at caviumnetworks dot com>
- To: binutils at sourceware dot org
- Date: Thu, 20 Mar 2008 16:24:12 -0700
- Subject: [PATCH] Fix objdump -p not to truncate 64-bit values
On hosts where long is 32 bits we print numeric values from the .dynamic
section of 64-bit objects truncated. The patch below fixes this and adds a
64-bit MIPS testcase.
Tested with mips64octeon-linux-gnu.
OK?
Adam
bfd/
* elf.c (_bfd_elf_print_private_bfd_data): Use bfd_fprintf_vma to
print the values from the dynamic section.
ld/testsuite/
* ld-mips-elf/dyn-sec64.d, ld-mips-elf/dyn-sec64.s,
ld-mips-elf/dyn-sec64.ld: New test.
* ld-mips-elf/mips-elf.exp: Run it.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.439
diff -F^\([(a-zA-Z0-9_]\|#define\) -u -p -r1.439 elf.c
--- bfd/elf.c 13 Mar 2008 05:27:42 -0000 1.439
+++ bfd/elf.c 20 Mar 2008 22:57:39 -0000
@@ -1293,7 +1293,10 @@ _bfd_elf_print_private_bfd_data (bfd *ab
fprintf (f, " %-20s ", name);
if (! stringp)
- fprintf (f, "0x%lx", (unsigned long) dyn.d_un.d_val);
+ {
+ fprintf (f, "0x");
+ bfd_fprintf_vma (abfd, f, dyn.d_un.d_val);
+ }
else
{
const char *string;
Index: ld/testsuite/ld-mips-elf/dyn-sec64.d
===================================================================
RCS file: ld/testsuite/ld-mips-elf/dyn-sec64.d
diff -N ld/testsuite/ld-mips-elf/dyn-sec64.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-mips-elf/dyn-sec64.d 20 Mar 2008 22:57:39 -0000
@@ -0,0 +1,30 @@
+#name: objdump -p print 64-bit values
+#source: dyn-sec64.s
+#as: -mips3 -EB -64
+#ld: -Tdyn-sec64.ld -shared -melf64btsmip
+#objdump: -p
+
+.*: .* file format .*
+
+Program Header:
+.* LOAD .*
+.*
+.* LOAD .*
+.*
+.* DYNAMIC .*
+.*
+.* NULL .*
+.*
+
+Dynamic Section:
+
+ INIT .* 0x0001234000003000
+ FINI .* 0x0001234000004000
+ HASH .* 0x0001234000001000
+ STRTAB .*
+ SYMTAB .*
+ STRSZ .*
+ SYMENT .*
+ PLTGOT .* 0x0001235000000000
+ REL .* 0x0001234000002000
+#pass
Index: ld/testsuite/ld-mips-elf/dyn-sec64.s
===================================================================
RCS file: ld/testsuite/ld-mips-elf/dyn-sec64.s
diff -N ld/testsuite/ld-mips-elf/dyn-sec64.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-mips-elf/dyn-sec64.s 20 Mar 2008 22:57:39 -0000
@@ -0,0 +1,19 @@
+ .section .init,"ax",@progbits
+ .globl _init
+ .ent _init
+ .type _init, @function
+_init:
+ ld $2,%call16(bar)
+ .end _init
+
+ .section .fini,"ax",@progbits
+ .globl _fini
+ .ent _fini
+ .type _fini, @function
+_fini:
+ .end _fini
+
+ .data
+foo:
+ .dword bar
+
Index: ld/testsuite/ld-mips-elf/dyn-sec64.ld
===================================================================
RCS file: ld/testsuite/ld-mips-elf/dyn-sec64.ld
diff -N ld/testsuite/ld-mips-elf/dyn-sec64.ld
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-mips-elf/dyn-sec64.ld 20 Mar 2008 22:57:39 -0000
@@ -0,0 +1,23 @@
+SECTIONS
+{
+ . = 0x1234000000000;
+ .dynamic : { *(.dynamic) }
+ . = 0x1234000001000;
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ . = 0x1234000002000;
+ .rel.dyn : { *(.rel.dyn) }
+
+ . = 0x1234000003000;
+ .init : { *(.init) }
+ . = 0x1234000004000;
+ .fini : { *(.fini) }
+ .text : { *(.text) }
+ .MIPS.stubs : { *(.MIPS.stubs) }
+
+ . = 0x1235000000000;
+ _gp = ALIGN (16) + 0x7ff0;
+ .got : { *(.got) }
+ .data : { *(.data) }
+}