[binutils-gdb] objdump -d with -j and objdump disassembly of .plt

Alan Modra amodra@sourceware.org
Tue Feb 3 21:03:34 GMT 2026


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

commit 25974c2e9f3b1b766bf6b3c541546ce5819f7834
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Feb 4 07:31:26 2026 +1030

    objdump -d with -j and objdump disassembly of .plt
    
    objdump -D disassembles non-code sections, paying no heed to symbols
    in those sections.  I think "objdump -d -j .data" should do the same,
    ie. not switch into dumping the section as data because an object
    symbol is encountered.
    
    On the other hand, dissassembly of .plt which is a code section, can
    dump the first part of .plt as data due to the presense of
    _PROCEDURE_LINKAGE_TABLE_.  Fix that too.
    
            PR 33243
            PR 33389
            PR 33515
    binutils/
            * objdump.c (disassemble_section): Ignore symbols in non-code
            sections.  Ignore _PROCEDURE_LINKAGE_TABLE_ too.
            * testsuite/binutils-all/compress.exp (test_gnu_debuglink): Don't
            xfail on Solaris/amd64.
    ld/
            * testsuite/ld-aarch64/rela-abs-relative-be.d,
            * testsuite/ld-aarch64/rela-abs-relative-opt.d,
            * testsuite/ld-aarch64/rela-abs-relative.d,
            * testsuite/ld-mips-elf/no-shared-1-n32.d,
            * testsuite/ld-mips-elf/no-shared-1-n64.d,
            * testsuite/ld-mips-elf/no-shared-1-o32.d: Update expected output.

Diff:
---
 binutils/objdump.c                              | 13 +++++++++----
 binutils/testsuite/binutils-all/compress.exp    |  1 -
 ld/testsuite/ld-aarch64/rela-abs-relative-be.d  | 13 ++++++-------
 ld/testsuite/ld-aarch64/rela-abs-relative-opt.d | 13 ++++++-------
 ld/testsuite/ld-aarch64/rela-abs-relative.d     | 13 ++++++-------
 ld/testsuite/ld-mips-elf/no-shared-1-n32.d      |  6 ++++--
 ld/testsuite/ld-mips-elf/no-shared-1-n64.d      |  8 +++++---
 ld/testsuite/ld-mips-elf/no-shared-1-o32.d      |  6 ++++--
 8 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/binutils/objdump.c b/binutils/objdump.c
index 1fb944909a0..a616a5cf7d7 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -4076,15 +4076,20 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
 	  || nextstop_offset <= addr_offset)
 	nextstop_offset = stop_offset;
 
-      /* If a symbol is explicitly marked as being an object
-	 rather than a function, just dump the bytes without
-	 disassembling them.  */
+      /* To better handle embedded data in a code section, just dump
+	 the bytes without disassembling them if we hit an object
+	 symbol.  Exclude _PROCEDURE_LINKAGE_TABLE_ as some ABIs
+	 require it to be an object even though code is expected.
+	 Take no notice of symbols if the user has explicity asked for
+	 a non-code section to be disassembled.  */
       if (disassemble_all
+	  || (section->flags & SEC_CODE) == 0
 	  || sym == NULL
 	  || sym->section != section
 	  || bfd_asymbol_value (sym) > addr
 	  || (sym->flags & BSF_OBJECT) == 0
-	  || (sym->flags & BSF_FUNCTION) != 0)
+	  || (sym->flags & BSF_FUNCTION) != 0
+	  || strcmp (sym->name, "_PROCEDURE_LINKAGE_TABLE_") == 0)
 	insns = true;
       else
 	insns = false;
