When a linker script is used with a pattern like { *(.bss .bss.*) } the InX::BssRelRo section will match against .bss.*. We want to make sure that when InX::BssRelRo hasn't created any .bss.rel.ro InputSections we don't report the .bss OutputSection as relro. We also want to give an error message if relro and non relro bss is placed within the same OutputSection.
This is an attempt at fixing the problem that motivated r318924 (D40364) in a way that doesn't need to check for empty or zero sized sections. The Synthetic Sections InX::BssRelRo and InX::Bss behave differently to other SyntheticSections in that they act as a proxy for creating .bss.rel.ro or .bss InputSections for copy relocations in their parent OutputSections. This means that they are always removed by removeUnusedSyntheticSections() and always have a zero size. This patch attempts to do the following:
- Move the name test before the InX::BssRelRo so that if it matches into an existing OutputSection that is already relro we are relro.
- If the OutputSection name is .bss.rel.ro then this is strong statement of intent like .data.rel.ro then we are relro.
- If all the InputSections in the parent OutputSection are .bss.rel.ro then we are relro.
- If none of the InputSections in the parent OutputSection are .bss.rel.ro then we are not relro.
- If there are both relro and non-relro InputSections then give an error message.
Is there a different test already for the opposite case, where we have .bss.rel.ro (with or without any other .bss), but with the same script? If not, I think that it would be beneficial to add it.