diff options
Diffstat (limited to 'ELF/LinkerScript.cpp')
| -rw-r--r-- | ELF/LinkerScript.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ELF/LinkerScript.cpp b/ELF/LinkerScript.cpp index 492b81c1fa76..99c464e3714c 100644 --- a/ELF/LinkerScript.cpp +++ b/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(); } @@ -290,6 +291,9 @@ LinkerScript::computeInputSections(const InputSectionDescription *Cmd) { size_t SizeBefore = Ret.size(); for (InputSectionBase *Sec : InputSections) { + if (!isa<InputSection>(Sec)) + continue; + if (Sec->Assigned) continue; @@ -1076,6 +1080,9 @@ template <class ELFT> void OutputSectionCommand::writeTo(uint8_t *Buf) { return; } + if (Sec->Type == SHT_NOBITS) + return; + // Write leading padding. ArrayRef<InputSection *> Sections = Sec->Sections; uint32_t Filler = getFiller(); |
