forked from OSchip/llvm-project
Handle a crash in conflict detection with archive members.
llvm-svn: 249996
This commit is contained in:
parent
4546181e12
commit
9afbac479f
|
@ -18,6 +18,7 @@
|
|||
namespace lld {
|
||||
namespace elf2 {
|
||||
|
||||
class ELFFileBase;
|
||||
class SymbolBody;
|
||||
|
||||
enum ELFKind {
|
||||
|
@ -30,6 +31,7 @@ enum ELFKind {
|
|||
|
||||
struct Configuration {
|
||||
SymbolBody *EntrySym = nullptr;
|
||||
ELFFileBase *FirstElf = nullptr;
|
||||
llvm::StringRef DynamicLinker;
|
||||
llvm::StringRef Entry;
|
||||
llvm::StringRef Emulation;
|
||||
|
|
|
@ -249,6 +249,9 @@ std::unique_ptr<ELFFileBase> createELFFile(MemoryBufferRef MB) {
|
|||
error("Invalid file class: " + MB.getBufferIdentifier());
|
||||
}
|
||||
|
||||
if (!Config->FirstElf)
|
||||
Config->FirstElf = Ret.get();
|
||||
|
||||
if (Config->ElfKind == ELFNoneKind) {
|
||||
Config->ElfKind = Ret->getELFKind();
|
||||
Config->EMachine = Ret->getEMachine();
|
||||
|
|
|
@ -35,7 +35,7 @@ void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {
|
|||
StringRef A = E->getName();
|
||||
StringRef B = Config->Emulation;
|
||||
if (B.empty())
|
||||
B = getFirstELF()->getName();
|
||||
B = Config->FirstElf->getName();
|
||||
error(A + " is incompatible with " + B);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/archive.s -o %ta.o
|
||||
// RUN: llvm-ar rc %t.a %ta.o
|
||||
// RUN: llvm-mc -filetype=obj -triple=i686-linux %s -o %tb.o
|
||||
// RUN: not ld.lld2 %t.a %tb.o 2>&1 | FileCheck %s
|
||||
|
||||
// We used to crash when
|
||||
// * The first object seen by the symbol table is from an archive.
|
||||
// * -m was not used.
|
||||
// CHECK: a.o is incompatible with {{.*}}b.o
|
||||
|
||||
// REQUIRES: x86
|
Loading…
Reference in New Issue