From feed7506767533338c0f990237452e3f69de0eae Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 6 Apr 2017 21:31:24 +0000 Subject: Move call to findMemoryRegion before assignAddresses. This removes a bit more work from assignAddresses. llvm-svn: 299716 --- lld/ELF/LinkerScript.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lld/ELF/LinkerScript.cpp') diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index f20dbff3f31..d97db847304 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -583,8 +583,7 @@ void LinkerScript::assignOffsets(OutputSectionCommand *Cmd) { if (Cmd->AlignExpr) Sec->updateAlignment(Cmd->AlignExpr().getValue()); - // Try and find an appropriate memory region to assign offsets in. - CurMemRegion = findMemoryRegion(Cmd); + CurMemRegion = Cmd->MemRegion; if (CurMemRegion) Dot = CurMemRegion->Offset; switchTo(Sec); @@ -657,6 +656,11 @@ void LinkerScript::adjustSectionsBeforeSorting() { void LinkerScript::adjustSectionsAfterSorting() { placeOrphanSections(); + // Try and find an appropriate memory region to assign offsets in. + for (BaseCommand *Base : Opt.Commands) + if (auto *Cmd = dyn_cast(Base)) + Cmd->MemRegion = findMemoryRegion(Cmd); + // If output section command doesn't specify any segments, // and we haven't previously assigned any section to segment, // then we simply assign section to the very first load segment. -- cgit v1.2.3