non-conformant ELF symbol table on MIPS?

Ian Lance Taylor iant@google.com
Fri Jul 28 17:11:50 GMT 2023


On Thu, Jul 27, 2023 at 11:16 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 27.07.2023 21:04, Ian Lance Taylor wrote:
> > On Thu, Jul 27, 2023 at 7:28 AM Jan Beulich via Binutils
> > <binutils@sourceware.org> wrote:
> >>
> >> extending the gas elf/common3.s testcase (in the context of trying to fix
> >> PR gas/30688) to
> >>
> >>         .comm foobar,30,4
> >>         .comm buf1, 5-1, 8
> >>         .comm buf2, 4, 9-1
> >>         .lcomm lbuf, 9-1
> >>
> >> I notice a violation of the ELF spec on most (all?) MIPS targets I would
> >> routinely test for common code changes: "lbuf" is emitted last in the
> >> symbol table. The spec is quite clear: "In each symbol table, all
> >> symbols with STB_LOCAL binding precede the weak and global symbols." I
> >> guess I want/need to xfail that test for mips*-*-* for the time being,
> >> but it would be nice if you could shed some light on this behavior.
> >
> > This is historical behavior that dates back to the SGI Irix operating
> > system.  Search for elf_bad_symtab in the BFD sources.  Here is the
> > commend from elf-bfd.h:
> >
> >   /* Irix 5 often screws up the symbol table, sorting local symbols
> >      after global symbols.  This flag is set if the symbol table in
> >      this BFD appears to be screwed up.  If it is, we ignore the
> >      sh_info field in the symbol table header, and always read all the
> >      symbols.  */
> >   unsigned int bad_symtab : 1;
> >
> > I believe we currently set elf_bad_symtab true by default for most MIPS targets.
>
> That explains consuming behavior. But gas is a producer, and from what
> you say and quote I can't see why gas also needs to produce non-
> conforming symbol tables.

It was required for the linker, because otherwise the SGI IRIX dynamic
linker would not work correctly.

I don't recall whether it was required for gas.  That may have been an
accidental carry-over.  Or it may have been required for the IRIX
static linker to work, I don't remember.

Doing it for the plan mips-elf target is probably not the best choice today.

Ian


More information about the Binutils mailing list