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]

RFC: Tweak the fix for PR9774


So, a mere 8 months after the patch went in, I come to realise that
the fix for PR9774 has caused some problems disassembling MIPS n64
binaries.  The PR was about making sure that objdump sign-extended
addresses on 32-bit MIPS, so that symbol lookup would work correctly.
And it does now.

The patch for the PR used sign_extend_vma to check whether addresses
are signed and assumed that the source address was 32 bits wide.
The problem is that MIPS ELF64 also sets sign_extend_vma, even though
its addresses are 64 bits wide.  This might seem odd, but I think it's
actually correct.  Addresses are conceptually signed values on MIPS,
and if we ever read a 32-bit address from an ELF64 binary, we should
always sign-extend it.

So although one option would be to change the sign_extend_vma setting
for ELF64, I think it'd be better to change objdump to support other
address sizes.

The patch below fixes the problems I was seeing the MIPS n64 linker tests.
Nick, is this OK?

Richard


binutils/
	* objdump.c (disassemble_section): Use bfd_get_arch_size
	instead of assuming that the address size is 32 bits.

Index: binutils/objdump.c
===================================================================
--- binutils/objdump.c	2009-09-20 11:59:54.000000000 +0100
+++ binutils/objdump.c	2009-09-20 11:59:57.000000000 +0100
@@ -1897,7 +1897,7 @@ disassemble_section (bfd *abfd, asection
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
       && (bed = get_elf_backend_data (abfd)) != NULL
       && bed->sign_extend_vma)
-    sign_adjust = 0x80000000;
+    sign_adjust = (bfd_vma) 1 << (bfd_get_arch_size (abfd) - 1);
 
   /* Disassemble a block of instructions up to the address associated with
      the symbol we have just found.  Then print the symbol and find the


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