Sign-extend start and stop address inputs to objdump
For targets that treat addresses as signed (MIPS/SH64), user-specified start/stop address limits cannot be compared directly to section VMAs. We must sign-extend user-specified 32-bit address limits which have bit 31 set for such targets. binutils/ * objdump.c (sign_extend_address): New function. (dump_bfd): Sign-extend user-specified start/stop addresses for targets that need it. * testsuite/binutils-all/objdump.exp: Add tests for objdump with start and stop addresses in higher address ranges.
This commit is contained in:
parent
46752c37b0
commit
2379f9c475
3 changed files with 88 additions and 0 deletions
|
@ -3749,11 +3749,25 @@ adjust_addresses (bfd *abfd ATTRIBUTE_UNUSED,
|
|||
}
|
||||
}
|
||||
|
||||
/* Return the sign-extended form of an ARCH_SIZE sized VMA. */
|
||||
|
||||
static bfd_vma
|
||||
sign_extend_address (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
bfd_vma vma,
|
||||
unsigned arch_size)
|
||||
{
|
||||
bfd_vma mask;
|
||||
mask = (bfd_vma) 1 << (arch_size - 1);
|
||||
return (((vma & ((mask << 1) - 1)) ^ mask) - mask);
|
||||
}
|
||||
|
||||
/* Dump selected contents of ABFD. */
|
||||
|
||||
static void
|
||||
dump_bfd (bfd *abfd, bfd_boolean is_mainfile)
|
||||
{
|
||||
const struct elf_backend_data * bed;
|
||||
|
||||
if (bfd_big_endian (abfd))
|
||||
byte_get = byte_get_big_endian;
|
||||
else if (bfd_little_endian (abfd))
|
||||
|
@ -3784,6 +3798,18 @@ dump_bfd (bfd *abfd, bfd_boolean is_mainfile)
|
|||
}
|
||||
}
|
||||
|
||||
/* Adjust user-specified start and stop limits for targets that use
|
||||
signed addresses. */
|
||||
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
|
||||
&& (bed = get_elf_backend_data (abfd)) != NULL
|
||||
&& bed->sign_extend_vma)
|
||||
{
|
||||
start_address = sign_extend_address (abfd, start_address,
|
||||
bed->s->arch_size);
|
||||
stop_address = sign_extend_address (abfd, stop_address,
|
||||
bed->s->arch_size);
|
||||
}
|
||||
|
||||
/* If we are adjusting section VMA's, change them all now. Changing
|
||||
the BFD information is a hack. However, we must do it, or
|
||||
bfd_find_nearest_line will not do the right thing. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue