forked from OSchip/llvm-project
[ELF] - Allow producing -r output if only empty archive is given.
This is used by linux kernel build system. (https://www.kernel.org/doc/Documentation/kbuild/makefiles.txt "3.2 Built-in object goals") It has for example next configuration for linking built-in.o files: drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) drivers-$(CONFIG_PCI) += arch/ia64/pci/ ... drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/ Im most simple case all CONFIG_* options are off. That means linker is called with empty input archive, emulation option and no inputs and expected to generate some relocatable output. ld.bfd is able to do that, we dont. Patch allows to support this case. Differential revision: https://reviews.llvm.org/D33937 llvm-svn: 305069
This commit is contained in:
parent
de57795cc8
commit
1840901a2f
|
@ -185,7 +185,7 @@ void LinkerDriver::addFile(StringRef Path, bool WithLOption) {
|
|||
// 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<LazyObjectFile>(P.first, Path, P.second));
|
||||
return;
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue