[lld] 89c0f45 - [ELF] Simplify/remove LinkerScript::switchTo. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 28 19:05:20 PST 2021
Author: Fangrui Song
Date: 2021-11-28T19:05:15-08:00
New Revision: 89c0f4553ea62cef172a4924c21b40afdc744f11
URL: https://github.com/llvm/llvm-project/commit/89c0f4553ea62cef172a4924c21b40afdc744f11
DIFF: https://github.com/llvm/llvm-project/commit/89c0f4553ea62cef172a4924c21b40afdc744f11.diff
LOG: [ELF] Simplify/remove LinkerScript::switchTo. NFC
Added:
Modified:
lld/ELF/LinkerScript.cpp
lld/ELF/LinkerScript.h
Removed:
################################################################################
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index f497506d4750..3ba8c35e82bd 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -900,22 +900,6 @@ void LinkerScript::diagnoseOrphanHandling() const {
}
}
-void LinkerScript::switchTo(OutputSection *sec) {
- ctx->outSec = sec;
-
- const uint64_t pos = dot;
- if (sec->addrExpr && script->hasSectionsCommand) {
- // The alignment is ignored.
- ctx->outSec->addr = pos;
- } else {
- // ctx->outSec->alignment is the max of ALIGN and the maximum of input
- // section alignments.
- dot = alignTo(dot, ctx->outSec->alignment);
- ctx->outSec->addr = dot;
- expandMemoryRegions(dot - pos);
- }
-}
-
// This function searches for a memory region to place the given output
// section in. If found, a pointer to the appropriate memory region is
// returned in the first member of the pair. Otherwise, a nullptr is returned.
@@ -1004,7 +988,18 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
sec->name);
}
- switchTo(sec);
+ ctx->outSec = sec;
+ if (sec->addrExpr && script->hasSectionsCommand) {
+ // The alignment is ignored.
+ ctx->outSec->addr = dot;
+ } else {
+ // ctx->outSec->alignment is the max of ALIGN and the maximum of input
+ // section alignments.
+ const uint64_t pos = dot;
+ dot = alignTo(dot, ctx->outSec->alignment);
+ ctx->outSec->addr = dot;
+ expandMemoryRegions(dot - pos);
+ }
// ctx->lmaOffset is LMA minus VMA. If LMA is explicitly specified via AT() or
// AT>, recompute ctx->lmaOffset; otherwise, if both previous/current LMA
@@ -1316,7 +1311,7 @@ const Defined *LinkerScript::assignAddresses() {
AddressState state;
ctx = &state;
errorOnMissingSection = true;
- switchTo(aether);
+ ctx->outSec = aether;
SymbolAssignmentMap oldValues = getSymbolAssignmentValues(sectionCommands);
for (SectionCommand *cmd : sectionCommands) {
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 614ecb9f21be..badc4d126be8 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -292,8 +292,6 @@ class LinkerScript final {
std::pair<MemoryRegion *, MemoryRegion *>
findMemoryRegion(OutputSection *sec, MemoryRegion *hint);
- void switchTo(OutputSection *sec);
-
void assignOffsets(OutputSection *sec);
// Ctx captures the local AddressState and makes it accessible
More information about the llvm-commits
mailing list