diff options
-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 |