This is slightly easier to read IMHO.
The main motivation is that with this a SharedSymbol doen't need a section, which reduces the size of SymbolUnion.
This seems makes things slightly simpler, so LGTM. Suggestions are below.
I would shorten this with something like:
Symbol Old = Sym; ... Sym.GotPltIndex = Old.GotPltIndex; ...
Maybe inline replaceWithDefined? These 2 lines look a bit lonely here. I would either inline or move them to replaceWithDefined.
Rebased and address some of the review comments.
This now move SharedSymbol from 80 to 72 bytes and Defined stays at 72.
With this the peak allocation when linking chromium goes from 568.1 to 564.2 MB.
We need replaceWithDefined for copy relocations and canonical plt entries, so I don't think we should inline it.
While these two lines are only needed when handling alias to copy relocated entries, they probably don't cause an harm if moved to replaceWithDefined. I will experiment with that.
Nice! I actually once tried to do the same thing but didn't succeed. It's nice to see you made it!
Please write a function comment to explain that a copy-relocated shared symbol is virtually the same as a defined symbol in a BSS section, so we replace the symbol as such.