[lld] r319874 - Fix a crash.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 5 18:53:43 PST 2017
Author: rafael
Date: Tue Dec 5 18:53:43 2017
New Revision: 319874
URL: http://llvm.org/viewvc/llvm-project?rev=319874&view=rev
Log:
Fix a crash.
This is a constructed testcase I noticed while working on another
patch.
Added:
lld/trunk/test/ELF/typed-undef.s
Modified:
lld/trunk/ELF/Relocations.cpp
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=319874&r1=319873&r2=319874&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Tue Dec 5 18:53:43 2017
@@ -601,8 +601,8 @@ static RelExpr adjustExpr(Symbol &Sym, R
if (Sym.isObject()) {
// Produce a copy relocation.
- auto *B = cast<SharedSymbol>(&Sym);
- if (!B->CopyRelSec) {
+ auto *B = dyn_cast<SharedSymbol>(&Sym);
+ if (B && !B->CopyRelSec) {
if (Config->ZNocopyreloc)
error("unresolvable relocation " + toString(Type) +
" against symbol '" + toString(*B) +
Added: lld/trunk/test/ELF/typed-undef.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/typed-undef.s?rev=319874&view=auto
==============================================================================
--- lld/trunk/test/ELF/typed-undef.s (added)
+++ lld/trunk/test/ELF/typed-undef.s Tue Dec 5 18:53:43 2017
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+
+# We used to crash on this, check that we don't
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t -pie --unresolved-symbols=ignore-all
+
+ .global _start
+_start:
+ .quad foo - .
+ .type foo, @object
More information about the llvm-commits
mailing list