lld: Simplify. NFC.

Obtained from:	LLVM r323440 by Rafael Espindola
This commit is contained in:
Ed Maste 2018-01-29 13:51:13 +00:00
parent 6fcb8605ef
commit 5a2ea37829
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328545
2 changed files with 6 additions and 10 deletions

View file

@ -656,22 +656,18 @@ void LinkerScript::assignOffsets(OutputSection *Sec) {
switchTo(Sec); switchTo(Sec);
if (Sec->LMAExpr) { if (Sec->LMAExpr)
uint64_t D = Dot; Ctx->LMAOffset = Sec->LMAExpr().getValue() - Dot;
Ctx->LMAOffset = [=] { return Sec->LMAExpr().getValue() - D; };
}
if (MemoryRegion *MR = Sec->LMARegion) { if (MemoryRegion *MR = Sec->LMARegion)
uint64_t Offset = MR->Origin - Dot; Ctx->LMAOffset = MR->Origin - Dot;
Ctx->LMAOffset = [=] { return Offset; };
}
// If neither AT nor AT> is specified for an allocatable section, the linker // If neither AT nor AT> is specified for an allocatable section, the linker
// will set the LMA such that the difference between VMA and LMA for the // 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 // 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 // https://sourceware.org/binutils/docs-2.20/ld/Output-Section-LMA.html
if (Ctx->LMAOffset) if (Ctx->LMAOffset)
Ctx->OutSec->LMAOffset = Ctx->LMAOffset(); Ctx->OutSec->LMAOffset = Ctx->LMAOffset;
// The Size previously denoted how many InputSections had been added to this // The Size previously denoted how many InputSections had been added to this
// section, and was used for sorting SHF_LINK_ORDER sections. Reset it to // section, and was used for sorting SHF_LINK_ORDER sections. Reset it to

View file

@ -206,7 +206,7 @@ class LinkerScript final {
uint64_t ThreadBssOffset = 0; uint64_t ThreadBssOffset = 0;
OutputSection *OutSec = nullptr; OutputSection *OutSec = nullptr;
MemoryRegion *MemRegion = nullptr; MemoryRegion *MemRegion = nullptr;
std::function<uint64_t()> LMAOffset; uint64_t LMAOffset = 0;
}; };
llvm::DenseMap<StringRef, OutputSection *> NameToOutputSection; llvm::DenseMap<StringRef, OutputSection *> NameToOutputSection;