summaryrefslogtreecommitdiffstats
path: root/lld/ELF
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF')
-rw-r--r--lld/ELF/LinkerScript.cpp6
-rw-r--r--lld/ELF/LinkerScript.h1
-rw-r--r--lld/ELF/ScriptParser.cpp6
3 files changed, 8 insertions, 5 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 121f2fb0c37..3ccc2c9a66e 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -70,6 +70,10 @@ uint64_t ExprValue::getSecAddr() const {
return 0;
}
+uint64_t ExprValue::getSectionOffset() const {
+ return getValue() - getSecAddr();
+}
+
static SymbolBody *addRegular(SymbolAssignment *Cmd) {
Symbol *Sym;
uint8_t Visibility = Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT;
@@ -141,7 +145,7 @@ void LinkerScript::assignSymbol(SymbolAssignment *Cmd, bool InSec) {
Sym->Value = V.getValue();
} else {
Sym->Section = V.Sec;
- Sym->Value = V.getValue() - V.getSecAddr();
+ Sym->Value = V.getSectionOffset();
}
}
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 0206b95384c..921bff05245 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -53,6 +53,7 @@ struct ExprValue {
bool isAbsolute() const { return ForceAbsolute || Sec == nullptr; }
uint64_t getValue() const;
uint64_t getSecAddr() const;
+ uint64_t getSectionOffset() const;
};
// This represents an expression in the linker script.
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 6a534e60cba..7d01bac1f39 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -147,13 +147,11 @@ static void moveAbsRight(ExprValue &A, ExprValue &B) {
static ExprValue add(ExprValue A, ExprValue B) {
moveAbsRight(A, B);
- uint64_t Val = alignTo(A.Val, A.Alignment) + B.getValue();
- return {A.Sec, A.ForceAbsolute, Val, A.Loc};
+ return {A.Sec, A.ForceAbsolute, A.getSectionOffset() + B.getValue(), A.Loc};
}
static ExprValue sub(ExprValue A, ExprValue B) {
- uint64_t Val = alignTo(A.Val, A.Alignment) - B.getValue();
- return {A.Sec, Val, A.Loc};
+ return {A.Sec, A.getSectionOffset() - B.getValue(), A.Loc};
}
static ExprValue mul(ExprValue A, ExprValue B) {
OpenPOWER on IntegriCloud