forked from OSchip/llvm-project
[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:
parent
03603439e3
commit
f04ab0a244
|
@ -17,6 +17,7 @@
|
||||||
#ifndef LLD_DRIVER_DARWIN_INPUT_GRAPH_H
|
#ifndef LLD_DRIVER_DARWIN_INPUT_GRAPH_H
|
||||||
#define 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/Core/InputGraph.h"
|
||||||
#include "lld/ReaderWriter/MachOLinkingContext.h"
|
#include "lld/ReaderWriter/MachOLinkingContext.h"
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ private:
|
||||||
void narrowFatBuffer(StringRef filePath);
|
void narrowFatBuffer(StringRef filePath);
|
||||||
|
|
||||||
MachOLinkingContext &_context;
|
MachOLinkingContext &_context;
|
||||||
|
std::unique_ptr<const ArchiveLibraryFile> _archiveFile;
|
||||||
bool _isWholeArchive;
|
bool _isWholeArchive;
|
||||||
bool _upwardDylib;
|
bool _upwardDylib;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 file is an archive and -all_load, then add all members.
|
||||||
if (ArchiveLibraryFile *archive = dyn_cast<ArchiveLibraryFile>(pf.get())) {
|
if (ArchiveLibraryFile *archive = dyn_cast<ArchiveLibraryFile>(pf.get())) {
|
||||||
if (_isWholeArchive) {
|
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);
|
return archive->parseAllMembers(_files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue