soc: nxp: Fix boot header placement when using lld #87929
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As well described in #58315, the GNU ld and LLVM lld linkers treat the location counter (
.
) differently. lld always inteprets the location counter as an absolute address whereas ld interprets it as an offset from the start of the current object.The NXP boot header linker script files use
.
assignment to specify an offset within therom_start
output section, which is fine for ld. However, lld errors out, as it sees the offset as an absolute address, which would require it to move the location counter backwards.To fix this, re-use the idea from #58315: replace
. = FOO_OFFSET
with. += FOO_OFFSET - (. - __rom_start_address)
. Given that__rom_start_address
is already set up to be at the very start of therom_start
output section, this sets the location counter in a way that works with both ld and lld.