Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -113,9 +113,6 @@ case file_magic::elf_shared_object: Files.push_back(createSharedFile(MBRef)); return; - case sys::fs::file_magic::bitcode: - Files.push_back(make_unique(MBRef)); - return; default: Files.push_back(createObjectFile(MBRef)); } Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -457,16 +457,13 @@ template static std::unique_ptr createELFFileAux(MemoryBufferRef MB) { - std::unique_ptr Ret = llvm::make_unique(MB); - + std::unique_ptr Ret(new T(MB)); if (!Config->FirstElf) Config->FirstElf = Ret.get(); - if (Config->EKind == ELFNoneKind) { Config->EKind = Ret->getELFKind(); Config->EMachine = Ret->getEMachine(); } - return std::move(Ret); } @@ -491,7 +488,12 @@ std::unique_ptr elf2::createObjectFile(MemoryBufferRef MB, StringRef ArchiveName) { - std::unique_ptr F = createELFFile(MB); + using namespace sys::fs; + std::unique_ptr F; + if (identify_magic(MB.getBuffer()) == file_magic::bitcode) + F.reset(new BitcodeFile(MB)); + else + F = createELFFile(MB); F->ArchiveName = ArchiveName; return F; } Index: ELF/Symbols.cpp =================================================================== --- ELF/Symbols.cpp +++ ELF/Symbols.cpp @@ -209,13 +209,6 @@ // read from the library. if (MBRef.getBuffer().empty()) return std::unique_ptr(nullptr); - - if (sys::fs::identify_magic(MBRef.getBuffer()) == - sys::fs::file_magic::bitcode) { - auto Ret = make_unique(MBRef); - Ret->ArchiveName = File->getName(); - return std::move(Ret); - } return createObjectFile(MBRef, File->getName()); } Index: test/ELF/lto/archive.ll =================================================================== --- test/ELF/lto/archive.ll +++ test/ELF/lto/archive.ll @@ -5,6 +5,8 @@ ; RUN: llvm-as %s -o %t2.o ; RUN: ld.lld -m elf_x86_64 %t2.o %t.a -o %t3 -shared ; RUN: llvm-readobj -t %t3 | FileCheck %s +; RUN: ld.lld -m elf_x86_64 %t2.o --whole-archive %t.a -o %t3 -shared +; RUN: llvm-readobj -t %t3 | FileCheck %s ; CHECK: Name: g (