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"
23 class ObjectImageCommon : public ObjectImage {
24 ObjectImageCommon(); // = delete
25 ObjectImageCommon(const ObjectImageCommon &other); // = delete
26 virtual void anchor();
29 object::ObjectFile *ObjFile;
31 // This form of the constructor allows subclasses to use
32 // format-specific subclasses of ObjectFile directly
33 ObjectImageCommon(ObjectBuffer *Input, object::ObjectFile *Obj)
34 : ObjectImage(Input), // saves Input as Buffer and takes ownership
40 ObjectImageCommon(ObjectBuffer* Input)
41 : ObjectImage(Input) // saves Input as Buffer and takes ownership
43 ObjFile = object::ObjectFile::createObjectFile(Buffer->getMemBuffer());
45 virtual ~ObjectImageCommon() { delete ObjFile; }
47 virtual object::symbol_iterator begin_symbols() const
48 { return ObjFile->begin_symbols(); }
49 virtual object::symbol_iterator end_symbols() const
50 { return ObjFile->end_symbols(); }
52 virtual object::section_iterator begin_sections() const
53 { return ObjFile->begin_sections(); }
54 virtual object::section_iterator end_sections() const
55 { return ObjFile->end_sections(); }
57 virtual /* Triple::ArchType */ unsigned getArch() const
58 { return ObjFile->getArch(); }
60 virtual StringRef getData() const { return ObjFile->getData(); }
62 virtual object::ObjectFile* getObjectFile() const { return ObjFile; }
64 // Subclasses can override these methods to update the image with loaded
65 // addresses for sections and common symbols
66 virtual void updateSectionAddress(const object::SectionRef &Sec,
68 virtual void updateSymbolAddress(const object::SymbolRef &Sym, uint64_t Addr)
71 // Subclasses can override these methods to provide JIT debugging support
72 virtual void registerWithDebugger() {}
73 virtual void deregisterWithDebugger() {}
76 } // end namespace llvm
78 #endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H