summaryrefslogtreecommitdiff
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2024-06-27 16:32:27 -0700
committershawbyoung <shawbyoung@gmail.com>2024-06-27 16:32:27 -0700
commitf5c7df12cacdb84552b36a7ac598a8db41acc680 (patch)
tree3b33e941b9bfb88c40c64fd18ee32a633423cbed /lld/ELF/LinkerScript.cpp
parent608880c3a7a59c86db82728067e553a8d4665a45 (diff)
parent804415825b97e974c96a92580bcbeaf4c7ff0a04 (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/shawbyoung/spr/main.boltnfc-refactoring-callgraph
Created using spr 1.3.4 [skip ci]
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 68f5240ddc69..1ec796a3bdd9 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -177,11 +177,10 @@ void LinkerScript::setDot(Expr e, const Twine &loc, bool inSec) {
// report it if this is the last assignAddresses iteration. dot may be smaller
// if there is another assignAddresses iteration.
if (val < dot && inSec) {
- backwardDotErr =
- (loc + ": unable to move location counter (0x" + Twine::utohexstr(dot) +
- ") backward to 0x" + Twine::utohexstr(val) + " for section '" +
- state->outSec->name + "'")
- .str();
+ recordError(loc + ": unable to move location counter (0x" +
+ Twine::utohexstr(dot) + ") backward to 0x" +
+ Twine::utohexstr(val) + " for section '" + state->outSec->name +
+ "'");
}
// Update to location counter means update to section size.
@@ -1411,7 +1410,7 @@ LinkerScript::assignAddresses() {
state = &st;
errorOnMissingSection = true;
st.outSec = aether;
- backwardDotErr.clear();
+ recordedErrors.clear();
SymbolAssignmentMap oldValues = getSymbolAssignmentValues(sectionCommands);
for (SectionCommand *cmd : sectionCommands) {
@@ -1661,6 +1660,11 @@ void LinkerScript::printMemoryUsage(raw_ostream& os) {
}
}
+void LinkerScript::recordError(const Twine &msg) {
+ auto &str = recordedErrors.emplace_back();
+ msg.toVector(str);
+}
+
static void checkMemoryRegion(const MemoryRegion *region,
const OutputSection *osec, uint64_t addr) {
uint64_t osecEnd = addr + osec->size;
@@ -1673,8 +1677,8 @@ static void checkMemoryRegion(const MemoryRegion *region,
}
void LinkerScript::checkFinalScriptConditions() const {
- if (backwardDotErr.size())
- errorOrWarn(backwardDotErr);
+ for (StringRef err : recordedErrors)
+ errorOrWarn(err);
for (const OutputSection *sec : outputSections) {
if (const MemoryRegion *memoryRegion = sec->memRegion)
checkMemoryRegion(memoryRegion, sec, sec->addr);