Remember OffsetInArchive in LazyObjectFile.

LazyObjectFile might turn out to be a BitcodeFile, so we need
OffsetInArchive.

llvm-svn: 302242
This commit is contained in:
Rafael Espindola 2017-05-05 15:17:07 +00:00
parent 0b1413a881
commit 0f6cc65fe9
4 changed files with 13 additions and 5 deletions

View File

@ -187,7 +187,7 @@ void LinkerDriver::addFile(StringRef Path, bool WithLOption) {
// we'll handle it as if it had a symbol table. // we'll handle it as if it had a symbol table.
if (!File->hasSymbolTable()) { if (!File->hasSymbolTable()) {
for (const auto &P : getArchiveMembers(MBRef)) 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; return;
} }
@ -215,7 +215,7 @@ void LinkerDriver::addFile(StringRef Path, bool WithLOption) {
return; return;
default: default:
if (InLib) if (InLib)
Files.push_back(make<LazyObjectFile>(MBRef, "")); Files.push_back(make<LazyObjectFile>(MBRef, "", 0));
else else
Files.push_back(createObjectFile(MBRef)); Files.push_back(createObjectFile(MBRef));
} }

View File

@ -981,7 +981,7 @@ InputFile *LazyObjectFile::fetch() {
MemoryBufferRef MBRef = getBuffer(); MemoryBufferRef MBRef = getBuffer();
if (MBRef.getBuffer().empty()) if (MBRef.getBuffer().empty())
return nullptr; return nullptr;
return createObjectFile(MBRef, ArchiveName); return createObjectFile(MBRef, ArchiveName, OffsetInArchive);
} }
template <class ELFT> void LazyObjectFile::parse() { template <class ELFT> void LazyObjectFile::parse() {

View File

@ -219,8 +219,9 @@ private:
// archive file semantics. // archive file semantics.
class LazyObjectFile : public InputFile { class LazyObjectFile : public InputFile {
public: public:
explicit LazyObjectFile(MemoryBufferRef M, StringRef ArchiveName) explicit LazyObjectFile(MemoryBufferRef M, StringRef ArchiveName,
: InputFile(LazyObjectKind, M) { uint64_t OffsetInArchive)
: InputFile(LazyObjectKind, M), OffsetInArchive(OffsetInArchive) {
this->ArchiveName = ArchiveName; this->ArchiveName = ArchiveName;
} }
@ -238,6 +239,7 @@ private:
std::vector<StringRef> getBitcodeSymbols(); std::vector<StringRef> getBitcodeSymbols();
bool Seen = false; bool Seen = false;
uint64_t OffsetInArchive;
}; };
// An ArchiveFile object represents a .a file. // An ArchiveFile object represents a .a file.

View File

@ -2,9 +2,15 @@
; RUN: mkdir -p %t1 %t2 ; RUN: mkdir -p %t1 %t2
; RUN: opt -module-summary %p/Inputs/thin1.ll -o %t1/t.coll.o ; 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: opt -module-summary %p/Inputs/thin2.ll -o %t2/t.coll.o
; RUN: rm -f %t.a ; RUN: rm -f %t.a
; RUN: llvm-ar rcs %t.a %t1/t.coll.o %t2/t.coll.o ; 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: ld.lld %t.o %t.a -o %t
; RUN: llvm-nm %t | FileCheck %s ; RUN: llvm-nm %t | FileCheck %s