diff options
author | Ed Maste <emaste@FreeBSD.org> | 2018-01-29 13:50:28 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2018-01-29 13:50:28 +0000 |
commit | 6fcb8605eff70d59ffa94679695b8cec10b2aee1 (patch) | |
tree | 4c683f66382784ffe979b65d61ab03a18ec1c768 /contrib | |
parent | 70bad665097a66b08025330f0678c471e77bcaa8 (diff) | |
download | src-6fcb8605eff70d59ffa94679695b8cec10b2aee1.tar.gz src-6fcb8605eff70d59ffa94679695b8cec10b2aee1.zip |
lld: Remove MemRegionOffset. NFC.
We can just use a member variable in MemoryRegion.
Obtained from: LLVM r323399 by Rafael Espindola
Notes
Notes:
svn path=/head/; revision=328544
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/llvm/tools/lld/ELF/LinkerScript.cpp | 10 | ||||
-rw-r--r-- | contrib/llvm/tools/lld/ELF/LinkerScript.h | 7 | ||||
-rw-r--r-- | contrib/llvm/tools/lld/ELF/ScriptParser.cpp | 4 |
3 files changed, 13 insertions, 8 deletions
diff --git a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp index 2b69de41c28d..6bd5d0ff7b21 100644 --- a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp +++ b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp @@ -590,7 +590,7 @@ void LinkerScript::output(InputSection *S) { // If there is a memory region associated with this input section, then // place the section in that region and update the region index. if (Ctx->MemRegion) { - uint64_t &CurOffset = Ctx->MemRegionOffset[Ctx->MemRegion]; + uint64_t &CurOffset = Ctx->MemRegion->CurPos; CurOffset += Pos - Before; uint64_t CurSize = CurOffset - Ctx->MemRegion->Origin; if (CurSize > Ctx->MemRegion->Length) { @@ -652,7 +652,7 @@ void LinkerScript::assignOffsets(OutputSection *Sec) { Ctx->MemRegion = Sec->MemRegion; if (Ctx->MemRegion) - Dot = Ctx->MemRegionOffset[Ctx->MemRegion]; + Dot = Ctx->MemRegion->CurPos; switchTo(Sec); @@ -693,7 +693,7 @@ void LinkerScript::assignOffsets(OutputSection *Sec) { Cmd->Offset = Dot - Ctx->OutSec->Addr; Dot += Cmd->Size; if (Ctx->MemRegion) - Ctx->MemRegionOffset[Ctx->MemRegion] += Cmd->Size; + Ctx->MemRegion->CurPos += Cmd->Size; Ctx->OutSec->Size = Dot - Ctx->OutSec->Addr; continue; } @@ -888,8 +888,8 @@ void LinkerScript::allocateHeaders(std::vector<PhdrEntry *> &Phdrs) { LinkerScript::AddressState::AddressState() { for (auto &MRI : Script->MemoryRegions) { - const MemoryRegion *MR = MRI.second; - MemRegionOffset[MR] = MR->Origin; + MemoryRegion *MR = MRI.second; + MR->CurPos = MR->Origin; } } diff --git a/contrib/llvm/tools/lld/ELF/LinkerScript.h b/contrib/llvm/tools/lld/ELF/LinkerScript.h index 11131dda8e26..f23da42e359a 100644 --- a/contrib/llvm/tools/lld/ELF/LinkerScript.h +++ b/contrib/llvm/tools/lld/ELF/LinkerScript.h @@ -118,11 +118,17 @@ enum class ConstraintKind { NoConstraint, ReadOnly, ReadWrite }; // target memory. Instances of the struct are created by parsing the // MEMORY command. struct MemoryRegion { + MemoryRegion(StringRef Name, uint64_t Origin, uint64_t Length, uint32_t Flags, + uint32_t NegFlags) + : Name(Name), Origin(Origin), Length(Length), Flags(Flags), + NegFlags(NegFlags) {} + std::string Name; uint64_t Origin; uint64_t Length; uint32_t Flags; uint32_t NegFlags; + uint64_t CurPos = 0; }; // This struct represents one section match pattern in SECTIONS() command. @@ -200,7 +206,6 @@ class LinkerScript final { uint64_t ThreadBssOffset = 0; OutputSection *OutSec = nullptr; MemoryRegion *MemRegion = nullptr; - llvm::DenseMap<const MemoryRegion *, uint64_t> MemRegionOffset; std::function<uint64_t()> LMAOffset; }; diff --git a/contrib/llvm/tools/lld/ELF/ScriptParser.cpp b/contrib/llvm/tools/lld/ELF/ScriptParser.cpp index e068beeee262..3d2606db8d06 100644 --- a/contrib/llvm/tools/lld/ELF/ScriptParser.cpp +++ b/contrib/llvm/tools/lld/ELF/ScriptParser.cpp @@ -1293,8 +1293,8 @@ void ScriptParser::readMemory() { // Add the memory region to the region map. if (Script->MemoryRegions.count(Name)) setError("region '" + Name + "' already defined"); - MemoryRegion *MR = make<MemoryRegion>(); - *MR = {Name, Origin, Length, Flags, NegFlags}; + MemoryRegion *MR = + make<MemoryRegion>(Name, Origin, Length, Flags, NegFlags); Script->MemoryRegions[Name] = MR; } } |