[lld] [ELF] OVERLAY: support optional start address and LMA (PR #77272)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 10:26:34 PST 2024


================
@@ -547,10 +549,15 @@ SmallVector<SectionCommand *, 0> ScriptParser::readOverlay() {
     // starting from the base load address specified.
     OutputDesc *osd = readOverlaySectionDescription();
     osd->osec.addrExpr = addrExpr;
-    if (prev)
+    if (prev) {
       osd->osec.lmaExpr = [=] { return prev->getLMA() + prev->size; };
-    else
+    } else {
       osd->osec.lmaExpr = lmaExpr;
+      // Ensure that the first section, even if empty, is not discarded.
+      // Subsequent sections share its address.
+      osd->osec.usedInExpression = true;
+      addrExpr = [=]() -> ExprValue { return {&osd->osec, false, 0, ""}; };
----------------
smithp35 wrote:

I guess addrExpr is for the case where the original addrExpr is DOT. May be worth updating the comment to.
```
// Use first section address for subsequent sections as initial addrExpr can be DOT. 
```

https://github.com/llvm/llvm-project/pull/77272


More information about the llvm-commits mailing list