[lld] r261663 - Handle bitcode files in archive files with --whole-archive.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 23 10:17:14 PST 2016
Author: ruiu
Date: Tue Feb 23 12:17:11 2016
New Revision: 261663
URL: http://llvm.org/viewvc/llvm-project?rev=261663&view=rev
Log:
Handle bitcode files in archive files with --whole-archive.
This patch moves BitcodeFile instantiation into createObjectFile.
Previously, we handle bitcode files outside that function and did
not handle for --whole-archive.
http://reviews.llvm.org/D17527
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/Symbols.cpp
lld/trunk/test/ELF/lto/archive.ll
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=261663&r1=261662&r2=261663&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Feb 23 12:17:11 2016
@@ -113,9 +113,6 @@ void LinkerDriver::addFile(StringRef Pat
case file_magic::elf_shared_object:
Files.push_back(createSharedFile(MBRef));
return;
- case sys::fs::file_magic::bitcode:
- Files.push_back(make_unique<BitcodeFile>(MBRef));
- return;
default:
Files.push_back(createObjectFile(MBRef));
}
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=261663&r1=261662&r2=261663&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Tue Feb 23 12:17:11 2016
@@ -491,7 +491,12 @@ static std::unique_ptr<InputFile> create
std::unique_ptr<InputFile> elf2::createObjectFile(MemoryBufferRef MB,
StringRef ArchiveName) {
- std::unique_ptr<InputFile> F = createELFFile<ObjectFile>(MB);
+ using namespace sys::fs;
+ std::unique_ptr<InputFile> F;
+ if (identify_magic(MB.getBuffer()) == file_magic::bitcode)
+ F.reset(new BitcodeFile(MB));
+ else
+ F = createELFFile<ObjectFile>(MB);
F->ArchiveName = ArchiveName;
return F;
}
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=261663&r1=261662&r2=261663&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Tue Feb 23 12:17:11 2016
@@ -209,13 +209,6 @@ std::unique_ptr<InputFile> Lazy::getMemb
// read from the library.
if (MBRef.getBuffer().empty())
return std::unique_ptr<InputFile>(nullptr);
-
- if (sys::fs::identify_magic(MBRef.getBuffer()) ==
- sys::fs::file_magic::bitcode) {
- auto Ret = make_unique<BitcodeFile>(MBRef);
- Ret->ArchiveName = File->getName();
- return std::move(Ret);
- }
return createObjectFile(MBRef, File->getName());
}
Modified: lld/trunk/test/ELF/lto/archive.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/archive.ll?rev=261663&r1=261662&r2=261663&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/archive.ll (original)
+++ lld/trunk/test/ELF/lto/archive.ll Tue Feb 23 12:17:11 2016
@@ -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 (
More information about the llvm-commits
mailing list