diff options
| author | Petr Hosek <phosek@chromium.org> | 2017-05-30 05:17:58 +0000 |
|---|---|---|
| committer | Petr Hosek <phosek@chromium.org> | 2017-05-30 05:17:58 +0000 |
| commit | 08dfd5326997265e42f08c2ce97c53874f6f7f54 (patch) | |
| tree | 5b3fb4bf5effa19da72c7707729a9fbc997d93df | |
| parent | d7b94d384052a9c949e8731a5d4d8f3186df6bb7 (diff) | |
| download | bcm5719-llvm-08dfd5326997265e42f08c2ce97c53874f6f7f54.tar.gz bcm5719-llvm-08dfd5326997265e42f08c2ce97c53874f6f7f54.zip | |
[ELF] Filter out non InputSection members from InputSections
InputSections may contain MergeInputSection members which trigger
a segmentation fault when trying to cast them to InputSection.
Differential Revision: https://reviews.llvm.org/D33628
llvm-svn: 304189
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 3 | ||||
| -rw-r--r-- | lld/test/ELF/linkerscript/merge-sections.s | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 0feb830b797..7c4bf3aaebb 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -291,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; diff --git a/lld/test/ELF/linkerscript/merge-sections.s b/lld/test/ELF/linkerscript/merge-sections.s index ae53ebc4d40..950d822ec40 100644 --- a/lld/test/ELF/linkerscript/merge-sections.s +++ b/lld/test/ELF/linkerscript/merge-sections.s @@ -31,6 +31,16 @@ # 0x19E = begin + sizeof(.foo) = 0x190 + 0xE # CHECK-NEXT: Value: 0x19E +# Check that we don't crash with --gc-sections +# RUN: ld.lld --gc-sections -o %t2 --script %t.script %t -shared +# RUN: llvm-readobj -s -t %t2 | FileCheck %s --check-prefix=GC + +# GC: Name: .foo +# GC-NEXT: Type: SHT_PROGBITS +# GC-NEXT: Flags [ +# GC-NEXT: SHF_ALLOC +# GC-NEXT: ] + .section .foo.1a,"aMS",@progbits,1 .asciz "foo" |

