diff options
| author | George Rimar <grimar@accesssoftek.com> | 2017-06-01 07:47:56 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2017-06-01 07:47:56 +0000 |
| commit | b940f65cd21da6c3a686c432b070989e11ef1ea6 (patch) | |
| tree | d4638c82963746daf895edb565e54a02e6d7761b | |
| parent | 348df0de15ee3fbf8908109a7231dc689e6d033e (diff) | |
| download | bcm5719-llvm-b940f65cd21da6c3a686c432b070989e11ef1ea6.tar.gz bcm5719-llvm-b940f65cd21da6c3a686c432b070989e11ef1ea6.zip | |
[ELF] - Do not crash when proccessing absolute symbols during GC.
This is PR33239, previously we segfault on given testcase.
Differential revision: https://reviews.llvm.org/D33713
llvm-svn: 304392
| -rw-r--r-- | lld/ELF/MarkLive.cpp | 3 | ||||
| -rw-r--r-- | lld/test/ELF/gc-absolute.s | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index ee499265886..b77c84ff75a 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -220,7 +220,8 @@ template <class ELFT> void elf::markLive() { auto MarkSymbol = [&](const SymbolBody *Sym) { if (auto *D = dyn_cast_or_null<DefinedRegular>(Sym)) - Enqueue({cast<InputSectionBase>(D->Section), D->Value}); + if (auto *IS = cast_or_null<InputSectionBase>(D->Section)) + Enqueue({IS, D->Value}); }; // Add GC root symbols. diff --git a/lld/test/ELF/gc-absolute.s b/lld/test/ELF/gc-absolute.s new file mode 100644 index 00000000000..29e671678ee --- /dev/null +++ b/lld/test/ELF/gc-absolute.s @@ -0,0 +1,7 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t2 -shared --gc-sections + +.global foo +foo = 0x123 |

