diff options
| author | Lang Hames <lhames@gmail.com> | 2014-11-26 06:53:26 +0000 |
|---|---|---|
| committer | Lang Hames <lhames@gmail.com> | 2014-11-26 06:53:26 +0000 |
| commit | 829a19ae74c572bdb5e46b4e4b85a35503255c94 (patch) | |
| tree | b1eac9db4b702227031bb68af4ee1b9b34b256ce /llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h | |
| parent | bf82611bc8fa3d384a2a73cbfc898cf67db5edd7 (diff) | |
| download | bcm5719-llvm-829a19ae74c572bdb5e46b4e4b85a35503255c94.tar.gz bcm5719-llvm-829a19ae74c572bdb5e46b4e4b85a35503255c94.zip | |
[MCJIT] Clean up RuntimeDyld's quirky object-ownership/modification scheme.
Previously, when loading an object file, RuntimeDyld (1) took ownership of the
ObjectFile instance (and associated MemoryBuffer), (2) potentially modified the
object in-place, and (3) returned an ObjectImage that managed ownership of the
now-modified object and provided some convenience methods. This scheme accreted
over several years as features were tacked on to RuntimeDyld, and was both
unintuitive and unsafe (See e.g. http://llvm.org/PR20722).
This patch fixes the issue by removing all ownership and in-place modification
of object files from RuntimeDyld. Existing behavior, including debugger
registration, is preserved.
Noteworthy changes include:
(1) ObjectFile instances are now passed to RuntimeDyld by const-ref.
(2) The ObjectImage and ObjectBuffer classes have been removed entirely, they
existed to model ownership within RuntimeDyld, and so are no longer needed.
(3) RuntimeDyld::loadObject now returns an instance of a new class,
RuntimeDyld::LoadedObjectInfo, which can be used to construct a modified
object suitable for registration with the debugger, following the existing
debugger registration scheme.
(4) The JITRegistrar class has been removed, and the GDBRegistrar class has been
re-written as a JITEventListener.
This should fix http://llvm.org/PR20722 .
llvm-svn: 222810
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h')
| -rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h b/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h deleted file mode 100644 index 9bbf6a0d809..00000000000 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h +++ /dev/null @@ -1,86 +0,0 @@ -//===-- ObjectImageCommon.h - Format independent executuable object image -===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares a file format independent ObjectImage class. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_OBJECTIMAGECOMMON_H -#define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_OBJECTIMAGECOMMON_H - -#include "llvm/ExecutionEngine/ObjectBuffer.h" -#include "llvm/ExecutionEngine/ObjectImage.h" -#include "llvm/Object/ObjectFile.h" - -#include <memory> - -namespace llvm { - -namespace object { - class ObjectFile; -} - -class ObjectImageCommon : public ObjectImage { - ObjectImageCommon(); // = delete - ObjectImageCommon(const ObjectImageCommon &other); // = delete - void anchor() override; - -protected: - std::unique_ptr<object::ObjectFile> ObjFile; - - // This form of the constructor allows subclasses to use - // format-specific subclasses of ObjectFile directly - ObjectImageCommon(std::unique_ptr<ObjectBuffer> Input, - std::unique_ptr<object::ObjectFile> Obj) - : ObjectImage(std::move(Input)), ObjFile(std::move(Obj)) {} - -public: - ObjectImageCommon(std::unique_ptr<ObjectBuffer> Input) - : ObjectImage(std::move(Input)) { - // FIXME: error checking? createObjectFile returns an ErrorOr<ObjectFile*> - // and should probably be checked for failure. - MemoryBufferRef Buf = Buffer->getMemBuffer(); - ObjFile = std::move(object::ObjectFile::createObjectFile(Buf).get()); - } - ObjectImageCommon(std::unique_ptr<object::ObjectFile> Input) - : ObjectImage(nullptr), ObjFile(std::move(Input)) {} - virtual ~ObjectImageCommon() { } - - object::symbol_iterator begin_symbols() const override - { return ObjFile->symbol_begin(); } - object::symbol_iterator end_symbols() const override - { return ObjFile->symbol_end(); } - - object::section_iterator begin_sections() const override - { return ObjFile->section_begin(); } - object::section_iterator end_sections() const override - { return ObjFile->section_end(); } - - /* Triple::ArchType */ unsigned getArch() const override - { return ObjFile->getArch(); } - - StringRef getData() const override { return ObjFile->getData(); } - - object::ObjectFile* getObjectFile() const override { return ObjFile.get(); } - - // Subclasses can override these methods to update the image with loaded - // addresses for sections and common symbols - void updateSectionAddress(const object::SectionRef &Sec, - uint64_t Addr) override {} - void updateSymbolAddress(const object::SymbolRef &Sym, - uint64_t Addr) override {} - - // Subclasses can override these methods to provide JIT debugging support - void registerWithDebugger() override {} - void deregisterWithDebugger() override {} -}; - -} // end namespace llvm - -#endif |

