Fix a crash.

This is a constructed testcase I noticed while working on another
patch.

llvm-svn: 319874
This commit is contained in:
Rafael Espindola 2017-12-06 02:53:43 +00:00
parent 146a9c3e51
commit a834b529c3
2 changed files with 13 additions and 2 deletions

View File

@ -601,8 +601,8 @@ static RelExpr adjustExpr(Symbol &Sym, RelExpr Expr, RelType Type,
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) +

View File

@ -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