Index: lld/trunk/ELF/Driver.cpp =================================================================== --- lld/trunk/ELF/Driver.cpp +++ lld/trunk/ELF/Driver.cpp @@ -185,7 +185,7 @@ // is attempting LTO and using a default ar command that doesn't // understand the LLVM bitcode file. It is a pretty common error, so // we'll handle it as if it had a symbol table. - if (!File->hasSymbolTable()) { + if (!File->isEmpty() && !File->hasSymbolTable()) { for (const auto &P : getArchiveMembers(MBRef)) Files.push_back(make(P.first, Path, P.second)); return; Index: lld/trunk/test/ELF/relocatable-empty-archive.s =================================================================== --- lld/trunk/test/ELF/relocatable-empty-archive.s +++ lld/trunk/test/ELF/relocatable-empty-archive.s @@ -0,0 +1,10 @@ +# REQUIRES: x86 +# RUN: rm %t.a +# RUN: llvm-ar rc %t.a +# RUN: ld.lld -m elf_x86_64 %t.a -o %t -r +# RUN: llvm-readobj -file-headers %t | FileCheck %s + +# CHECK: Format: ELF64-x86-64 +# CHECK: Arch: x86_64 +# CHECK: AddressSize: 64bit +# CHECK: Type: Relocatable