Index: include/lld/Core/File.h =================================================================== --- include/lld/Core/File.h +++ include/lld/Core/File.h @@ -55,11 +55,15 @@ return _kind; } - /// \brief For error messages and debugging, this returns the path to the file - /// which was used to create this object (e.g. "/tmp/foo.o"). - StringRef path() const { - return _path; - } + /// This returns the path to the file which was used to create this object + /// (e.g. "/tmp/foo.o"). If the file is a member of an archive file, returns + /// the file name in the archive. + StringRef path() const { return _path; } + + /// Returns the path of the archive file name if this file is instantiated + /// from an archive file. Otehrwise returns the empty string. + StringRef archivePath() const { return _archivePath; } + void setArchivePath(StringRef path) { _archivePath = path; } /// Returns the command line order of the file. uint64_t ordinal() const { @@ -248,6 +252,7 @@ private: StringRef _path; + std::string _archivePath; Kind _kind; mutable uint64_t _ordinal; std::shared_ptr _sharedMemoryBuffer; Index: lib/ReaderWriter/FileArchive.cpp =================================================================== --- lib/ReaderWriter/FileArchive.cpp +++ lib/ReaderWriter/FileArchive.cpp @@ -196,7 +196,7 @@ llvm::errs() << memberPath << "\n"; std::unique_ptr memberMB(MemoryBuffer::getMemBuffer( - mb.getBuffer(), memberPath, false)); + mb.getBuffer(), mb.getBufferIdentifier(), false)); std::vector> files; if (std::error_code ec = _registry.loadFile(std::move(memberMB), files)) @@ -205,6 +205,7 @@ result = std::move(files[0]); if (std::error_code ec = result->parse()) return ec; + result->setArchivePath(_archive->getFileName()); // The memory buffer is co-owned by the archive file and the children, // so that the bufffer is deallocated when all the members are destructed.