* non-conformant ELF symbol table on MIPS? @ 2023-07-27 14:27 Jan Beulich 2023-07-27 19:04 ` Ian Lance Taylor 2023-07-27 19:28 ` Maciej W. Rozycki 0 siblings, 2 replies; 11+ messages in thread From: Jan Beulich @ 2023-07-27 14:27 UTC (permalink / raw) To: Maciej W. Rozycki, Chenghua Xu; +Cc: Binutils Hello, 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. Thanks, Jan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-27 14:27 non-conformant ELF symbol table on MIPS? Jan Beulich @ 2023-07-27 19:04 ` Ian Lance Taylor 2023-07-27 19:39 ` Maciej W. Rozycki 2023-07-28 6:16 ` Jan Beulich 2023-07-27 19:28 ` Maciej W. Rozycki 1 sibling, 2 replies; 11+ messages in thread From: Ian Lance Taylor @ 2023-07-27 19:04 UTC (permalink / raw) To: Jan Beulich; +Cc: Maciej W. Rozycki, Chenghua Xu, Binutils 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-27 19:04 ` Ian Lance Taylor @ 2023-07-27 19:39 ` Maciej W. Rozycki 2023-07-28 6:16 ` Jan Beulich 1 sibling, 0 replies; 11+ messages in thread From: Maciej W. Rozycki @ 2023-07-27 19:39 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: Jan Beulich, Chenghua Xu, Binutils On Thu, 27 Jul 2023, Ian Lance Taylor wrote: > > 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. Maybe, though not sure if really, by the number of individual targets supported, but certainly not by the userbase. IRIX emulation is only used by IRIX targets (naturally, hardly used now) and some, especially older bare-metal targets. Then Linux, *BSD and the remaining bare-metal targets use traditional emulation. In particular IRIX emulation is incompatible with symbol versioning required by glibc 2.x, which was the motivation back in the day to add traditional emulation support to the MIPS backend. Maciej ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-27 19:04 ` Ian Lance Taylor 2023-07-27 19:39 ` Maciej W. Rozycki @ 2023-07-28 6:16 ` Jan Beulich 2023-07-28 17:11 ` Ian Lance Taylor 1 sibling, 1 reply; 11+ messages in thread From: Jan Beulich @ 2023-07-28 6:16 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: Maciej W. Rozycki, Chenghua Xu, Binutils 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. Jan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-28 6:16 ` Jan Beulich @ 2023-07-28 17:11 ` Ian Lance Taylor 2023-07-28 23:58 ` Alan Modra 0 siblings, 1 reply; 11+ messages in thread From: Ian Lance Taylor @ 2023-07-28 17:11 UTC (permalink / raw) To: Jan Beulich; +Cc: Maciej W. Rozycki, Chenghua Xu, Binutils 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-28 17:11 ` Ian Lance Taylor @ 2023-07-28 23:58 ` Alan Modra 0 siblings, 0 replies; 11+ messages in thread From: Alan Modra @ 2023-07-28 23:58 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: Jan Beulich, Maciej W. Rozycki, Chenghua Xu, Binutils On Fri, Jul 28, 2023 at 10:11:50AM -0700, Ian Lance Taylor via Binutils wrote: > 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. I think it is probably required. It's not just the sorting within symbol tables but also the meaning of sh_info. For mips irix5 a symbol table sh_info is the section symbol count, not the local symbol count. I say "probably" because I guess it might be possible to have SHT_SYMTAB and SHT_DYNSYM differ, but that seems even more weird. > Doing it for the plain mips-elf target is probably not the best choice today. I agree. -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-27 14:27 non-conformant ELF symbol table on MIPS? Jan Beulich 2023-07-27 19:04 ` Ian Lance Taylor @ 2023-07-27 19:28 ` Maciej W. Rozycki 2023-07-28 6:13 ` Jan Beulich 2023-07-28 6:18 ` Jan Beulich 1 sibling, 2 replies; 11+ messages in thread From: Maciej W. Rozycki @ 2023-07-27 19:28 UTC (permalink / raw) To: Jan Beulich; +Cc: Chenghua Xu, Binutils On Thu, 27 Jul 2023, Jan Beulich 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. Which specific MIPS target is it? There are two kinds of MIPS targets, ones that use the older IRIX symbol sorting rules and ones that use the newer "traditional" symbol sorting rules. The IRIX symbol sorting rules mandate that section symbols precede all other symbols, see e.g. bfd/elf32-mips.c:mips_elf_sym_is_global. Mind that SGI was an early adopter of the ELF standard and things weren't as settled as they are nowadays, hence e.g. the odd solution for composed relocations with the n64 psABI (later n32 uses standard ELF gABI ones) and other peculiarities here and there. Determining whether a MIPS target uses the IRIX emulation is complex, see e.g. how binutils/testsuite/binutils-all/mips/mips.exp sets `irixemul'. If you provide me with test case details (input and output), then I may be able to give you further advice, but otherwise you may want to mark the test case with `notarget' or suchlike rather than `xfail', because that's not a bug with the backend that the symbol ordering varies. Maciej ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-27 19:28 ` Maciej W. Rozycki @ 2023-07-28 6:13 ` Jan Beulich 2023-07-28 7:18 ` Jan Beulich 2023-07-28 6:18 ` Jan Beulich 1 sibling, 1 reply; 11+ messages in thread From: Jan Beulich @ 2023-07-28 6:13 UTC (permalink / raw) To: Maciej W. Rozycki; +Cc: Chenghua Xu, Binutils On 27.07.2023 21:28, Maciej W. Rozycki wrote: > On Thu, 27 Jul 2023, Jan Beulich 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. > > Which specific MIPS target is it? Among the 9 I test, it's mips-unknown-elf, mipsisa32r2el-unknown-elf, mips-sgi-irix6, and mipstx39-unknown-elf. > There are two kinds of MIPS targets, ones that use the older IRIX symbol > sorting rules and ones that use the newer "traditional" symbol sorting > rules. The IRIX symbol sorting rules mandate that section symbols precede > all other symbols, see e.g. bfd/elf32-mips.c:mips_elf_sym_is_global. > Mind that SGI was an early adopter of the ELF standard and things weren't > as settled as they are nowadays, hence e.g. the odd solution for composed > relocations with the n64 psABI (later n32 uses standard ELF gABI ones) and > other peculiarities here and there. > > Determining whether a MIPS target uses the IRIX emulation is complex, see > e.g. how binutils/testsuite/binutils-all/mips/mips.exp sets `irixemul'. > If you provide me with test case details (input and output), then I may be > able to give you further advice, I've provided you the input (see context above), and you'll be able to generate the object file from it yourself. But I don't see what this would bring, when you already indicate that this is "expected" behavior. > but otherwise you may want to mark the > test case with `notarget' or suchlike rather than `xfail', because that's > not a bug with the backend that the symbol ordering varies. I'm okay making mips*-*-irix* "notarget", but I don't view this as appropriate for e.g. mips*-unknown-elf. Instead I would prefer leaving further tweaking (if so needed) to you. The immediate goal is to get a regression fix (with an accompanying extension to a testcase) in quickly, such that hopefully Nick would still be able to pick it up for 2.41 (as in principle it affects most if not all targets). Jan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-28 6:13 ` Jan Beulich @ 2023-07-28 7:18 ` Jan Beulich 0 siblings, 0 replies; 11+ messages in thread From: Jan Beulich @ 2023-07-28 7:18 UTC (permalink / raw) To: Maciej W. Rozycki; +Cc: Chenghua Xu, Binutils On 28.07.2023 08:13, Jan Beulich wrote: > On 27.07.2023 21:28, Maciej W. Rozycki wrote: >> Determining whether a MIPS target uses the IRIX emulation is complex, see >> e.g. how binutils/testsuite/binutils-all/mips/mips.exp sets `irixemul'. >> If you provide me with test case details (input and output), then I may be >> able to give you further advice, > > I've provided you the input (see context above), and you'll be able to > generate the object file from it yourself. But I don't see what this > would bring, when you already indicate that this is "expected" behavior. > >> but otherwise you may want to mark the >> test case with `notarget' or suchlike rather than `xfail', because that's >> not a bug with the backend that the symbol ordering varies. > > I'm okay making mips*-*-irix* "notarget", but I don't view this as > appropriate for e.g. mips*-unknown-elf. Actually you're right, it needs to be notarget, or else we'd see "unexpected successes" on the other mips*-*-* targets. I'll refer to irixemul in the accompanying comment. Jan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-27 19:28 ` Maciej W. Rozycki 2023-07-28 6:13 ` Jan Beulich @ 2023-07-28 6:18 ` Jan Beulich 2023-07-28 6:56 ` Maciej W. Rozycki 1 sibling, 1 reply; 11+ messages in thread From: Jan Beulich @ 2023-07-28 6:18 UTC (permalink / raw) To: Maciej W. Rozycki; +Cc: Chenghua Xu, Binutils On 27.07.2023 21:28, Maciej W. Rozycki wrote: > On Thu, 27 Jul 2023, Jan Beulich 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. > > Which specific MIPS target is it? > > There are two kinds of MIPS targets, ones that use the older IRIX symbol > sorting rules and ones that use the newer "traditional" symbol sorting > rules. The IRIX symbol sorting rules mandate that section symbols precede > all other symbols, see e.g. bfd/elf32-mips.c:mips_elf_sym_is_global. Along the lines of my reply to Ian: This still doesn't explain the behavior I observe. What you say is required could still be met without violating ELF rules. Jan > Mind that SGI was an early adopter of the ELF standard and things weren't > as settled as they are nowadays, hence e.g. the odd solution for composed > relocations with the n64 psABI (later n32 uses standard ELF gABI ones) and > other peculiarities here and there. > > Determining whether a MIPS target uses the IRIX emulation is complex, see > e.g. how binutils/testsuite/binutils-all/mips/mips.exp sets `irixemul'. > If you provide me with test case details (input and output), then I may be > able to give you further advice, but otherwise you may want to mark the > test case with `notarget' or suchlike rather than `xfail', because that's > not a bug with the backend that the symbol ordering varies. > > Maciej ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: non-conformant ELF symbol table on MIPS? 2023-07-28 6:18 ` Jan Beulich @ 2023-07-28 6:56 ` Maciej W. Rozycki 0 siblings, 0 replies; 11+ messages in thread From: Maciej W. Rozycki @ 2023-07-28 6:56 UTC (permalink / raw) To: Jan Beulich; +Cc: Chenghua Xu, Binutils On Fri, 28 Jul 2023, Jan Beulich wrote: > > There are two kinds of MIPS targets, ones that use the older IRIX symbol > > sorting rules and ones that use the newer "traditional" symbol sorting > > rules. The IRIX symbol sorting rules mandate that section symbols precede > > all other symbols, see e.g. bfd/elf32-mips.c:mips_elf_sym_is_global. > > Along the lines of my reply to Ian: This still doesn't explain the > behavior I observe. What you say is required could still be met without > violating ELF rules. Yes, we could put section symbols first, then local ones, then external ones, and it was discussed many years ago, but it would require rather a heavy overhaul of generic parts of BFD. Someone would have to do it just to handle a corner case, so it was concluded that it wouldn't be the best use of time, which would better be spent on something more important. Maciej ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-07-28 23:58 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-07-27 14:27 non-conformant ELF symbol table on MIPS? Jan Beulich 2023-07-27 19:04 ` Ian Lance Taylor 2023-07-27 19:39 ` Maciej W. Rozycki 2023-07-28 6:16 ` Jan Beulich 2023-07-28 17:11 ` Ian Lance Taylor 2023-07-28 23:58 ` Alan Modra 2023-07-27 19:28 ` Maciej W. Rozycki 2023-07-28 6:13 ` Jan Beulich 2023-07-28 7:18 ` Jan Beulich 2023-07-28 6:18 ` Jan Beulich 2023-07-28 6:56 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).