This is PR32026, we have next issue currently:
If script has a symbol assignment, for example PROVIDE(foo = 5)
and that foo is a lazy symbol. Then code that invokes processCommands()...addSymbol(Cmd);
will fetch that archive much later than we expect to see new sections to appear.
We have next code and comment:
void LinkerDriver::link(opt::InputArgList &Args) { .. // Now that we have a complete list of input files. // Beyond this point, no new files are added.
But that comment becomes not true in that case. We are adding new sections
from that archive for processing foo much later. Also if object where foo lives contains
mergeable section, then code that do splitIntoPieces() is completely skipped,
also this section is not merged into synthetic output section, because we doo that early.
To avoid that, patch implement early scan of assignments.
One of problems is that it does not support symbols definitions inside sections declarations,
like: ".foo : { ...; bar = .; }". It is complicated to implement those because we still need to filter
out sections not matching the constraints, so cant just add such symbols early like I did in this patch for
symbols outside. (Though I am not sure such symbols are really used in real livfe)
I think best way to implement it (if we want) is the next:
As an alternative solution probably we can reimplement handling of mergeable sections
and do not merge them into synthetics early, just like D29223 did.
I think that way later addition of sections and files will not be a problem, we should be
able to invoke merging and splitIntoPieces() from script side when we need it.
That way support of symbols like bar from above should be easy, though that complicates
the implementation of other parts, not sure if we want it now.