[ELF] Prevent SEGFAULT in case of conflict with an internally defined symbol.

Differential Revision: http://reviews.llvm.org/D14832

llvm-svn: 253588
This commit is contained in:
Igor Kudrin 2015-11-19 19:08:45 +00:00
parent c12c2790e1
commit 4bc5ad4c37
2 changed files with 13 additions and 1 deletions

View File

@ -139,7 +139,8 @@ void SymbolTable<ELFT>::reportConflict(const Twine &Message,
}
std::string Msg = (Message + ": " + Old.getName() + " in " +
OldFile->getName() + " and " + NewFile->getName())
(OldFile ? OldFile->getName() : "(internal)") + " and " +
(NewFile ? NewFile->getName() : "(internal)"))
.str();
if (Warning)
warning(Msg);

View File

@ -0,0 +1,11 @@
# Should print an expected message in case of conflict with an internally generated symbol.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
# CHECK: duplicate symbol: _gp in (internal) and {{.*}}
# REQUIRES: mips
.globl _gp
_gp = 0