diff --git a/binutils/testsuite/binutils-all/compress.exp b/binutils/testsuite/binutils-all/compress.exp
index 65351061745..ae2bf8010f8 100644
--- a/binutils/testsuite/binutils-all/compress.exp
+++ b/binutils/testsuite/binutils-all/compress.exp
@@ -780,7 +780,6 @@ proc test_gnu_debuglink {} {
     set status [remote_exec build diff "${src1} ${src2}"]
     set exec_output [lindex $status 1]
     set exec_output [prune_warnings $exec_output]
-    setup_xfail "x86_64-*-solaris2*" "PR binutils/33243"
     if ![string match "" $exec_output] then {
 	send_log "$exec_output\n"
 	verbose "$exec_output" 1
diff --git a/ld/testsuite/ld-aarch64/rela-abs-relative-be.d b/ld/testsuite/ld-aarch64/rela-abs-relative-be.d
index 333122a0bce..e222b2b3fe1 100644
--- a/ld/testsuite/ld-aarch64/rela-abs-relative-be.d
+++ b/ld/testsuite/ld-aarch64/rela-abs-relative-be.d
@@ -2,12 +2,11 @@
 #source: rela-abs-relative.s
 #alltargets: [check_shared_lib_support] aarch64_be-*-*
 #ld: -shared -Ttext-segment=0x100000 -Tdata=0x200000 -Trelocs.ld
-#objdump: -dR -j .data
-#...
+#objdump: -sR -j .data
 
-Disassembly of section .data:
+#...
+0+200008 R_AARCH64_RELATIVE  \*ABS\*\+0x0*100ca
 
-.* <a>:
-  200000:	00 00 00 00 ca fe ca fe 00 00 00 00 00 01 00 ca.*
-			200008: R_AARCH64_RELATIVE	\*ABS\*\+0x100ca
-  200010:	00 00 00 00 de ad de ad.*
+Contents of section \.data:
+ 200000 00000000 cafecafe 00000000 000100ca .*
+ 200010 00000000 deaddead                   .*
diff --git a/ld/testsuite/ld-aarch64/rela-abs-relative-opt.d b/ld/testsuite/ld-aarch64/rela-abs-relative-opt.d
index 7d76758ceee..0e51c78e317 100644
--- a/ld/testsuite/ld-aarch64/rela-abs-relative-opt.d
+++ b/ld/testsuite/ld-aarch64/rela-abs-relative-opt.d
@@ -3,12 +3,11 @@
 #target: [check_shared_lib_support]
 #ld: -shared -Ttext-segment=0x100000 -Tdata=0x200000 -Trelocs.ld --no-apply-dynamic-relocs
 #notarget: aarch64_be-*-*
-#objdump: -dR -j .data
-#...
+#objdump: -sR -j .data
 
-Disassembly of section .data:
+#...
+0+200008 R_AARCH64_RELATIVE  \*ABS\*\+0x0*100ca
 
-.* <a>:
-  200000:	fe ca fe ca 00 00 00 00 00 00 00 00 00 00 00 00.*
-			200008: R_AARCH64_RELATIVE	\*ABS\*\+0x100ca
-  200010:	ad de ad de 00 00 00 00.*
+Contents of section \.data:
+ 200000 fecafeca 00000000 00000000 00000000 .*
+ 200010 addeadde 00000000                   .*
diff --git a/ld/testsuite/ld-aarch64/rela-abs-relative.d b/ld/testsuite/ld-aarch64/rela-abs-relative.d
index 0d43bfc7401..47baa92df21 100644
--- a/ld/testsuite/ld-aarch64/rela-abs-relative.d
+++ b/ld/testsuite/ld-aarch64/rela-abs-relative.d
@@ -3,12 +3,11 @@
 #target: [check_shared_lib_support]
 #ld: -shared -Ttext-segment=0x100000 -Tdata=0x200000 -Trelocs.ld
 #notarget: aarch64_be-*-*
-#objdump: -dR -j .data
-#...
+#objdump: -sR -j .data
 
-Disassembly of section .data:
+#...
+0+200008 R_AARCH64_RELATIVE  \*ABS\*\+0x0*100ca
 
-.* <a>:
-  200000:	fe ca fe ca 00 00 00 00 ca 00 01 00 00 00 00 00.*
-			200008: R_AARCH64_RELATIVE	\*ABS\*\+0x100ca
-  200010:	ad de ad de 00 00 00 00.*
+Contents of section \.data:
+ 200000 fecafeca 00000000 ca000100 00000000 .*
+ 200010 addeadde 00000000                   .*
diff --git a/ld/testsuite/ld-mips-elf/no-shared-1-n32.d b/ld/testsuite/ld-mips-elf/no-shared-1-n32.d
index 5574360c7ea..955235141e5 100644
--- a/ld/testsuite/ld-mips-elf/no-shared-1-n32.d
+++ b/ld/testsuite/ld-mips-elf/no-shared-1-n32.d
@@ -16,9 +16,11 @@ Disassembly of section \.text:
 Disassembly of section \.data:
 
 00060000 .*:
-   60000:	00068000 	.*
+   60000:	00068000 .*
 #...
 Disassembly of section \.got:
 
 00060010 <_GLOBAL_OFFSET_TABLE_>:
-   60010:	00000000 80000000 00068000  .*
+   60010:	00000000 .*
+   60014:	80000000 .*
+   60018:	00068000 .*
diff --git a/ld/testsuite/ld-mips-elf/no-shared-1-n64.d b/ld/testsuite/ld-mips-elf/no-shared-1-n64.d
index b5cd86e7285..f6cfc3b2930 100644
--- a/ld/testsuite/ld-mips-elf/no-shared-1-n64.d
+++ b/ld/testsuite/ld-mips-elf/no-shared-1-n64.d
@@ -15,11 +15,13 @@ Disassembly of section \.text:
 Disassembly of section \.data:
 
 0000000000060000 .*:
-   60000:	00000000 	.*
-   60004:	00068000 	.*
+   60000:	00000000 .*
+   60004:	00068000 .*
 #...
 Disassembly of section \.got:
 
 0000000000060010 <_GLOBAL_OFFSET_TABLE_>:
 	\.\.\.
-   60018:	80000000 00000000 00000000 00068000  .*
+   60018:	80000000 .*
+	\.\.\.
+   60024:	00068000 .*
diff --git a/ld/testsuite/ld-mips-elf/no-shared-1-o32.d b/ld/testsuite/ld-mips-elf/no-shared-1-o32.d
index fcb5f5db588..51322242527 100644
--- a/ld/testsuite/ld-mips-elf/no-shared-1-o32.d
+++ b/ld/testsuite/ld-mips-elf/no-shared-1-o32.d
@@ -15,9 +15,11 @@ Disassembly of section \.text:
 Disassembly of section \.data:
 
 00060000 .*:
-   60000:	00068000 	.*
+   60000:	00068000 .*
 #...
 Disassembly of section \.got:
 
 00060010 <_GLOBAL_OFFSET_TABLE_>:
-   60010:	00000000 80000000 00068000  .*
+   60010:	00000000 .*
+   60014:	80000000 .*
+   60018:	00068000 .*


More information about the Binutils-cvs mailing list