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
47 ObjFile = object::ObjectFile::createObjectFile(Buffer->getMemBuffer());
49 ObjectImageCommon(object::ObjectFile* Input)
50 : ObjectImage(NULL), ObjFile(Input) {}
51 virtual ~ObjectImageCommon() { delete ObjFile; }
53 virtual object::symbol_iterator begin_symbols() const
54 { return ObjFile->begin_symbols(); }
55 virtual object::symbol_iterator end_symbols() const
56 { return ObjFile->end_symbols(); }
58 virtual object::section_iterator begin_sections() const
59 { return ObjFile->begin_sections(); }
60 virtual object::section_iterator end_sections() const
61 { return ObjFile->end_sections(); }
63 virtual /* Triple::ArchType */ unsigned getArch() const
64 { return ObjFile->getArch(); }
66 virtual StringRef getData() const { return ObjFile->getData(); }
68 virtual object::ObjectFile* getObjectFile() const { return ObjFile; }
70 // Subclasses can override these methods to update the image with loaded
71 // addresses for sections and common symbols
72 virtual void updateSectionAddress(const object::SectionRef &Sec,
74 virtual void updateSymbolAddress(const object::SymbolRef &Sym, uint64_t Addr)
77 // Subclasses can override these methods to provide JIT debugging support
78 virtual void registerWithDebugger() {}
79 virtual void deregisterWithDebugger() {}
82 } // end namespace llvm
84 #endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H