aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2022-12-16 15:44:55 +0000
committerNick Clifton <nickc@redhat.com>2022-12-16 15:44:55 +0000
commitc7ce51d8c886cc4b34ccee30dd1e7add4058466f (patch)
treee3ae215340d7f45c855479102a59b579512d0e9a /binutils
parent832a980e1725a4a7fa527f2dcd92a64d7e68ab0f (diff)
downloadgdb-c7ce51d8c886cc4b34ccee30dd1e7add4058466f.zip
gdb-c7ce51d8c886cc4b34ccee30dd1e7add4058466f.tar.gz
gdb-c7ce51d8c886cc4b34ccee30dd1e7add4058466f.tar.bz2
Fix previous delta to allow for compilation on 32-bit systems
Diffstat (limited to 'binutils')
-rw-r--r--binutils/NEWS4
-rw-r--r--binutils/doc/binutils.texi5
-rw-r--r--binutils/dwarf.c6
-rw-r--r--binutils/objdump.c22
-rw-r--r--binutils/testsuite/binutils-all/objdump.exp26
5 files changed, 60 insertions, 3 deletions
diff --git a/binutils/NEWS b/binutils/NEWS
index 5ff17f6..3ac10f4 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -1,5 +1,9 @@
-*- text -*-
+* Objdump has a new command line option --show-all-symbols which will make it
+ display all symbols that match a given address when disassembling. (Normally
+ only the first symbol that matches an address is shown).
+
* Add --enable-colored-disassembly configure time option to enable colored
disassembly output by default, if the output device is a terminal. Note,
this configure option is disabled by default.
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 852ed60..c9d52d7 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -2274,6 +2274,7 @@ objdump [@option{-a}|@option{--archive-headers}]
[@option{--prefix-addresses}]
[@option{--[no-]show-raw-insn}]
[@option{--adjust-vma=}@var{offset}]
+ [@option{--show-all-symbols}]
[@option{--dwarf-depth=@var{n}}]
[@option{--dwarf-start=@var{n}}]
[@option{--ctf-parent=}@var{section}]
@@ -2784,6 +2785,10 @@ non-empty sections are displayed.
Display source code intermixed with disassembly, if possible. Implies
@option{-d}.
+@item --show-all-symbols
+When disassembling, show all the symbols that match a given address,
+not just the first one.
+
@item --source-comment[=@var{txt}]
@cindex source disassembly
@cindex disassembly, with source
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 533f118..03b36afc 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7741,7 +7741,7 @@ display_debug_addr (struct dwarf_section *section,
if (end < entry)
{
warn (_("Corrupt %s section header: length field (%lx) is too small\n"),
- section->name, length);
+ section->name, (long) length);
return 0;
}
SAFE_BYTE_GET_AND_INC (version, curr_header, 2, entry);
@@ -7761,8 +7761,8 @@ display_debug_addr (struct dwarf_section *section,
{
warn (_("Corrupt %s section: address base of entry %u (%lx) is less than entry %u (%lx)\n"),
section->name,
- i, debug_addr_info [i]->addr_base,
- i + 1, debug_addr_info [i + 1]->addr_base);
+ i, (long) debug_addr_info [i]->addr_base,
+ i + 1, (long) debug_addr_info [i + 1]->addr_base);
return 0;
}
}
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 6695c5d..d51abbe 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -137,6 +137,7 @@ static bool visualize_jumps = false; /* --visualize-jumps. */
static bool color_output = false; /* --visualize-jumps=color. */
static bool extended_color_output = false; /* --visualize-jumps=extended-color. */
static int process_links = false; /* --process-links. */
+static int show_all_symbols; /* --show-all-symbols. */
static enum color_selection
{
@@ -399,6 +400,8 @@ usage (FILE *stream, int status)
fprintf (stream, _("\
--adjust-vma=OFFSET Add OFFSET to all displayed section addresses\n"));
fprintf (stream, _("\
+ --show-all-symbols When disassembling, display all symbols at a given address\n"));
+ fprintf (stream, _("\
--special-syms Include special symbols in symbol dumps\n"));
fprintf (stream, _("\
--inlines Print all inlines for source line (with -l)\n"));
@@ -537,6 +540,7 @@ static struct option long_options[]=
{"section", required_argument, NULL, 'j'},
{"section-headers", no_argument, NULL, 'h'},
{"sframe", optional_argument, NULL, OPTION_SFRAME},
+ {"show-all-symbols", no_argument, &show_all_symbols, 1},
{"show-raw-insn", no_argument, &show_raw_insn, 1},
{"source", no_argument, NULL, 'S'},
{"source-comment", optional_argument, NULL, OPTION_SOURCE_COMMENT},
@@ -3942,6 +3946,24 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
objdump_print_addr_with_sym (abfd, section, sym, addr,
pinfo, false);
pinfo->fprintf_func (pinfo->stream, ":\n");
+
+ if (sym != NULL && show_all_symbols)
+ {
+ for (++place; place < sorted_symcount; place++)
+ {
+ sym = sorted_syms[place];
+
+ if (bfd_asymbol_value (sym) != addr)
+ break;
+ if (! pinfo->symbol_is_valid (sym, pinfo))
+ continue;
+ if (strcmp (bfd_section_name (sym->section), bfd_section_name (section)) != 0)
+ break;
+
+ objdump_print_addr_with_sym (abfd, section, sym, addr, pinfo, false);
+ pinfo->fprintf_func (pinfo->stream, ":\n");
+ }
+ }
}
if (sym != NULL && bfd_asymbol_value (sym) > addr)
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index 436fc46..0ab7842 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -375,6 +375,32 @@ if { [is_elf_format] } then {
}
}
+proc test_objdump_d_show_all_symbols { testfile dumpfile } {
+ global OBJDUMP
+ global OBJDUMPFLAGS
+
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -d --show-all-symbols $testfile"]
+
+ set want "${dumpfile}.*:.*00+0 <text_symbol>"
+ if ![regexp $want $got] then {
+ fail "objdump -d --show-all-symbols $testfile: Missing 'text_symbol'"
+ return
+ }
+
+ set want "${dumpfile}.*:.*00+0 <static_text_symbol>"
+ if ![regexp $want $got] then {
+ fail "objdump -d --show-all-symbols $testfile: Missing 'static_text_symbol'"
+ return
+ }
+
+ pass "objdump -d --show-all-symbols $testfile"
+}
+
+# The AIX and ECOFF assemblers default to makeing symbols local, not global.
+# So they do not show up in this test.
+setup_xfail "*-*-*aix*"
+setup_xfail "*-*-*ecoff"
+test_objdump_d_show_all_symbols $testfile $testfile
# Test objdump -s