On some occasions output section listed in linker script may not be written to output file. This often happens if same linker script
is used to link many applications, some of them may, for example, contain EH frames or TLS sections and some may not.
In such case two problems arise:
- All symbols listed in such sections will be added to symbol table incorrectly. Their section index will be invalid.
- If some symbols refer address or size of an empty section then application will fail to link, because this section is not listed in OutputSections vector.
The ld and gold linkers use different approaches to address this problem:
- ld adds empty section symbols to preceding non-empty output section.
- gold makes those symbols absolute.
This patch uses gold-like way, converting all section-defined symbols to absolute. The address of an empty section is an address which it should have had in case it wasn't
empty.
While you are here, can you change the function name so that it sounds like a predicate function? I'd suggest satisifiesConstraint but you may come up with a better name. I think "Check" is not a good name because it is not obvious whether it will return true or false on success.