Fixes PR45594.
In ObjFile<ELFT>::initializeSymbols(), for a defined symbol relative to
a discarded section (due to section group rules), it may have been
inserted as a lazy symbol. We need to demote it to an Undefined to
enable the discarded section error happened in a later pass.
Add LazyObjFile::fetched (if true) and ArchiveFile::parsed (if false) to represent that there is an
ongoing lazy symbol fetch and we should replace the current lazy symbol
with an Undefined, instead of calling Symbol::resolve (the lazy symbol
was added by an unrelated archive/lazy object).
As a side result, one small issue in start-lib-comdat.s is now fixed.
The hack motivating D51892 will be unsupported: if
.gnu.linkonce.t.__i686.get_pc_thunk.bx in an archive is referenced
by another section, this will likely be errored unless the function is
also defined in a regular object file.
(Bringing back rL330869 would error undefined symbol instead of the
more relevant discarded section.)
Note, glibc i386's crti.o still works (PR31215), because
.gnu.linkonce.t.__x86.get_pc_thunk.bx is in crti.o (one of the first
regular object files in a linker command line).
I am thinking about adding some flag like isFetched or alike to InputFile instead of using symbols.empty() this and in other places.
(Or perhaps only for ArchiveFile/LazyObjFile`)
It should look cleaner and avoid hacks like push_back(nullptr). What do you think?