This changes adds a new synthetic section CopyRelSection to hold the ZI reserved for the result of the copy relocation, moreover the dynamic copy relocation is made relative to the CopyRelSection. Previously we altered the size of the OutputSection and made the copy relocation relative to an offset into the OutputSection. This change has a couple of small benefits:
- All dynamic relocations are now relative to an InputSection, this means we can remove the support for OutputSection relative dynamic relocations, which makes us more robust to changes in section offsets after scanRelocs().
- If assignOffsets() is called on .bss or .bss.rel.ro the offsets and final size of the OutputSection will be correct. Previously the work of scanRelocs() would be destroyed by assignOffsets().
I wonder how many copy relocations are usually made for a program which needs copy relocations. If it is thousands, it is fine to create thousands of input sections here, but if it's more than that, we want to avoid that. (If it is small, I like this approach to create one section per a copy relocation, as it is simple.)