diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1712,9 +1712,16 @@ InputFile *elf::createObjectFile(MemoryBufferRef mb, StringRef archiveName, uint64_t offsetInArchive) { + Expected bcData = IRObjectFile::findBitcodeInMemBuffer(mb); + + // If it is a fatLTO object file + if (!errorToBool(bcData .takeError())) + return make(*bcData, archiveName, offsetInArchive, /*lazy=*/false); + if (isBitcode(mb)) return make(mb, archiveName, offsetInArchive, /*lazy=*/false); + switch (getELFKind(mb, archiveName)) { case ELF32LEKind: return make>(mb, archiveName); diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp --- a/llvm/lib/Object/ObjectFile.cpp +++ b/llvm/lib/Object/ObjectFile.cpp @@ -79,7 +79,7 @@ bool ObjectFile::isSectionBitcode(DataRefImpl Sec) const { Expected NameOrErr = getSectionName(Sec); if (NameOrErr) - return *NameOrErr == ".llvmbc"; + return *NameOrErr == ".llvmbc" || *NameOrErr == ".fatlto"; consumeError(NameOrErr.takeError()); return false; }