[lld] r323396 - Only lookup LMARegion once. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 17:36:36 PST 2018
Author: rafael
Date: Wed Jan 24 17:36:36 2018
New Revision: 323396
URL: http://llvm.org/viewvc/llvm-project?rev=323396&view=rev
Log:
Only lookup LMARegion once. NFC.
This is similar to how we handle MemRegion.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/OutputSections.h
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=323396&r1=323395&r2=323396&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Jan 24 17:36:36 2018
@@ -661,13 +661,9 @@ void LinkerScript::assignOffsets(OutputS
Ctx->LMAOffset = [=] { return Sec->LMAExpr().getValue() - D; };
}
- if (!Sec->LMARegionName.empty()) {
- if (MemoryRegion *MR = MemoryRegions.lookup(Sec->LMARegionName)) {
- uint64_t Offset = MR->Origin - Dot;
- Ctx->LMAOffset = [=] { return Offset; };
- } else {
- error("memory region '" + Sec->LMARegionName + "' not declared");
- }
+ if (MemoryRegion *MR = Sec->LMARegion) {
+ uint64_t Offset = MR->Origin - Dot;
+ Ctx->LMAOffset = [=] { return Offset; };
}
// If neither AT nor AT> is specified for an allocatable section, the linker
@@ -796,6 +792,12 @@ void LinkerScript::adjustSectionsAfterSo
if (auto *Sec = dyn_cast<OutputSection>(Base)) {
if (!Sec->Live)
continue;
+ if (!Sec->LMARegionName.empty()) {
+ if (MemoryRegion *M = MemoryRegions.lookup(Sec->LMARegionName))
+ Sec->LMARegion = M;
+ else
+ error("memory region '" + Sec->LMARegionName + "' not declared");
+ }
Sec->MemRegion = findMemoryRegion(Sec);
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
if (Sec->AlignExpr)
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=323396&r1=323395&r2=323396&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Wed Jan 24 17:36:36 2018
@@ -89,6 +89,7 @@ public:
// The following members are normally only used in linker scripts.
MemoryRegion *MemRegion = nullptr;
+ MemoryRegion *LMARegion = nullptr;
Expr AddrExpr;
Expr AlignExpr;
Expr LMAExpr;
More information about the llvm-commits
mailing list