finalization time.
As currently implemented, RuntimeDyldELF requires the original object
file to be avaible when relocations are being resolved. This patch
ensures that the ObjectLinkingLayer preserves it until then. In the
future RuntimeDyldELF should be rewritten to remove this requirement, at
which point this patch can be reverted.
Regression test cases for Orc (which include coverage of this bug) will
be committed shortly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227778
91177308-0d34-0410-b5e6-
96231b3b80d8
Buffers.push_back(std::move(Buffer));
}
Buffers.push_back(std::move(Buffer));
}
- return BaseLayer.addObjectSet(std::move(Objects), std::move(MM));
+ ModuleSetHandleT H =
+ BaseLayer.addObjectSet(Objects, std::move(MM));
+
+ BaseLayer.takeOwnershipOfBuffers(H, std::move(Buffers));
+
+ return H;
}
/// @brief Remove the module set associated with the handle H.
}
/// @brief Remove the module set associated with the handle H.
RTDyld->resolveRelocations();
RTDyld->registerEHFrames();
MM->finalizeMemory();
RTDyld->resolveRelocations();
RTDyld->registerEHFrames();
MM->finalizeMemory();
RTDyld->mapSectionAddress(LocalAddress, TargetAddress);
}
RTDyld->mapSectionAddress(LocalAddress, TargetAddress);
}
+ void takeOwnershipOfBuffer(std::unique_ptr<MemoryBuffer> B) {
+ OwnedBuffers.push_back(std::move(B));
+ }
+
private:
std::unique_ptr<RTDyldMemoryManager> MM;
std::unique_ptr<RuntimeDyld> RTDyld;
enum { Raw, Finalizing, Finalized } State;
private:
std::unique_ptr<RTDyldMemoryManager> MM;
std::unique_ptr<RuntimeDyld> RTDyld;
enum { Raw, Finalizing, Finalized } State;
+
+ // FIXME: This ownership hack only exists because RuntimeDyldELF still
+ // wants to be able to inspect the original object when resolving
+ // relocations. As soon as that can be fixed this should be removed.
+ std::vector<std::unique_ptr<MemoryBuffer>> OwnedBuffers;
};
typedef std::list<LinkedObjectSet> LinkedObjectSetListT;
};
typedef std::list<LinkedObjectSet> LinkedObjectSetListT;
public:
/// @brief Handle to a set of loaded objects.
typedef LinkedObjectSetListT::iterator ObjSetHandleT;
public:
/// @brief Handle to a set of loaded objects.
typedef LinkedObjectSetListT::iterator ObjSetHandleT;
+
+ // Ownership hack.
+ // FIXME: Remove this as soon as RuntimeDyldELF can apply relocations without
+ // referencing the original object.
+ template <typename OwningMBSet>
+ void takeOwnershipOfBuffers(ObjSetHandleT H, OwningMBSet MBs) {
+ for (auto &MB : MBs)
+ H->takeOwnershipOfBuffer(std::move(MB));
+ }
+
};
/// @brief Default (no-op) action to perform when loading objects.
};
/// @brief Default (no-op) action to perform when loading objects.