From 7eceea36ce033ede90aab53c868ccba99e59ba4a Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 1 Jan 2018 19:18:30 +0000 Subject: [PATCH] Make lld respect ALIGN directives on output sections even with -r. Fixes the generation of gap.o. ok patrick@ --- gnu/llvm/tools/lld/ELF/LinkerScript.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gnu/llvm/tools/lld/ELF/LinkerScript.cpp b/gnu/llvm/tools/lld/ELF/LinkerScript.cpp index 8bdbd8db20a..468c2ba80ce 100644 --- a/gnu/llvm/tools/lld/ELF/LinkerScript.cpp +++ b/gnu/llvm/tools/lld/ELF/LinkerScript.cpp @@ -732,6 +732,10 @@ void LinkerScript::adjustSectionsBeforeSorting() { continue; if (OutputSection *Sec = Cmd->Sec) { Flags = Sec->Flags; + + // Handle align (e.g. ".foo : ALIGN(16) { ... }"). + if (Cmd->AlignExpr) + Sec->updateAlignment(Cmd->AlignExpr().getValue()); continue; } @@ -742,18 +746,18 @@ void LinkerScript::adjustSectionsBeforeSorting() { OutSec->SectionIndex = I; Cmd->Sec = OutSec; SecToCommand[OutSec] = Cmd; + + // Handle align (e.g. ".foo : ALIGN(16) { ... }"). + if (Cmd->AlignExpr) + Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue()); } } void LinkerScript::adjustSectionsAfterSorting() { // Try and find an appropriate memory region to assign offsets in. for (BaseCommand *Base : Opt.Commands) { - if (auto *Cmd = dyn_cast(Base)) { + if (auto *Cmd = dyn_cast(Base)) Cmd->MemRegion = findMemoryRegion(Cmd); - // Handle align (e.g. ".foo : ALIGN(16) { ... }"). - if (Cmd->AlignExpr) - Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue()); - } } // If output section command doesn't specify any segments, -- 2.20.1