aboutsummaryrefslogtreecommitdiff
path: root/binutils/objdump.c
diff options
context:
space:
mode:
authorFaraz Shahbazker <fshahbazker@wavecomp.com>2019-05-03 18:21:49 -0700
committerFaraz Shahbazker <fshahbazker@wavecomp.com>2019-05-08 09:07:35 -0700
commit2379f9c475505ecedc97607b39af7184bd67aa88 (patch)
tree1640b839f8c2c2ceedb7d53225b8b6e30c16e2ce /binutils/objdump.c
parent46752c37b06c83a8cbf6be887beac4092d5e3505 (diff)
downloadgdb-2379f9c475505ecedc97607b39af7184bd67aa88.zip
gdb-2379f9c475505ecedc97607b39af7184bd67aa88.tar.gz
gdb-2379f9c475505ecedc97607b39af7184bd67aa88.tar.bz2
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.
Diffstat (limited to 'binutils/objdump.c')
-rw-r--r--binutils/objdump.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 644638c..05d503e 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -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. */