mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-17 04:50:15 +00:00
Don't crash on an empty section with an ALIGN.
llvm-svn: 308809
This commit is contained in:
parent
6a963f76ca
commit
ca5740d95a
@ -751,7 +751,7 @@ void LinkerScript::adjustSectionsAfterSorting() {
|
|||||||
if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {
|
if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {
|
||||||
Cmd->MemRegion = findMemoryRegion(Cmd);
|
Cmd->MemRegion = findMemoryRegion(Cmd);
|
||||||
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
|
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
|
||||||
if (Cmd->AlignExpr)
|
if (Cmd->AlignExpr && Cmd->Sec)
|
||||||
Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
|
Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
lld/test/ELF/linkerscript/align-section.s
Normal file
6
lld/test/ELF/linkerscript/align-section.s
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# REQUIRES: x86
|
||||||
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
||||||
|
# RUN: echo "SECTIONS { .foo : ALIGN(2M) { } }" > %t.script
|
||||||
|
# RUN: ld.lld -o %t --script %t.script %t.o -shared
|
||||||
|
|
||||||
|
# We would crash if an empty section had an ALIGN.
|
Loading…
Reference in New Issue
Block a user