From 9f141efc57812d3629082afc5520b182e38567e3 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 14 Jul 2015 21:28:07 +0000 Subject: [PATCH] Use getChildOffset instead of getBuffer for identifying a member. I am adding support for thin archives. On those, getting the buffer involves reading another file. Since we only need an id in here, use the member offset in the archive. llvm-svn: 242205 --- lld/COFF/InputFiles.cpp | 5 ++--- lld/COFF/InputFiles.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index 66d792b..d9312f6 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -76,7 +76,7 @@ std::error_code ArchiveFile::parse() { // all members are mapped to false, which indicates all these files // are not read yet. for (const Archive::Child &Child : File->children()) - Seen[Child.getBuffer().data()].clear(); + Seen[Child.getChildOffset()].clear(); return std::error_code(); } @@ -89,8 +89,7 @@ ErrorOr ArchiveFile::getMember(const Archive::Symbol *Sym) { Archive::child_iterator It = ItOrErr.get(); // Return an empty buffer if we have already returned the same buffer. - const char *StartAddr = It->getBuffer().data(); - if (Seen[StartAddr].test_and_set()) + if (Seen[It->getChildOffset()].test_and_set()) return MemoryBufferRef(); return It->getMemoryBufferRef(); } diff --git a/lld/COFF/InputFiles.h b/lld/COFF/InputFiles.h index 0d768c5..361d97d 100644 --- a/lld/COFF/InputFiles.h +++ b/lld/COFF/InputFiles.h @@ -107,7 +107,7 @@ private: std::unique_ptr File; std::string Filename; std::vector LazySymbols; - std::map Seen; + std::map Seen; llvm::MallocAllocator Alloc; }; -- 2.7.4