On Wed, Nov 2, 2022 at 6:21 PM Ard Biesheuvel <ardb@xxxxxxxxxx> wrote: > > Hello Masahiro, > > On Wed, 2 Nov 2022 at 10:13, Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote: > > > > This is an experimental patch, driven by the feedback from Jiri Slaby > > and Michael Matz. [1] > > > > Michael Matz says: > > "I know of no linker (outside LTO-like modes) that processes > > archives in a different order than first-to-last-member (under > > whole-archive), but that's not guaranteed anywhere. So relying on > > member-order within archives is always brittle." > > > > It is pretty easy to pass the list of objects instead of a thin archive > > because the linker supports the '@file' syntax, where command line > > arguments are read from 'file'. > > > > Can you explain which problem is solved by doing this? Jiri Slaby reported that the (not-upstreamed) GCC-LTO tree got broken due to 321648455061 ("kbuild: use obj-y instead extra-y for objects placed at the head") https://lore.kernel.org/linux-kbuild/ea468b86-abb7-bb2b-1e0a-4c8959d23f1c@xxxxxxxxxx/ I am not pretty sure because I did not check the downstream code. If I understood his report correctly, the reason for the breakage is because I put all objects into the thin archive, expecting the linker would preserve the object order in the archive. By specifying the object order directly in the command line, GCC-LTO should get back working again. > > If we can only produce a working kernel if each object is linked in > the order it appears in the archive, I think we have bigger problems > that need solving regardless. And for the .head.text objects that need > to appear at the start of the binary image, I think the reported issue > with __head annotated C functions on x86 needs to be addressed by > getting rid of __head entirely (which seems to have been introduced > without proper justification) I agree that it is the correct approach. I think my patch is unneeded (hence RFC), but I just wanted to know if linkers (gnu ld and lld) see any difference. -- Best Regards Masahiro Yamada