[PATCH] D33937: [ELF] - Allow producing -r output if only empty archive is given.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 7 08:03:35 PDT 2017


grimar updated this revision to Diff 101738.
grimar added a comment.

- Addressed review comments.


https://reviews.llvm.org/D33937

Files:
  ELF/Driver.cpp
  test/ELF/relocatable-empty-archive.s


Index: test/ELF/relocatable-empty-archive.s
===================================================================
--- test/ELF/relocatable-empty-archive.s
+++ test/ELF/relocatable-empty-archive.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+# RUN: echo "" > %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o
+# RUN: llvm-ar rc %t.a %t.o
+# 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
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ 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<LazyObjectFile>(P.first, Path, P.second));
       return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33937.101738.patch
Type: text/x-patch
Size: 1140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170607/d9ef31f4/attachment.bin>


More information about the llvm-commits mailing list