Index: COFF/Symbols.cpp =================================================================== --- COFF/Symbols.cpp +++ COFF/Symbols.cpp @@ -221,17 +221,19 @@ return std::unique_ptr(nullptr); file_magic Magic = identify_magic(MBRef.getBuffer()); - if (Magic == file_magic::bitcode) - return std::unique_ptr(new BitcodeFile(MBRef)); if (Magic == file_magic::coff_import_library) return std::unique_ptr(new ImportFile(MBRef)); - if (Magic != file_magic::coff_object) { + std::unique_ptr Obj; + if (Magic == file_magic::coff_object) + Obj.reset(new ObjectFile(MBRef)); + else if (Magic == file_magic::bitcode) + Obj.reset(new BitcodeFile(MBRef)); + else { llvm::errs() << File->getName() << ": unknown file type\n"; return make_error_code(LLDError::InvalidFile); } - std::unique_ptr Obj(new ObjectFile(MBRef)); Obj->setParentName(File->getName()); return std::move(Obj); } Index: test/COFF/lto.ll =================================================================== --- test/COFF/lto.ll +++ test/COFF/lto.ll @@ -11,7 +11,7 @@ ; RUN: lld -flavor link2 /out:%T/main.exe /entry:main /include:f2 /subsystem:console %T/main.lto.obj %T/foo.lto.obj ; RUN: llvm-readobj -file-headers %T/main.exe | FileCheck -check-prefix=HEADERS-11 %s ; RUN: llvm-objdump -d %T/main.exe | FileCheck -check-prefix=TEXT-11 %s -; RUN: lld -flavor link2 /out:%T/main.exe /entry:main /include:f2 /subsystem:console %T/main.lto.obj %T/foo.lto.lib +; RUN: lld -flavor link2 /out:%T/main.exe /entry:main /include:f2 /subsystem:console %T/main.lto.obj %T/foo.lto.lib /verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s ; RUN: llvm-readobj -file-headers %T/main.exe | FileCheck -check-prefix=HEADERS-11 %s ; RUN: llvm-objdump -d %T/main.exe | FileCheck -check-prefix=TEXT-11 %s @@ -29,6 +29,8 @@ ; RUN: llvm-readobj -file-headers %T/main.exe | FileCheck -check-prefix=HEADERS-10 %s ; RUN: llvm-objdump -d %T/main.exe | FileCheck -check-prefix=TEXT-10 %s +; VERBOSE: foo.lto.lib({{.*}}foo.lto.obj) + ; HEADERS-11: AddressOfEntryPoint: 0x1000 ; TEXT-11: Disassembly of section .text: ; TEXT-11-NEXT: .text: