diff options
-rw-r--r-- | lld/ELF/LinkerScript.cpp | 11 | ||||
-rw-r--r-- | lld/ELF/LinkerScript.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 143324dc1dc..eccbb76d4ba 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -463,9 +463,8 @@ void LinkerScript<ELFT>::switchTo(OutputSectionBase *Sec) { // will set the LMA such that the difference between VMA and LMA for the // section is the same as the preceding output section in the same region // https://sourceware.org/binutils/docs-2.20/ld/Output-Section-LMA.html - Expr LMAExpr = CurLMA.first; - if (LMAExpr) - CurOutSec->setLMAOffset(LMAExpr(CurLMA.second) - CurLMA.second); + if (LMAOffset) + CurOutSec->setLMAOffset(LMAOffset()); } template <class ELFT> void LinkerScript<ELFT>::process(BaseCommand &Base) { @@ -565,8 +564,10 @@ MemoryRegion *LinkerScript<ELFT>::findMemoryRegion(OutputSectionCommand *Cmd, // for a single sections command (e.g. ".text { *(.text); }"). template <class ELFT> void LinkerScript<ELFT>::assignOffsets(OutputSectionCommand *Cmd) { - if (Cmd->LMAExpr) - CurLMA = {Cmd->LMAExpr, Dot}; + if (Cmd->LMAExpr) { + uintX_t D = Dot; + LMAOffset = [=] { return Cmd->LMAExpr(D) - D; }; + } OutputSectionBase *Sec = findSection<ELFT>(Cmd->Name, *OutputSections); if (!Sec) return; diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 6893ad628bf..66bf1d6b3e3 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -298,7 +298,7 @@ private: OutputSectionBase *Sec); uintX_t Dot; - std::pair<Expr, uintX_t> CurLMA; + std::function<uint64_t()> LMAOffset; OutputSectionBase *CurOutSec = nullptr; MemoryRegion *CurMemRegion = nullptr; uintX_t ThreadBssOffset = 0; |