[LLD][ELF] Support OVERLAY NOCROSSREFS (#133807)

This allows NOCROSSREFS to be specified in OVERLAY linker script
descriptions. This is a particularly useful part of the OVERLAY syntax,
since it's very rarely possible for one overlay section to sensibly
reference another.

Closes #128790
This commit is contained in:
Daniel Thornburgh
2025-04-02 09:25:18 -07:00
committed by GitHub
parent 6f959a46c0
commit e84b57dfbf
4 changed files with 33 additions and 0 deletions

View File

@@ -565,6 +565,7 @@ SmallVector<SectionCommand *, 0> ScriptParser::readOverlay() {
addrExpr = readExpr();
expect(":");
}
bool noCrossRefs = consume("NOCROSSREFS");
Expr lmaExpr = consume("AT") ? readParenExpr() : Expr{};
expect("{");
@@ -595,6 +596,12 @@ SmallVector<SectionCommand *, 0> ScriptParser::readOverlay() {
static_cast<OutputDesc *>(od)->osec.memoryRegionName =
std::string(regionName);
}
if (noCrossRefs) {
NoCrossRefCommand cmd;
for (SectionCommand *od : v)
cmd.outputSections.push_back(static_cast<OutputDesc *>(od)->osec.name);
ctx.script->noCrossRefs.push_back(std::move(cmd));
}
// According to the specification, at the end of the overlay, the location
// counter should be equal to the overlay base address plus size of the