[PATCH 2/4] objdump: don't compare sections by name
Alan Modra
amodra@gmail.com
Wed Feb 26 23:21:07 GMT 2025
On Wed, Feb 26, 2025 at 12:58:55PM +0100, Jan Beulich wrote:
> Multiple sections of the same name may exist (32-bit HPPA for example
> looks to be keeping sections separate when combining object files with
> ld -r). And really there's no reason to go by section name: We can
> simply compare section pointers, as only a match with the section being
> disassembled is of interest.
> ---
> Tests put in place by subsequent patches will cover this, on HPPA 32-bit
> ELF.
>
> --- a/binutils/objdump.c
> +++ b/binutils/objdump.c
> @@ -1133,8 +1133,8 @@ compare_symbols (const void *ap, const v
> Don't sort symbols from other sections by section, since there
> isn't much reason to prefer one section over another otherwise.
> See sym_ok comment for why we compare by section name. */
> - as = strcmp (compare_section->name, a->section->name) == 0;
> - bs = strcmp (compare_section->name, b->section->name) == 0;
> + as = compare_section == a->section;
> + bs = compare_section == b->section;
> if (as && !bs)
> return -1;
> if (!as && bs)
The sym_ok comment says:
/* Note - we cannot just compare section pointers because they could
be different, but the same... Ie the symbol that we are trying to
find could have come from a separate debug info file. Under such
circumstances the symbol will be associated with a section in the
debug info file, whilst the section we want is in a normal file.
So the section pointers will be different, but the section names
will be the same. */
--
Alan Modra
More information about the Binutils
mailing list