summaryrefslogtreecommitdiffstats
path: root/lld/ELF
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF')
-rw-r--r--lld/ELF/LinkerScript.cpp7
-rw-r--r--lld/ELF/LinkerScript.h5
-rw-r--r--lld/ELF/ScriptParser.cpp6
3 files changed, 14 insertions, 4 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 492b81c1fa7..0feb830b797 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -52,11 +52,12 @@ LinkerScript *elf::Script;
uint64_t ExprValue::getValue() const {
if (Sec) {
if (Sec->getOutputSection())
- return Sec->getOffset(Val) + Sec->getOutputSection()->Addr;
+ return alignTo(Sec->getOffset(Val) + Sec->getOutputSection()->Addr,
+ Alignment);
error("unable to evaluate expression: input section " + Sec->Name +
" has no output section assigned");
}
- return Val;
+ return alignTo(Val, Alignment);
}
uint64_t ExprValue::getSecAddr() const {
@@ -143,7 +144,7 @@ void LinkerScript::assignSymbol(SymbolAssignment *Cmd, bool InSec) {
} else {
Sym->Section = V.Sec;
if (Sym->Section->Flags & SHF_ALLOC)
- Sym->Value = V.Val;
+ Sym->Value = alignTo(V.Val, V.Alignment);
else
Sym->Value = V.getValue();
}
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index e56e569d4e7..08f60f4517a 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -41,7 +41,12 @@ struct ExprValue {
SectionBase *Sec;
uint64_t Val;
bool ForceAbsolute;
+ uint64_t Alignment = 1;
+ ExprValue(SectionBase *Sec, bool ForceAbsolute, uint64_t Val,
+ uint64_t Alignment)
+ : Sec(Sec), Val(Val), ForceAbsolute(ForceAbsolute), Alignment(Alignment) {
+ }
ExprValue(SectionBase *Sec, bool ForceAbsolute, uint64_t Val)
: Sec(Sec), Val(Val), ForceAbsolute(ForceAbsolute) {}
ExprValue(SectionBase *Sec, uint64_t Val) : ExprValue(Sec, false, Val) {}
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index f1bc245c925..4b77e35b9ba 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -859,7 +859,11 @@ Expr ScriptParser::readPrimary() {
expect(",");
Expr E2 = readExpr();
expect(")");
- return [=] { return alignTo(E().getValue(), E2().getValue()); };
+ return [=] {
+ ExprValue V = E();
+ V.Alignment = E2().getValue();
+ return V;
+ };
}
if (Tok == "ALIGNOF") {
StringRef Name = readParenLiteral();
OpenPOWER on IntegriCloud