Avoid recursive calls to init (we would crash).

llvm-svn: 249412
This commit is contained in:
Rafael Espindola 2015-10-06 15:03:52 +00:00
parent d76603fbe7
commit b90582dbbd
2 changed files with 18 additions and 7 deletions

View File

@ -143,21 +143,24 @@ template <class ELFT> void SymbolTable::init(uint16_t EMachine) {
}
template <class ELFT> void SymbolTable::addELFFile(ELFFileBase *File) {
if (const ELFFileBase *Old = getFirstELF()) {
if (!Old->isCompatibleWith(*File))
error(Twine(Old->getName() + " is incompatible with " + File->getName()));
} else {
const ELFFileBase *Old = getFirstELF();
if (Old && !Old->isCompatibleWith(*File))
error(Twine(Old->getName() + " is incompatible with " + File->getName()));
if (auto *O = dyn_cast<ObjectFileBase>(File))
ObjectFiles.emplace_back(O);
else if (auto *S = dyn_cast<SharedFile<ELFT>>(File))
SharedFiles.emplace_back(S);
if (!Old)
init<ELFT>(File->getEMachine());
}
if (auto *O = dyn_cast<ObjectFileBase>(File)) {
ObjectFiles.emplace_back(O);
for (SymbolBody *Body : O->getSymbols())
resolve<ELFT>(Body);
}
if (auto *S = dyn_cast<SharedFile<ELFT>>(File)) {
SharedFiles.emplace_back(S);
for (SharedSymbol<ELFT> &Body : S->getSharedSymbols())
resolve<ELFT>(&Body);
}

View File

@ -23,3 +23,11 @@
# CHECK-NEXT: T bar
# CHECK-NEXT: T end
# CHECK-NEXT: w foo
# Test that the hitting the first object file after having a lazy symbol for
# _start is handled correctly.
# RUN: lld -flavor gnu2 %tar %t -o %tout
# RUN: llvm-nm %tout | FileCheck --check-prefix=AR-FIRST %s
# AR-FIRST: T _start