[PATCH 3/4] objdump: properly disassemble successive functions of the same name
Jan Beulich
jbeulich@suse.com
Wed Feb 26 11:59:18 GMT 2025
... when only their symbol was requested for disassembly. Addressing the
respective FIXME is as easy as coverting the "else" there to an if()
with the opposite condition, thus accounting for the disabling the
original if() may have effected.
---
RFC: A number of targets don't configure or build ld. I'm surprised that
run_dump_test doesn't simply mark a test needing ld as UNSUPPORTED
or UNRESOLVED, when there is none. Am I overlooking some pre-cooked
way of handling this situation?
The testcase may not seem very useful for HPPA 32-bit ELF, where .text
sections are kept separate by "ld -r". However, the testcases here check
effectiveness of the earlier "objdump: don't compare sections by name".
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -3954,15 +3954,13 @@ disassemble_section (bfd *abfd, asection
break;
case next_sym:
- /* FIXME: There is an implicit assumption here
- that the name of sym is different from
- paux->symbol. */
if (! bfd_is_local_label (abfd, sym))
do_print = false;
break;
}
}
- else
+
+ if (!do_print)
{
const char * name = bfd_asymbol_name (sym);
char * alloc = NULL;
--- /dev/null
+++ b/binutils/testsuite/binutils-all/multi-1.d
@@ -0,0 +1,23 @@
+#name: objdump --disassemble= of consecutive same-name functions (1)
+#source: multi1.s
+#source: multi2.s
+#ld: -r
+#objdump: --disassemble=func -wz
+# ECOFF disassembly omits local symbols, for whatever reason.
+#xfail: "alpha*-*-*ecoff" "alpha*-*-osf*"
+
+.*: +file format .*
+
+Disassembly of section .*:
+
+0+ <func>:
+[ ]*[0-9a-f]+: [0-9a-f][0-9a-f].*
+#?[ ]*[0-9a-f]+: [0-9a-f][0-9a-f].*
+#?[ ]*[0-9a-f]+: [0-9a-f][0-9a-f].*
+
+# HPPA 32-bit ELF "ld -r" leaves .text unmerged.
+#?Disassembly of section .*:
+
+0+[0-3][0-9a-f] <func>:
+[ ]*[0-9a-f]+: [0-9a-f][0-9a-f].*
+#pass
--- /dev/null
+++ b/binutils/testsuite/binutils-all/multi-2.d
@@ -0,0 +1,23 @@
+#name: objdump --disassemble= of consecutive same-name functions (2)
+#source: multi2.s
+#source: multi1.s
+#ld: -r
+#objdump: --disassemble=func2 -wz
+# ECOFF disassembly omits local symbols, for whatever reason.
+#xfail: "alpha*-*-*ecoff" "alpha*-*-osf*"
+
+.*: +file format .*
+
+Disassembly of section .*:
+
+0+ <func2>:
+[ ]*[0-9a-f]+: [0-9a-f][0-9a-f].*
+#?[ ]*[0-9a-f]+: [0-9a-f][0-9a-f].*
+#?[ ]*[0-9a-f]+: [0-9a-f][0-9a-f].*
+
+# HPPA 32-bit ELF "ld -r" leaves .text unmerged.
+#?Disassembly of section .*:
+
+0+[0-3][0-9a-f] <func2>:
+[ ]*[0-9a-f]+: [0-9a-f][0-9a-f].*
+#pass
--- /dev/null
+++ b/binutils/testsuite/binutils-all/multi1.s
@@ -0,0 +1,6 @@
+ .text
+func:
+ .nop
+
+func2:
+ .nop
--- /dev/null
+++ b/binutils/testsuite/binutils-all/multi2.s
@@ -0,0 +1,6 @@
+ .text
+func2:
+ .nop
+
+func:
+ .nop
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -249,6 +249,22 @@ if { [ remote_file host exists $testarch
test_objdump_d $testarchive bintest2.${obj}
}
+# AIX gas doesn't add local symbols to the symbol table.
+# TI C30 and C54x ld emits various "address .. of tmpdir/dump section `...' is
+# not within region `...'" errors, which look bogus for relocatable linking.
+# alpha-vms doesn't support relocatable linking.
+# i?86-msdos ld generates an executable despite being passed -r.
+# Don't chance other than our own ld improperly handling -r.
+if { ![istarget "*-*-aix*"]
+ && ![istarget "*c30-*-*"]
+ && ![istarget "*c54x-*-*"]
+ && ![istarget "alpha-*-*vms*"]
+ && ![istarget "i?86-*-msdos"]
+ && [file normalize "$LD"] == [file normalize "$objdir/../ld/ld-new"]} then {
+ run_dump_test multi-1
+ run_dump_test multi-2
+}
+
# Test objdump --disassemble=<symbol>
proc test_objdump_d_sym { testfile dumpfile } {
global OBJDUMP
More information about the Binutils
mailing list