• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ObjectImageCommon.h - Format independent executuable object image -===//
2 //
3 //		       The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares a file format independent ObjectImage class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
15 #define LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
16 
17 #include "llvm/ExecutionEngine/ObjectBuffer.h"
18 #include "llvm/ExecutionEngine/ObjectImage.h"
19 #include "llvm/Object/ObjectFile.h"
20 
21 namespace llvm {
22 
23 class ObjectImageCommon : public ObjectImage {
24   ObjectImageCommon(); // = delete
25   ObjectImageCommon(const ObjectImageCommon &other); // = delete
26 
27 protected:
28   object::ObjectFile *ObjFile;
29 
30   // This form of the constructor allows subclasses to use
31   // format-specific subclasses of ObjectFile directly
ObjectImageCommon(ObjectBuffer * Input,object::ObjectFile * Obj)32   ObjectImageCommon(ObjectBuffer *Input, object::ObjectFile *Obj)
33   : ObjectImage(Input), // saves Input as Buffer and takes ownership
34     ObjFile(Obj)
35   {
36   }
37 
38 public:
ObjectImageCommon(ObjectBuffer * Input)39   ObjectImageCommon(ObjectBuffer* Input)
40   : ObjectImage(Input) // saves Input as Buffer and takes ownership
41   {
42     ObjFile = object::ObjectFile::createObjectFile(Buffer->getMemBuffer());
43   }
~ObjectImageCommon()44   virtual ~ObjectImageCommon() { delete ObjFile; }
45 
begin_symbols()46   virtual object::symbol_iterator begin_symbols() const
47 	      { return ObjFile->begin_symbols(); }
end_symbols()48   virtual object::symbol_iterator end_symbols() const
49 	      { return ObjFile->end_symbols(); }
50 
begin_sections()51   virtual object::section_iterator begin_sections() const
52 	      { return ObjFile->begin_sections(); }
end_sections()53   virtual object::section_iterator end_sections() const
54 	      { return ObjFile->end_sections(); }
55 
getArch()56   virtual /* Triple::ArchType */ unsigned getArch() const
57 	      { return ObjFile->getArch(); }
58 
getData()59   virtual StringRef getData() const { return ObjFile->getData(); }
60 
getObjectFile()61   virtual object::ObjectFile* getObjectFile() const { return ObjFile; }
62 
63   // Subclasses can override these methods to update the image with loaded
64   // addresses for sections and common symbols
updateSectionAddress(const object::SectionRef & Sec,uint64_t Addr)65   virtual void updateSectionAddress(const object::SectionRef &Sec,
66 				    uint64_t Addr) {}
updateSymbolAddress(const object::SymbolRef & Sym,uint64_t Addr)67   virtual void updateSymbolAddress(const object::SymbolRef &Sym, uint64_t Addr)
68 	      {}
69 
70   // Subclasses can override these methods to provide JIT debugging support
registerWithDebugger()71   virtual void registerWithDebugger() {}
deregisterWithDebugger()72   virtual void deregisterWithDebugger() {}
73 };
74 
75 } // end namespace llvm
76 
77 #endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H
78 
79