diff options
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 2240f7a0887..3f9b24ae8a9 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -112,8 +112,7 @@ static void expandMemoryRegion(MemoryRegion *MemRegion, uint64_t Size, "': overflowed by " + Twine(NewSize - MemRegion->Length) + " bytes"); } -void LinkerScript::expandOutputSection(uint64_t Size) { - Ctx->OutSec->Size += Size; +void LinkerScript::expandMemoryRegions(uint64_t Size) { if (Ctx->MemRegion) expandMemoryRegion(Ctx->MemRegion, Size, Ctx->MemRegion->Name, Ctx->OutSec->Name); @@ -122,6 +121,11 @@ void LinkerScript::expandOutputSection(uint64_t Size) { Ctx->OutSec->Name); } +void LinkerScript::expandOutputSection(uint64_t Size) { + Ctx->OutSec->Size += Size; + expandMemoryRegions(Size); +} + void LinkerScript::setDot(Expr E, const Twine &Loc, bool InSec) { uint64_t Val = E().getValue(); if (Val < Dot && InSec) @@ -707,9 +711,11 @@ void LinkerScript::output(InputSection *S) { void LinkerScript::switchTo(OutputSection *Sec) { if (Ctx->OutSec == Sec) return; - Ctx->OutSec = Sec; + + uint64_t Before = advance(0, 1); Ctx->OutSec->Addr = advance(0, Ctx->OutSec->Alignment); + expandMemoryRegions(Ctx->OutSec->Addr - Before); } // This function searches for a memory region to place the given output |

