non-conformant ELF symbol table on MIPS?

Ian Lance Taylor iant@google.com
Thu Jul 27 19:04:12 GMT 2023


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.

Ian


More information about the Binutils mailing list