diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-12-11 19:45:36 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-12-11 19:45:36 +0000 |
commit | af57d48ed4576aa3e17ffacd08ab48b497088629 (patch) | |
tree | eae89dd11cdfc1c95880d6d1a106fa97c37a3ad3 | |
parent | bf5fad86db497775a4f0279b8a806d150c0fa201 (diff) | |
download | bcm5719-llvm-af57d48ed4576aa3e17ffacd08ab48b497088629.tar.gz bcm5719-llvm-af57d48ed4576aa3e17ffacd08ab48b497088629.zip |
Handle symbols pointing to output sections.
Now that gc sections runs after linker defined symbols are added it
can see symbols that point to an OutputSection.
Should fix a bot failure.
llvm-svn: 320412
-rw-r--r-- | lld/ELF/MarkLive.cpp | 2 | ||||
-rw-r--r-- | lld/test/ELF/gc-sections-linker-defined-symbol.s | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index e2d2ee9c6cf..fbf57a9ee2d 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -219,7 +219,7 @@ template <class ELFT> static void doGcSections() { auto MarkSymbol = [&](Symbol *Sym) { if (auto *D = dyn_cast_or_null<Defined>(Sym)) - if (auto *IS = cast_or_null<InputSectionBase>(D->Section)) + if (auto *IS = dyn_cast_or_null<InputSectionBase>(D->Section)) Enqueue(IS, D->Value); }; diff --git a/lld/test/ELF/gc-sections-linker-defined-symbol.s b/lld/test/ELF/gc-sections-linker-defined-symbol.s new file mode 100644 index 00000000000..8720b845091 --- /dev/null +++ b/lld/test/ELF/gc-sections-linker-defined-symbol.s @@ -0,0 +1,16 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t.so --gc-sections -shared +# RUN: llvm-readobj --dyn-symbols %t.so | FileCheck %s + +# CHECK: Name: _end@ +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other: +# CHECK-NEXT: Section: .dynamic + + .data + .quad _end |