public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] Fix previous delta to allow for compilation on 32-bit systems
@ 2022-12-16 15:45 Nick Clifton
  0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2022-12-16 15:45 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c7ce51d8c886cc4b34ccee30dd1e7add4058466f

commit c7ce51d8c886cc4b34ccee30dd1e7add4058466f
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Dec 16 15:44:55 2022 +0000

    Fix previous delta to allow for compilation on 32-bit systems

Diff:
---
 binutils/NEWS                               |  4 ++++
 binutils/doc/binutils.texi                  |  5 +++++
 binutils/dwarf.c                            |  6 +++---
 binutils/objdump.c                          | 22 ++++++++++++++++++++++
 binutils/testsuite/binutils-all/objdump.exp | 26 ++++++++++++++++++++++++++
 5 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/binutils/NEWS b/binutils/NEWS
index 5ff17f67650..3ac10f4a18d 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 852ed6002ef..c9d52d7c92f 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 533f1183012..03b36afcec0 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 6695c5d343f..d51abbe3858 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 436fc46d1a8..0ab784206ee 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-16 15:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16 15:45 [binutils-gdb] Fix previous delta to allow for compilation on 32-bit systems Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).