[mach-o] Fix MachOFileNode to own archives same as ELFFileNode

My previous fix to have FileArchive own the member MemoryBuffers was not a
complete solution for darwin because nothing owned the FileArchive object.
Fixed MachOFileNode to be like ELFFileNode and have the graph node own the
archive object.

llvm-svn: 221552
This commit is contained in:
Nick Kledzik 2014-11-07 22:00:23 +00:00
parent 03603439e3
commit f04ab0a244
2 changed files with 6 additions and 1 deletions

View File

@ -17,6 +17,7 @@
#ifndef LLD_DRIVER_DARWIN_INPUT_GRAPH_H
#define LLD_DRIVER_DARWIN_INPUT_GRAPH_H
#include "lld/Core/ArchiveLibraryFile.h"
#include "lld/Core/InputGraph.h"
#include "lld/ReaderWriter/MachOLinkingContext.h"
@ -67,6 +68,7 @@ private:
void narrowFatBuffer(StringRef filePath);
MachOLinkingContext &_context;
std::unique_ptr<const ArchiveLibraryFile> _archiveFile;
bool _isWholeArchive;
bool _upwardDylib;
};

View File

@ -88,7 +88,10 @@ std::error_code MachOFileNode::parse(const LinkingContext &ctx,
// If file is an archive and -all_load, then add all members.
if (ArchiveLibraryFile *archive = dyn_cast<ArchiveLibraryFile>(pf.get())) {
if (_isWholeArchive) {
// Note: the members are added to _files, but the archive is not.
// Have this node own the FileArchive object.
_archiveFile.reset(archive);
pf.release();
// Add all members to _files vector
return archive->parseAllMembers(_files);
}
}