aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2018-01-29 13:49:10 +0000
committerEd Maste <emaste@FreeBSD.org>2018-01-29 13:49:10 +0000
commit70bad665097a66b08025330f0678c471e77bcaa8 (patch)
tree89f60eb6cbd290ebae84f8211e91b2099e06e549 /contrib
parent032c24abe634720c4403c440e505cf5500aa6950 (diff)
downloadsrc-70bad665097a66b08025330f0678c471e77bcaa8.tar.gz
src-70bad665097a66b08025330f0678c471e77bcaa8.zip
lld: Only lookup LMARegion once. NFC.
This is similar to how we handle MemRegion. Obtained from: LLVM r323396 by Rafael Espindola
Notes
Notes: svn path=/head/; revision=328543
Diffstat (limited to 'contrib')
-rw-r--r--contrib/llvm/tools/lld/ELF/LinkerScript.cpp16
-rw-r--r--contrib/llvm/tools/lld/ELF/OutputSections.h1
2 files changed, 10 insertions, 7 deletions
diff --git a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
index fb8b5ad78a53..2b69de41c28d 100644
--- a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
+++ b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
@@ -661,13 +661,9 @@ void LinkerScript::assignOffsets(OutputSection *Sec) {
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::adjustSectionsAfterSorting() {
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)
diff --git a/contrib/llvm/tools/lld/ELF/OutputSections.h b/contrib/llvm/tools/lld/ELF/OutputSections.h
index 009f45c03333..dd7f0955c986 100644
--- a/contrib/llvm/tools/lld/ELF/OutputSections.h
+++ b/contrib/llvm/tools/lld/ELF/OutputSections.h
@@ -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;