Clean-up of memory buffer and object ownership model in MCJIT
[oota-llvm.git] / include / llvm / ExecutionEngine / ObjectImage.h
1 //===---- ObjectImage.h - Format independent executuable object image -----===//\r
2 //\r
3 //                     The LLVM Compiler Infrastructure\r
4 //\r
5 // This file is distributed under the University of Illinois Open Source\r
6 // License. See LICENSE.TXT for details.\r
7 //\r
8 //===----------------------------------------------------------------------===//\r
9 //\r
10 // This file declares a file format independent ObjectImage class.\r
11 //\r
12 //===----------------------------------------------------------------------===//\r
13 \r
14 #ifndef LLVM_EXECUTIONENGINE_OBJECTIMAGE_H\r
15 #define LLVM_EXECUTIONENGINE_OBJECTIMAGE_H\r
16 \r
17 #include "llvm/Object/ObjectFile.h"\r
18 #include "llvm/ExecutionEngine/ObjectBuffer.h"\r
19 \r
20 namespace llvm {\r
21 \r
22 \r
23 /// ObjectImage - A container class that represents an ObjectFile that has been\r
24 /// or is in the process of being loaded into memory for execution.\r
25 class ObjectImage {\r
26   ObjectImage() LLVM_DELETED_FUNCTION;\r
27   ObjectImage(const ObjectImage &other) LLVM_DELETED_FUNCTION;\r
28 \r
29 protected:\r
30   OwningPtr<ObjectBuffer> Buffer;\r
31 \r
32 public:\r
33   ObjectImage(ObjectBuffer *Input) : Buffer(Input) {}\r
34   virtual ~ObjectImage() {}\r
35 \r
36   virtual object::symbol_iterator begin_symbols() const = 0;\r
37   virtual object::symbol_iterator end_symbols() const = 0;\r
38 \r
39   virtual object::section_iterator begin_sections() const = 0;\r
40   virtual object::section_iterator end_sections() const  = 0;\r
41 \r
42   virtual /* Triple::ArchType */ unsigned getArch() const = 0;\r
43 \r
44   // Subclasses can override these methods to update the image with loaded\r
45   // addresses for sections and common symbols\r
46   virtual void updateSectionAddress(const object::SectionRef &Sec,\r
47                                     uint64_t Addr) = 0;\r
48   virtual void updateSymbolAddress(const object::SymbolRef &Sym,\r
49                                    uint64_t Addr) = 0;\r
50 \r
51   virtual StringRef getData() const = 0;\r
52 \r
53   // Subclasses can override these methods to provide JIT debugging support\r
54   virtual void registerWithDebugger() = 0;\r
55   virtual void deregisterWithDebugger() = 0;\r
56 };\r
57 \r
58 } // end namespace llvm\r
59 \r
60 #endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H\r
61 \r