InputSections with a SHF_LINK_ORDER dependency must be ordered in the same order as the InputSections that they have a dependency on. This ordering is done late in the link when the OutputSection containing a SHF_LINK_ORDER dependency is finalized. The reordering needs to handle these cases:
- No linker script SECTIONS command describing OutputSection
- Linker script that fully describes OutputSection with no orphans
- Linker script that partially describes OutputSection with orphans
At present we sort the OutputSection::Sections vector which will be fully or partially ignored if a linker script fully or partially describes the .ARM.exidx OutputSection. This is analogous to the insertion of thunks directly into OutputSection::Sections.
Building upon D32223:
This change:
- introduces a function inputSectionRanges() to obtain just the InputSectionDescriptions from an OutputSection.
- Inserts the .ARM.exidx sentinel into an InputSectionDescription
- Moves the fabricateInputSectionDescriptions before the call to OutputSection::finalize(), we need to do at least one call to Script->assignAddresses() to assign each InputSection its OutSecOff.
- Added a function to clear the state that accumulates with each call to assignAddresses() so that we can call it more than once.
- Consolidates the InputSectionDescriptions for .ARM.exidx into one as we need to sort the entire table. We can get multiple InputSectionDescriptions when something like
.ARM.exidx { *(.ARM.exidx) }
which will get orphans of the form .ARM.exidx.suffix.
- Sort the InputSectionDescription using the same criteria as before.
- Adds a test case that would previously fail as the later call to Script->assignAddresses() would ignore the sorting done to OutputSection::Sections().