[PATCH] objdump: Use the SEC_CODE bit only for the section symbol
Alan Modra
amodra@gmail.com
Tue Sep 9 07:54:55 GMT 2025
On Tue, Sep 09, 2025 at 09:00:36AM +0200, Jan Beulich wrote:
> On 09.09.2025 08:43, Alan Modra wrote:
> > I think commit 6b27a220321e should be reverted. The place HJ was
> > patching is all about symbols so testing a section flag just looks
> > wrong. SEC_CODE is tested elsewhere. If _PROCEDURE_LINKAGE_TABLE_
> > or _GLOBAL_OFFSET_TABLE_ are causing a problem then do something
> > about those particular symbols.
>
> Yes, seeing the tweak here (which I expect wouldn't be the last one), I
> agree (and in hindsight I probably shouldn't have approved the change).
>
> > Hmm, why are we checking for gnu_compiled and gcc2_compiled here and
> > in compare_symbols? Wouldn't it be better to handle them once in
> > remove_useless_symbols?
>
> I, too, was wondering about that.
This passed testing, so committed along with reverting 6b27a220321e.
* objdump.c (remove_useless_symbols): Deal with gcc_compiled
and gcc2_compiled here..
(compare_symbols): ..rather than here..
(disassemble_section): ..and here.
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 0bea4d0761c..290f7e51f66 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1106,6 +1106,9 @@ remove_useless_symbols (asymbol **symbols, long count)
if (bfd_is_und_section (sym->section)
|| bfd_is_com_section (sym->section))
continue;
+ if (strstr (sym->name, "gnu_compiled")
+ || strstr (sym->name, "gcc2_compiled"))
+ continue;
*out_ptr++ = sym;
}
@@ -1171,18 +1174,6 @@ compare_symbols (const void *ap, const void *bp)
anl = strlen (an);
bnl = strlen (bn);
- /* The symbols gnu_compiled and gcc2_compiled convey no real
- information, so put them after other symbols with the same value. */
- af = (strstr (an, "gnu_compiled") != NULL
- || strstr (an, "gcc2_compiled") != NULL);
- bf = (strstr (bn, "gnu_compiled") != NULL
- || strstr (bn, "gcc2_compiled") != NULL);
-
- if (af && ! bf)
- return 1;
- if (! af && bf)
- return -1;
-
/* We use a heuristic for the file name, to try to sort it after
more useful symbols. It may not work on non Unix systems, but it
doesn't really matter; the only difference is precisely which
@@ -4092,11 +4083,7 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
|| sym == NULL
|| sym->section != section
|| bfd_asymbol_value (sym) > addr
- || ((sym->flags & BSF_OBJECT) == 0
- && (strstr (bfd_asymbol_name (sym), "gnu_compiled")
- == NULL)
- && (strstr (bfd_asymbol_name (sym), "gcc2_compiled")
- == NULL))
+ || (sym->flags & BSF_OBJECT) == 0
|| (sym->flags & BSF_FUNCTION) != 0)
insns = true;
else
--
Alan Modra
More information about the Binutils
mailing list