[lld] r302242 - Remember OffsetInArchive in LazyObjectFile.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri May 5 08:17:07 PDT 2017
Author: rafael
Date: Fri May 5 10:17:07 2017
New Revision: 302242
URL: http://llvm.org/viewvc/llvm-project?rev=302242&view=rev
Log:
Remember OffsetInArchive in LazyObjectFile.
LazyObjectFile might turn out to be a BitcodeFile, so we need
OffsetInArchive.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputFiles.h
lld/trunk/test/ELF/lto/thin-archivecollision.ll
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=302242&r1=302241&r2=302242&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri May 5 10:17:07 2017
@@ -187,7 +187,7 @@ void LinkerDriver::addFile(StringRef Pat
// we'll handle it as if it had a symbol table.
if (!File->hasSymbolTable()) {
for (const auto &P : getArchiveMembers(MBRef))
- Files.push_back(make<LazyObjectFile>(P.first, Path));
+ Files.push_back(make<LazyObjectFile>(P.first, Path, P.second));
return;
}
@@ -215,7 +215,7 @@ void LinkerDriver::addFile(StringRef Pat
return;
default:
if (InLib)
- Files.push_back(make<LazyObjectFile>(MBRef, ""));
+ Files.push_back(make<LazyObjectFile>(MBRef, "", 0));
else
Files.push_back(createObjectFile(MBRef));
}
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=302242&r1=302241&r2=302242&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri May 5 10:17:07 2017
@@ -981,7 +981,7 @@ InputFile *LazyObjectFile::fetch() {
MemoryBufferRef MBRef = getBuffer();
if (MBRef.getBuffer().empty())
return nullptr;
- return createObjectFile(MBRef, ArchiveName);
+ return createObjectFile(MBRef, ArchiveName, OffsetInArchive);
}
template <class ELFT> void LazyObjectFile::parse() {
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=302242&r1=302241&r2=302242&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Fri May 5 10:17:07 2017
@@ -219,8 +219,9 @@ private:
// archive file semantics.
class LazyObjectFile : public InputFile {
public:
- explicit LazyObjectFile(MemoryBufferRef M, StringRef ArchiveName)
- : InputFile(LazyObjectKind, M) {
+ explicit LazyObjectFile(MemoryBufferRef M, StringRef ArchiveName,
+ uint64_t OffsetInArchive)
+ : InputFile(LazyObjectKind, M), OffsetInArchive(OffsetInArchive) {
this->ArchiveName = ArchiveName;
}
@@ -238,6 +239,7 @@ private:
std::vector<StringRef> getBitcodeSymbols();
bool Seen = false;
+ uint64_t OffsetInArchive;
};
// An ArchiveFile object represents a .a file.
Modified: lld/trunk/test/ELF/lto/thin-archivecollision.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/thin-archivecollision.ll?rev=302242&r1=302241&r2=302242&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/thin-archivecollision.ll (original)
+++ lld/trunk/test/ELF/lto/thin-archivecollision.ll Fri May 5 10:17:07 2017
@@ -2,9 +2,15 @@
; RUN: mkdir -p %t1 %t2
; RUN: opt -module-summary %p/Inputs/thin1.ll -o %t1/t.coll.o
; RUN: opt -module-summary %p/Inputs/thin2.ll -o %t2/t.coll.o
+
; RUN: rm -f %t.a
; RUN: llvm-ar rcs %t.a %t1/t.coll.o %t2/t.coll.o
+; RUN: ld.lld %t.o %t.a -o %t
+; RUN: llvm-nm %t | FileCheck %s
+; Check without a archive symbol table
+; RUN: rm -f %t.a
+; RUN: llvm-ar rcS %t.a %t1/t.coll.o %t2/t.coll.o
; RUN: ld.lld %t.o %t.a -o %t
; RUN: llvm-nm %t | FileCheck %s
More information about the llvm-commits
mailing list