1 //===-- ObjectImageCommon.h - Format independent executuable object image -===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares a file format independent ObjectImage class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
15 #define LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
17 #include "llvm/ExecutionEngine/ObjectBuffer.h"
18 #include "llvm/ExecutionEngine/ObjectImage.h"
19 #include "llvm/Object/ObjectFile.h"
27 class ObjectImageCommon : public ObjectImage {
28 ObjectImageCommon(); // = delete
29 ObjectImageCommon(const ObjectImageCommon &other); // = delete
30 virtual void anchor();
33 object::ObjectFile *ObjFile;
35 // This form of the constructor allows subclasses to use
36 // format-specific subclasses of ObjectFile directly
37 ObjectImageCommon(ObjectBuffer *Input, object::ObjectFile *Obj)
38 : ObjectImage(Input), // saves Input as Buffer and takes ownership
44 ObjectImageCommon(ObjectBuffer* Input)
45 : ObjectImage(Input) // saves Input as Buffer and takes ownership
48 object::ObjectFile::createObjectFile(Buffer->getMemBuffer()).get();
50 ObjectImageCommon(object::ObjectFile* Input)
51 : ObjectImage(NULL), ObjFile(Input) {}
52 virtual ~ObjectImageCommon() { delete ObjFile; }
54 virtual object::symbol_iterator begin_symbols() const
55 { return ObjFile->begin_symbols(); }
56 virtual object::symbol_iterator end_symbols() const
57 { return ObjFile->end_symbols(); }
59 virtual object::section_iterator begin_sections() const
60 { return ObjFile->begin_sections(); }
61 virtual object::section_iterator end_sections() const
62 { return ObjFile->end_sections(); }
64 virtual /* Triple::ArchType */ unsigned getArch() const
65 { return ObjFile->getArch(); }
67 virtual StringRef getData() const { return ObjFile->getData(); }
69 virtual object::ObjectFile* getObjectFile() const { return ObjFile; }
71 // Subclasses can override these methods to update the image with loaded
72 // addresses for sections and common symbols
73 virtual void updateSectionAddress(const object::SectionRef &Sec,
75 virtual void updateSymbolAddress(const object::SymbolRef &Sym, uint64_t Addr)
78 // Subclasses can override these methods to provide JIT debugging support
79 virtual void registerWithDebugger() {}
80 virtual void deregisterWithDebugger() {}
83 } // end namespace llvm
85 #endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H