summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2018-01-01 19:18:30 +0000
committerkettenis <kettenis@openbsd.org>2018-01-01 19:18:30 +0000
commit7eceea36ce033ede90aab53c868ccba99e59ba4a (patch)
tree4fe793b67cfe7317b0754a5f1a7bcbc16675b60b
parentThe missing NULL check for the return value of malloc(9) with (diff)
downloadwireguard-openbsd-7eceea36ce033ede90aab53c868ccba99e59ba4a.tar.xz
wireguard-openbsd-7eceea36ce033ede90aab53c868ccba99e59ba4a.zip
Make lld respect ALIGN directives on output sections even with -r. Fixes
the generation of gap.o. ok patrick@
-rw-r--r--gnu/llvm/tools/lld/ELF/LinkerScript.cpp14
1 files 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<OutputSectionCommand>(Base)) {
+ if (auto *Cmd = dyn_cast<OutputSectionCommand>(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,