Jim Grosbach | e0934be | 2012-01-16 23:50:58 +0000 | [diff] [blame] | 1 | //===-- RuntimeDyld.cpp - Run-time dynamic linker for MC-JIT ----*- C++ -*-===// |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 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 | // Implementation of the MC-JIT runtime dynamic linker. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Jim Grosbach | 8b54dca | 2011-03-23 19:52:00 +0000 | [diff] [blame] | 14 | #define DEBUG_TYPE "dyld" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 15 | #include "llvm/ExecutionEngine/RuntimeDyld.h" |
Andrew Kaylor | 3f23cef | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 16 | #include "ObjectImageCommon.h" |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 17 | #include "RuntimeDyldELF.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 18 | #include "RuntimeDyldImpl.h" |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 19 | #include "RuntimeDyldMachO.h" |
Rafael Espindola | 3ecfcc2 | 2013-06-11 18:01:14 +0000 | [diff] [blame] | 20 | #include "llvm/Support/FileSystem.h" |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame] | 21 | #include "llvm/Support/MathExtras.h" |
Rafael Espindola | 7486d92 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 22 | #include "llvm/Object/ELF.h" |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 23 | |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 24 | using namespace llvm; |
| 25 | using namespace llvm::object; |
| 26 | |
Chandler Carruth | 53c5e7b | 2011-04-05 23:54:31 +0000 | [diff] [blame] | 27 | // Empty out-of-line virtual destructor as the key function. |
Danil Malyshev | cf852dc | 2011-07-13 07:57:58 +0000 | [diff] [blame] | 28 | RuntimeDyldImpl::~RuntimeDyldImpl() {} |
Chandler Carruth | 53c5e7b | 2011-04-05 23:54:31 +0000 | [diff] [blame] | 29 | |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 30 | namespace llvm { |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 31 | |
Rafael Espindola | a2e40fb | 2013-05-05 20:43:10 +0000 | [diff] [blame] | 32 | StringRef RuntimeDyldImpl::getEHFrameSection() { |
| 33 | return StringRef(); |
| 34 | } |
| 35 | |
Jim Grosbach | f8c1c84 | 2011-04-12 21:20:41 +0000 | [diff] [blame] | 36 | // Resolve the relocations for all symbols we currently know about. |
| 37 | void RuntimeDyldImpl::resolveRelocations() { |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 38 | // First, resolve relocations associated with external symbols. |
Eli Bendersky | 37bc5a2 | 2012-04-30 12:15:58 +0000 | [diff] [blame] | 39 | resolveExternalSymbols(); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 40 | |
Jim Grosbach | 61425c0 | 2012-01-16 22:26:39 +0000 | [diff] [blame] | 41 | // Just iterate over the sections we have and resolve all the relocations |
| 42 | // in them. Gross overkill, but it gets the job done. |
| 43 | for (int i = 0, e = Sections.size(); i != e; ++i) { |
Andrew Kaylor | 2898988 | 2012-11-05 20:57:16 +0000 | [diff] [blame] | 44 | uint64_t Addr = Sections[i].LoadAddress; |
| 45 | DEBUG(dbgs() << "Resolving relocations Section #" << i |
| 46 | << "\t" << format("%p", (uint8_t *)Addr) |
| 47 | << "\n"); |
| 48 | resolveRelocationList(Relocations[i], Addr); |
Jim Grosbach | 61425c0 | 2012-01-16 22:26:39 +0000 | [diff] [blame] | 49 | } |
Jim Grosbach | f8c1c84 | 2011-04-12 21:20:41 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Jim Grosbach | e940c1b | 2012-09-13 21:50:06 +0000 | [diff] [blame] | 52 | void RuntimeDyldImpl::mapSectionAddress(const void *LocalAddress, |
Jim Grosbach | 020f4e8 | 2012-01-16 23:50:55 +0000 | [diff] [blame] | 53 | uint64_t TargetAddress) { |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 54 | for (unsigned i = 0, e = Sections.size(); i != e; ++i) { |
| 55 | if (Sections[i].Address == LocalAddress) { |
| 56 | reassignSectionAddress(i, TargetAddress); |
| 57 | return; |
| 58 | } |
| 59 | } |
| 60 | llvm_unreachable("Attempting to remap address of unknown section!"); |
Jim Grosbach | 020f4e8 | 2012-01-16 23:50:55 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Eli Bendersky | 5fe0198 | 2012-04-29 12:40:47 +0000 | [diff] [blame] | 63 | // Subclasses can implement this method to create specialized image instances. |
Sylvestre Ledru | c8e41c5 | 2012-07-23 08:51:15 +0000 | [diff] [blame] | 64 | // The caller owns the pointer that is returned. |
Andrew Kaylor | 3f23cef | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 65 | ObjectImage *RuntimeDyldImpl::createObjectImage(ObjectBuffer *InputBuffer) { |
| 66 | return new ObjectImageCommon(InputBuffer); |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Andrew Kaylor | 3f23cef | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 69 | ObjectImage *RuntimeDyldImpl::loadObject(ObjectBuffer *InputBuffer) { |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 70 | OwningPtr<ObjectImage> obj(createObjectImage(InputBuffer)); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 71 | if (!obj) |
| 72 | report_fatal_error("Unable to create object image from memory buffer!"); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 73 | |
| 74 | Arch = (Triple::ArchType)obj->getArch(); |
| 75 | |
Eli Bendersky | d98c9e9 | 2012-05-01 06:58:59 +0000 | [diff] [blame] | 76 | // Symbols found in this object |
| 77 | StringMap<SymbolLoc> LocalSymbols; |
| 78 | // Used sections from the object file |
| 79 | ObjSectionToIDMap LocalSections; |
| 80 | |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame] | 81 | // Common symbols requiring allocation, with their sizes and alignments |
Eli Bendersky | d98c9e9 | 2012-05-01 06:58:59 +0000 | [diff] [blame] | 82 | CommonSymbolMap CommonSymbols; |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame] | 83 | // Maximum required total memory to allocate all common symbols |
Eli Bendersky | d98c9e9 | 2012-05-01 06:58:59 +0000 | [diff] [blame] | 84 | uint64_t CommonSize = 0; |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 85 | |
| 86 | error_code err; |
| 87 | // Parse symbols |
| 88 | DEBUG(dbgs() << "Parse symbols:\n"); |
| 89 | for (symbol_iterator i = obj->begin_symbols(), e = obj->end_symbols(); |
| 90 | i != e; i.increment(err)) { |
| 91 | Check(err); |
| 92 | object::SymbolRef::Type SymType; |
| 93 | StringRef Name; |
| 94 | Check(i->getType(SymType)); |
| 95 | Check(i->getName(Name)); |
| 96 | |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 97 | uint32_t flags; |
| 98 | Check(i->getFlags(flags)); |
| 99 | |
| 100 | bool isCommon = flags & SymbolRef::SF_Common; |
| 101 | if (isCommon) { |
| 102 | // Add the common symbols to a list. We'll allocate them all below. |
Rafael Espindola | 59a0e79 | 2013-04-29 22:24:22 +0000 | [diff] [blame] | 103 | uint32_t Align; |
| 104 | Check(i->getAlignment(Align)); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 105 | uint64_t Size = 0; |
| 106 | Check(i->getSize(Size)); |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame] | 107 | CommonSize += Size + Align; |
| 108 | CommonSymbols[*i] = CommonSymbolInfo(Size, Align); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 109 | } else { |
| 110 | if (SymType == object::SymbolRef::ST_Function || |
Akira Hatanaka | b889e0c | 2012-08-17 21:28:04 +0000 | [diff] [blame] | 111 | SymType == object::SymbolRef::ST_Data || |
| 112 | SymType == object::SymbolRef::ST_Unknown) { |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 113 | uint64_t FileOffset; |
Eli Bendersky | 5fe0198 | 2012-04-29 12:40:47 +0000 | [diff] [blame] | 114 | StringRef SectionData; |
Tim Northover | 7882213 | 2012-12-17 17:59:35 +0000 | [diff] [blame] | 115 | bool IsCode; |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 116 | section_iterator si = obj->end_sections(); |
| 117 | Check(i->getFileOffset(FileOffset)); |
| 118 | Check(i->getSection(si)); |
| 119 | if (si == obj->end_sections()) continue; |
Eli Bendersky | 5fe0198 | 2012-04-29 12:40:47 +0000 | [diff] [blame] | 120 | Check(si->getContents(SectionData)); |
Tim Northover | 7882213 | 2012-12-17 17:59:35 +0000 | [diff] [blame] | 121 | Check(si->isText(IsCode)); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 122 | const uint8_t* SymPtr = (const uint8_t*)InputBuffer->getBufferStart() + |
| 123 | (uintptr_t)FileOffset; |
Eli Bendersky | 5fe0198 | 2012-04-29 12:40:47 +0000 | [diff] [blame] | 124 | uintptr_t SectOffset = (uintptr_t)(SymPtr - |
| 125 | (const uint8_t*)SectionData.begin()); |
Tim Northover | 7882213 | 2012-12-17 17:59:35 +0000 | [diff] [blame] | 126 | unsigned SectionID = findOrEmitSection(*obj, *si, IsCode, LocalSections); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 127 | LocalSymbols[Name.data()] = SymbolLoc(SectionID, SectOffset); |
| 128 | DEBUG(dbgs() << "\tFileOffset: " << format("%p", (uintptr_t)FileOffset) |
| 129 | << " flags: " << flags |
| 130 | << " SID: " << SectionID |
| 131 | << " Offset: " << format("%p", SectOffset)); |
Amara Emerson | 098d6d5 | 2012-11-16 11:11:59 +0000 | [diff] [blame] | 132 | GlobalSymbolTable[Name] = SymbolLoc(SectionID, SectOffset); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 133 | } |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 134 | } |
| 135 | DEBUG(dbgs() << "\tType: " << SymType << " Name: " << Name << "\n"); |
| 136 | } |
| 137 | |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 138 | // Allocate common symbols |
| 139 | if (CommonSize != 0) |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 140 | emitCommonSymbols(*obj, CommonSymbols, CommonSize, LocalSymbols); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 141 | |
Eli Bendersky | 5fe0198 | 2012-04-29 12:40:47 +0000 | [diff] [blame] | 142 | // Parse and process relocations |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 143 | DEBUG(dbgs() << "Parse relocations:\n"); |
| 144 | for (section_iterator si = obj->begin_sections(), |
| 145 | se = obj->end_sections(); si != se; si.increment(err)) { |
| 146 | Check(err); |
| 147 | bool isFirstRelocation = true; |
| 148 | unsigned SectionID = 0; |
| 149 | StubMap Stubs; |
Rafael Espindola | 7486d92 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 150 | section_iterator RelocatedSection = si->getRelocatedSection(); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 151 | |
| 152 | for (relocation_iterator i = si->begin_relocations(), |
| 153 | e = si->end_relocations(); i != e; i.increment(err)) { |
| 154 | Check(err); |
| 155 | |
Eli Bendersky | 5fe0198 | 2012-04-29 12:40:47 +0000 | [diff] [blame] | 156 | // If it's the first relocation in this section, find its SectionID |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 157 | if (isFirstRelocation) { |
Rafael Espindola | 7486d92 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 158 | SectionID = |
| 159 | findOrEmitSection(*obj, *RelocatedSection, true, LocalSections); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 160 | DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n"); |
| 161 | isFirstRelocation = false; |
| 162 | } |
| 163 | |
Rafael Espindola | ca0e736 | 2013-04-29 19:03:21 +0000 | [diff] [blame] | 164 | processRelocationRef(SectionID, *i, *obj, LocalSections, LocalSymbols, |
Rafael Espindola | efa91f6 | 2013-04-29 14:44:23 +0000 | [diff] [blame] | 165 | Stubs); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 166 | } |
| 167 | } |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 168 | |
Andrew Kaylor | 3f23cef | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 169 | return obj.take(); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Eli Bendersky | c201e6e | 2012-05-01 10:41:12 +0000 | [diff] [blame] | 172 | void RuntimeDyldImpl::emitCommonSymbols(ObjectImage &Obj, |
| 173 | const CommonSymbolMap &CommonSymbols, |
| 174 | uint64_t TotalSize, |
| 175 | SymbolTableMap &SymbolTable) { |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 176 | // Allocate memory for the section |
| 177 | unsigned SectionID = Sections.size(); |
| 178 | uint8_t *Addr = MemMgr->allocateDataSection(TotalSize, sizeof(void*), |
Andrew Kaylor | 53608a3 | 2012-11-15 23:50:01 +0000 | [diff] [blame] | 179 | SectionID, false); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 180 | if (!Addr) |
| 181 | report_fatal_error("Unable to allocate memory for common symbols!"); |
| 182 | uint64_t Offset = 0; |
Rafael Espindola | a2e40fb | 2013-05-05 20:43:10 +0000 | [diff] [blame] | 183 | Sections.push_back(SectionEntry(StringRef(), Addr, TotalSize, 0)); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 184 | memset(Addr, 0, TotalSize); |
| 185 | |
| 186 | DEBUG(dbgs() << "emitCommonSection SectionID: " << SectionID |
| 187 | << " new addr: " << format("%p", Addr) |
| 188 | << " DataSize: " << TotalSize |
| 189 | << "\n"); |
| 190 | |
| 191 | // Assign the address of each symbol |
Eli Bendersky | c201e6e | 2012-05-01 10:41:12 +0000 | [diff] [blame] | 192 | for (CommonSymbolMap::const_iterator it = CommonSymbols.begin(), |
| 193 | itEnd = CommonSymbols.end(); it != itEnd; it++) { |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame] | 194 | uint64_t Size = it->second.first; |
| 195 | uint64_t Align = it->second.second; |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 196 | StringRef Name; |
| 197 | it->first.getName(Name); |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame] | 198 | if (Align) { |
| 199 | // This symbol has an alignment requirement. |
| 200 | uint64_t AlignOffset = OffsetToAlignment((uint64_t)Addr, Align); |
| 201 | Addr += AlignOffset; |
| 202 | Offset += AlignOffset; |
| 203 | DEBUG(dbgs() << "Allocating common symbol " << Name << " address " << |
Andrew Kaylor | 5fc8c7c | 2012-11-01 19:49:21 +0000 | [diff] [blame] | 204 | format("%p\n", Addr)); |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame] | 205 | } |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 206 | Obj.updateSymbolAddress(it->first, (uint64_t)Addr); |
Eli Bendersky | c201e6e | 2012-05-01 10:41:12 +0000 | [diff] [blame] | 207 | SymbolTable[Name.data()] = SymbolLoc(SectionID, Offset); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 208 | Offset += Size; |
| 209 | Addr += Size; |
| 210 | } |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 213 | unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj, |
| 214 | const SectionRef &Section, |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 215 | bool IsCode) { |
| 216 | |
| 217 | unsigned StubBufSize = 0, |
| 218 | StubSize = getMaxStubSize(); |
| 219 | error_code err; |
Rafael Espindola | 7486d92 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 220 | const ObjectFile *ObjFile = Obj.getObjectFile(); |
| 221 | // FIXME: this is an inefficient way to handle this. We should computed the |
| 222 | // necessary section allocation size in loadObject by walking all the sections |
| 223 | // once. |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 224 | if (StubSize > 0) { |
Rafael Espindola | 7486d92 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 225 | for (section_iterator SI = ObjFile->begin_sections(), |
| 226 | SE = ObjFile->end_sections(); |
| 227 | SI != SE; SI.increment(err), Check(err)) { |
| 228 | section_iterator RelSecI = SI->getRelocatedSection(); |
| 229 | if (!(RelSecI == Section)) |
| 230 | continue; |
| 231 | |
| 232 | for (relocation_iterator I = SI->begin_relocations(), |
| 233 | E = SI->end_relocations(); I != E; I.increment(err), Check(err)) { |
| 234 | StubBufSize += StubSize; |
| 235 | } |
| 236 | } |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 237 | } |
Rafael Espindola | 7486d92 | 2013-05-30 03:05:14 +0000 | [diff] [blame] | 238 | |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 239 | StringRef data; |
| 240 | uint64_t Alignment64; |
| 241 | Check(Section.getContents(data)); |
| 242 | Check(Section.getAlignment(Alignment64)); |
| 243 | |
| 244 | unsigned Alignment = (unsigned)Alignment64 & 0xffffffffL; |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 245 | bool IsRequired; |
| 246 | bool IsVirtual; |
| 247 | bool IsZeroInit; |
Andrew Kaylor | 53608a3 | 2012-11-15 23:50:01 +0000 | [diff] [blame] | 248 | bool IsReadOnly; |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 249 | uint64_t DataSize; |
Adhemerval Zanella | 6e8946c | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 250 | StringRef Name; |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 251 | Check(Section.isRequiredForExecution(IsRequired)); |
| 252 | Check(Section.isVirtual(IsVirtual)); |
| 253 | Check(Section.isZeroInit(IsZeroInit)); |
Andrew Kaylor | 53608a3 | 2012-11-15 23:50:01 +0000 | [diff] [blame] | 254 | Check(Section.isReadOnlyData(IsReadOnly)); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 255 | Check(Section.getSize(DataSize)); |
Adhemerval Zanella | 6e8946c | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 256 | Check(Section.getName(Name)); |
Richard Sandiford | 6fc2ad6 | 2013-05-03 14:15:35 +0000 | [diff] [blame] | 257 | if (StubSize > 0) { |
| 258 | unsigned StubAlignment = getStubAlignment(); |
| 259 | unsigned EndAlignment = (DataSize | Alignment) & -(DataSize | Alignment); |
| 260 | if (StubAlignment > EndAlignment) |
| 261 | StubBufSize += StubAlignment - EndAlignment; |
| 262 | } |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 263 | |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 264 | unsigned Allocate; |
| 265 | unsigned SectionID = Sections.size(); |
| 266 | uint8_t *Addr; |
| 267 | const char *pData = 0; |
| 268 | |
| 269 | // Some sections, such as debug info, don't need to be loaded for execution. |
| 270 | // Leave those where they are. |
| 271 | if (IsRequired) { |
| 272 | Allocate = DataSize + StubBufSize; |
| 273 | Addr = IsCode |
| 274 | ? MemMgr->allocateCodeSection(Allocate, Alignment, SectionID) |
Andrew Kaylor | 53608a3 | 2012-11-15 23:50:01 +0000 | [diff] [blame] | 275 | : MemMgr->allocateDataSection(Allocate, Alignment, SectionID, IsReadOnly); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 276 | if (!Addr) |
| 277 | report_fatal_error("Unable to allocate section memory!"); |
| 278 | |
| 279 | // Virtual sections have no data in the object image, so leave pData = 0 |
| 280 | if (!IsVirtual) |
| 281 | pData = data.data(); |
| 282 | |
| 283 | // Zero-initialize or copy the data from the image |
| 284 | if (IsZeroInit || IsVirtual) |
| 285 | memset(Addr, 0, DataSize); |
| 286 | else |
| 287 | memcpy(Addr, pData, DataSize); |
| 288 | |
| 289 | DEBUG(dbgs() << "emitSection SectionID: " << SectionID |
Adhemerval Zanella | 6e8946c | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 290 | << " Name: " << Name |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 291 | << " obj addr: " << format("%p", pData) |
| 292 | << " new addr: " << format("%p", Addr) |
| 293 | << " DataSize: " << DataSize |
| 294 | << " StubBufSize: " << StubBufSize |
| 295 | << " Allocate: " << Allocate |
| 296 | << "\n"); |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 297 | Obj.updateSectionAddress(Section, (uint64_t)Addr); |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 298 | } |
| 299 | else { |
| 300 | // Even if we didn't load the section, we need to record an entry for it |
Eli Bendersky | 5fe0198 | 2012-04-29 12:40:47 +0000 | [diff] [blame] | 301 | // to handle later processing (and by 'handle' I mean don't do anything |
| 302 | // with these sections). |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 303 | Allocate = 0; |
| 304 | Addr = 0; |
| 305 | DEBUG(dbgs() << "emitSection SectionID: " << SectionID |
Adhemerval Zanella | 6e8946c | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 306 | << " Name: " << Name |
Preston Gurd | c68dda8 | 2012-04-12 20:13:57 +0000 | [diff] [blame] | 307 | << " obj addr: " << format("%p", data.data()) |
| 308 | << " new addr: 0" |
| 309 | << " DataSize: " << DataSize |
| 310 | << " StubBufSize: " << StubBufSize |
| 311 | << " Allocate: " << Allocate |
| 312 | << "\n"); |
| 313 | } |
| 314 | |
Rafael Espindola | a2e40fb | 2013-05-05 20:43:10 +0000 | [diff] [blame] | 315 | Sections.push_back(SectionEntry(Name, Addr, DataSize, (uintptr_t)pData)); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 316 | return SectionID; |
| 317 | } |
| 318 | |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 319 | unsigned RuntimeDyldImpl::findOrEmitSection(ObjectImage &Obj, |
| 320 | const SectionRef &Section, |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 321 | bool IsCode, |
| 322 | ObjSectionToIDMap &LocalSections) { |
| 323 | |
| 324 | unsigned SectionID = 0; |
| 325 | ObjSectionToIDMap::iterator i = LocalSections.find(Section); |
| 326 | if (i != LocalSections.end()) |
| 327 | SectionID = i->second; |
| 328 | else { |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 329 | SectionID = emitSection(Obj, Section, IsCode); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 330 | LocalSections[Section] = SectionID; |
| 331 | } |
| 332 | return SectionID; |
| 333 | } |
| 334 | |
Eli Bendersky | c201e6e | 2012-05-01 10:41:12 +0000 | [diff] [blame] | 335 | void RuntimeDyldImpl::addRelocationForSection(const RelocationEntry &RE, |
| 336 | unsigned SectionID) { |
| 337 | Relocations[SectionID].push_back(RE); |
| 338 | } |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 339 | |
Eli Bendersky | c201e6e | 2012-05-01 10:41:12 +0000 | [diff] [blame] | 340 | void RuntimeDyldImpl::addRelocationForSymbol(const RelocationEntry &RE, |
| 341 | StringRef SymbolName) { |
| 342 | // Relocation by symbol. If the symbol is found in the global symbol table, |
| 343 | // create an appropriate section relocation. Otherwise, add it to |
| 344 | // ExternalSymbolRelocations. |
| 345 | SymbolTableMap::const_iterator Loc = |
| 346 | GlobalSymbolTable.find(SymbolName); |
| 347 | if (Loc == GlobalSymbolTable.end()) { |
| 348 | ExternalSymbolRelocations[SymbolName].push_back(RE); |
Eli Bendersky | 37bc5a2 | 2012-04-30 12:15:58 +0000 | [diff] [blame] | 349 | } else { |
Eli Bendersky | c201e6e | 2012-05-01 10:41:12 +0000 | [diff] [blame] | 350 | // Copy the RE since we want to modify its addend. |
| 351 | RelocationEntry RECopy = RE; |
| 352 | RECopy.Addend += Loc->second.second; |
| 353 | Relocations[Loc->second.first].push_back(RECopy); |
Eli Bendersky | 37bc5a2 | 2012-04-30 12:15:58 +0000 | [diff] [blame] | 354 | } |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | uint8_t *RuntimeDyldImpl::createStubFunction(uint8_t *Addr) { |
Tim Northover | 4a9b6b7 | 2013-05-04 20:14:09 +0000 | [diff] [blame] | 358 | if (Arch == Triple::aarch64) { |
| 359 | // This stub has to be able to access the full address space, |
| 360 | // since symbol lookup won't necessarily find a handy, in-range, |
| 361 | // PLT stub for functions which could be anywhere. |
| 362 | uint32_t *StubAddr = (uint32_t*)Addr; |
| 363 | |
| 364 | // Stub can use ip0 (== x16) to calculate address |
| 365 | *StubAddr = 0xd2e00010; // movz ip0, #:abs_g3:<addr> |
| 366 | StubAddr++; |
| 367 | *StubAddr = 0xf2c00010; // movk ip0, #:abs_g2_nc:<addr> |
| 368 | StubAddr++; |
| 369 | *StubAddr = 0xf2a00010; // movk ip0, #:abs_g1_nc:<addr> |
| 370 | StubAddr++; |
| 371 | *StubAddr = 0xf2800010; // movk ip0, #:abs_g0_nc:<addr> |
| 372 | StubAddr++; |
| 373 | *StubAddr = 0xd61f0200; // br ip0 |
| 374 | |
| 375 | return Addr; |
| 376 | } else if (Arch == Triple::arm) { |
Akira Hatanaka | b889e0c | 2012-08-17 21:28:04 +0000 | [diff] [blame] | 377 | // TODO: There is only ARM far stub now. We should add the Thumb stub, |
| 378 | // and stubs for branches Thumb - ARM and ARM - Thumb. |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 379 | uint32_t *StubAddr = (uint32_t*)Addr; |
| 380 | *StubAddr = 0xe51ff004; // ldr pc,<label> |
| 381 | return (uint8_t*)++StubAddr; |
NAKAMURA Takumi | 4af1ca5 | 2012-12-04 00:08:14 +0000 | [diff] [blame] | 382 | } else if (Arch == Triple::mipsel || Arch == Triple::mips) { |
Akira Hatanaka | b889e0c | 2012-08-17 21:28:04 +0000 | [diff] [blame] | 383 | uint32_t *StubAddr = (uint32_t*)Addr; |
| 384 | // 0: 3c190000 lui t9,%hi(addr). |
| 385 | // 4: 27390000 addiu t9,t9,%lo(addr). |
| 386 | // 8: 03200008 jr t9. |
| 387 | // c: 00000000 nop. |
| 388 | const unsigned LuiT9Instr = 0x3c190000, AdduiT9Instr = 0x27390000; |
| 389 | const unsigned JrT9Instr = 0x03200008, NopInstr = 0x0; |
| 390 | |
| 391 | *StubAddr = LuiT9Instr; |
| 392 | StubAddr++; |
| 393 | *StubAddr = AdduiT9Instr; |
| 394 | StubAddr++; |
| 395 | *StubAddr = JrT9Instr; |
| 396 | StubAddr++; |
| 397 | *StubAddr = NopInstr; |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 398 | return Addr; |
Bill Schmidt | f38cc38 | 2013-07-26 01:35:43 +0000 | [diff] [blame^] | 399 | } else if (Arch == Triple::ppc64 || Arch == Triple::ppc64le) { |
Adhemerval Zanella | 6e8946c | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 400 | // PowerPC64 stub: the address points to a function descriptor |
| 401 | // instead of the function itself. Load the function address |
| 402 | // on r11 and sets it to control register. Also loads the function |
| 403 | // TOC in r2 and environment pointer to r11. |
| 404 | writeInt32BE(Addr, 0x3D800000); // lis r12, highest(addr) |
| 405 | writeInt32BE(Addr+4, 0x618C0000); // ori r12, higher(addr) |
| 406 | writeInt32BE(Addr+8, 0x798C07C6); // sldi r12, r12, 32 |
| 407 | writeInt32BE(Addr+12, 0x658C0000); // oris r12, r12, h(addr) |
| 408 | writeInt32BE(Addr+16, 0x618C0000); // ori r12, r12, l(addr) |
| 409 | writeInt32BE(Addr+20, 0xF8410028); // std r2, 40(r1) |
| 410 | writeInt32BE(Addr+24, 0xE96C0000); // ld r11, 0(r12) |
| 411 | writeInt32BE(Addr+28, 0xE84C0008); // ld r2, 0(r12) |
| 412 | writeInt32BE(Addr+32, 0x7D6903A6); // mtctr r11 |
| 413 | writeInt32BE(Addr+36, 0xE96C0010); // ld r11, 16(r2) |
| 414 | writeInt32BE(Addr+40, 0x4E800420); // bctr |
Andrew Kaylor | 5fc8c7c | 2012-11-01 19:49:21 +0000 | [diff] [blame] | 415 | |
Adhemerval Zanella | 6e8946c | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 416 | return Addr; |
Richard Sandiford | 6fc2ad6 | 2013-05-03 14:15:35 +0000 | [diff] [blame] | 417 | } else if (Arch == Triple::systemz) { |
| 418 | writeInt16BE(Addr, 0xC418); // lgrl %r1,.+8 |
| 419 | writeInt16BE(Addr+2, 0x0000); |
| 420 | writeInt16BE(Addr+4, 0x0004); |
| 421 | writeInt16BE(Addr+6, 0x07F1); // brc 15,%r1 |
| 422 | // 8-byte address stored at Addr + 8 |
| 423 | return Addr; |
Akira Hatanaka | b889e0c | 2012-08-17 21:28:04 +0000 | [diff] [blame] | 424 | } |
| 425 | return Addr; |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | // Assign an address to a symbol name and resolve all the relocations |
| 429 | // associated with it. |
| 430 | void RuntimeDyldImpl::reassignSectionAddress(unsigned SectionID, |
| 431 | uint64_t Addr) { |
| 432 | // The address to use for relocation resolution is not |
| 433 | // the address of the local section buffer. We must be doing |
Andrew Kaylor | 2898988 | 2012-11-05 20:57:16 +0000 | [diff] [blame] | 434 | // a remote execution environment of some sort. Relocations can't |
| 435 | // be applied until all the sections have been moved. The client must |
| 436 | // trigger this with a call to MCJIT::finalize() or |
| 437 | // RuntimeDyld::resolveRelocations(). |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 438 | // |
| 439 | // Addr is a uint64_t because we can't assume the pointer width |
| 440 | // of the target is the same as that of the host. Just use a generic |
| 441 | // "big enough" type. |
| 442 | Sections[SectionID].LoadAddress = Addr; |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 443 | } |
| 444 | |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 445 | void RuntimeDyldImpl::resolveRelocationList(const RelocationList &Relocs, |
| 446 | uint64_t Value) { |
| 447 | for (unsigned i = 0, e = Relocs.size(); i != e; ++i) { |
Rafael Espindola | 87b5017 | 2013-04-29 17:24:34 +0000 | [diff] [blame] | 448 | const RelocationEntry &RE = Relocs[i]; |
| 449 | // Ignore relocations for sections that were not loaded |
| 450 | if (Sections[RE.SectionID].Address == 0) |
| 451 | continue; |
| 452 | resolveRelocation(RE, Value); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
Eli Bendersky | 37bc5a2 | 2012-04-30 12:15:58 +0000 | [diff] [blame] | 456 | void RuntimeDyldImpl::resolveExternalSymbols() { |
| 457 | StringMap<RelocationList>::iterator i = ExternalSymbolRelocations.begin(), |
| 458 | e = ExternalSymbolRelocations.end(); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 459 | for (; i != e; i++) { |
| 460 | StringRef Name = i->first(); |
| 461 | RelocationList &Relocs = i->second; |
Eli Bendersky | d98c9e9 | 2012-05-01 06:58:59 +0000 | [diff] [blame] | 462 | SymbolTableMap::const_iterator Loc = GlobalSymbolTable.find(Name); |
| 463 | if (Loc == GlobalSymbolTable.end()) { |
Andrew Kaylor | 7b17050 | 2013-02-20 18:09:21 +0000 | [diff] [blame] | 464 | if (Name.size() == 0) { |
| 465 | // This is an absolute symbol, use an address of zero. |
| 466 | DEBUG(dbgs() << "Resolving absolute relocations." << "\n"); |
| 467 | resolveRelocationList(Relocs, 0); |
Andrew Kaylor | 29fe150 | 2013-02-20 18:24:34 +0000 | [diff] [blame] | 468 | } else { |
| 469 | // This is an external symbol, try to get its address from |
Andrew Kaylor | 7b17050 | 2013-02-20 18:09:21 +0000 | [diff] [blame] | 470 | // MemoryManager. |
| 471 | uint8_t *Addr = (uint8_t*) MemMgr->getPointerToNamedFunction(Name.data(), |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 472 | true); |
Andrew Kaylor | 7b17050 | 2013-02-20 18:09:21 +0000 | [diff] [blame] | 473 | DEBUG(dbgs() << "Resolving relocations Name: " << Name |
| 474 | << "\t" << format("%p", Addr) |
| 475 | << "\n"); |
| 476 | resolveRelocationList(Relocs, (uintptr_t)Addr); |
| 477 | } |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 478 | } else { |
Eli Bendersky | 37bc5a2 | 2012-04-30 12:15:58 +0000 | [diff] [blame] | 479 | report_fatal_error("Expected external symbol"); |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 480 | } |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 485 | //===----------------------------------------------------------------------===// |
| 486 | // RuntimeDyld class implementation |
Danil Malyshev | cf852dc | 2011-07-13 07:57:58 +0000 | [diff] [blame] | 487 | RuntimeDyld::RuntimeDyld(RTDyldMemoryManager *mm) { |
Andrew Kaylor | 53608a3 | 2012-11-15 23:50:01 +0000 | [diff] [blame] | 488 | // FIXME: There's a potential issue lurking here if a single instance of |
| 489 | // RuntimeDyld is used to load multiple objects. The current implementation |
| 490 | // associates a single memory manager with a RuntimeDyld instance. Even |
| 491 | // though the public class spawns a new 'impl' instance for each load, |
| 492 | // they share a single memory manager. This can become a problem when page |
| 493 | // permissions are applied. |
Danil Malyshev | cf852dc | 2011-07-13 07:57:58 +0000 | [diff] [blame] | 494 | Dyld = 0; |
| 495 | MM = mm; |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | RuntimeDyld::~RuntimeDyld() { |
| 499 | delete Dyld; |
| 500 | } |
| 501 | |
Andrew Kaylor | 3f23cef | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 502 | ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) { |
Danil Malyshev | cf852dc | 2011-07-13 07:57:58 +0000 | [diff] [blame] | 503 | if (!Dyld) { |
Rafael Espindola | 3ecfcc2 | 2013-06-11 18:01:14 +0000 | [diff] [blame] | 504 | sys::fs::file_magic Type = |
| 505 | sys::fs::identify_magic(InputBuffer->getBuffer()); |
| 506 | switch (Type) { |
| 507 | case sys::fs::file_magic::elf_relocatable: |
| 508 | case sys::fs::file_magic::elf_executable: |
| 509 | case sys::fs::file_magic::elf_shared_object: |
| 510 | case sys::fs::file_magic::elf_core: |
| 511 | Dyld = new RuntimeDyldELF(MM); |
| 512 | break; |
| 513 | case sys::fs::file_magic::macho_object: |
| 514 | case sys::fs::file_magic::macho_executable: |
| 515 | case sys::fs::file_magic::macho_fixed_virtual_memory_shared_lib: |
| 516 | case sys::fs::file_magic::macho_core: |
| 517 | case sys::fs::file_magic::macho_preload_executable: |
| 518 | case sys::fs::file_magic::macho_dynamically_linked_shared_lib: |
| 519 | case sys::fs::file_magic::macho_dynamic_linker: |
| 520 | case sys::fs::file_magic::macho_bundle: |
| 521 | case sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub: |
| 522 | case sys::fs::file_magic::macho_dsym_companion: |
| 523 | Dyld = new RuntimeDyldMachO(MM); |
| 524 | break; |
| 525 | case sys::fs::file_magic::unknown: |
| 526 | case sys::fs::file_magic::bitcode: |
| 527 | case sys::fs::file_magic::archive: |
| 528 | case sys::fs::file_magic::coff_object: |
| 529 | case sys::fs::file_magic::pecoff_executable: |
Alexey Samsonov | 9c22f87 | 2013-06-18 15:03:28 +0000 | [diff] [blame] | 530 | case sys::fs::file_magic::macho_universal_binary: |
Rafael Espindola | 3ecfcc2 | 2013-06-11 18:01:14 +0000 | [diff] [blame] | 531 | report_fatal_error("Incompatible object format!"); |
Eli Bendersky | a66a185 | 2012-01-16 08:56:09 +0000 | [diff] [blame] | 532 | } |
Danil Malyshev | cf852dc | 2011-07-13 07:57:58 +0000 | [diff] [blame] | 533 | } else { |
Eli Bendersky | a66a185 | 2012-01-16 08:56:09 +0000 | [diff] [blame] | 534 | if (!Dyld->isCompatibleFormat(InputBuffer)) |
Danil Malyshev | cf852dc | 2011-07-13 07:57:58 +0000 | [diff] [blame] | 535 | report_fatal_error("Incompatible object format!"); |
| 536 | } |
| 537 | |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 538 | return Dyld->loadObject(InputBuffer); |
| 539 | } |
| 540 | |
Jim Grosbach | b027105 | 2011-04-08 17:31:24 +0000 | [diff] [blame] | 541 | void *RuntimeDyld::getSymbolAddress(StringRef Name) { |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 542 | return Dyld->getSymbolAddress(Name); |
| 543 | } |
| 544 | |
Jim Grosbach | 35ed842 | 2012-09-05 16:50:40 +0000 | [diff] [blame] | 545 | uint64_t RuntimeDyld::getSymbolLoadAddress(StringRef Name) { |
| 546 | return Dyld->getSymbolLoadAddress(Name); |
| 547 | } |
| 548 | |
Jim Grosbach | f8c1c84 | 2011-04-12 21:20:41 +0000 | [diff] [blame] | 549 | void RuntimeDyld::resolveRelocations() { |
| 550 | Dyld->resolveRelocations(); |
| 551 | } |
| 552 | |
Jim Grosbach | 61425c0 | 2012-01-16 22:26:39 +0000 | [diff] [blame] | 553 | void RuntimeDyld::reassignSectionAddress(unsigned SectionID, |
| 554 | uint64_t Addr) { |
| 555 | Dyld->reassignSectionAddress(SectionID, Addr); |
Jim Grosbach | f8c1c84 | 2011-04-12 21:20:41 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Jim Grosbach | e940c1b | 2012-09-13 21:50:06 +0000 | [diff] [blame] | 558 | void RuntimeDyld::mapSectionAddress(const void *LocalAddress, |
Jim Grosbach | 020f4e8 | 2012-01-16 23:50:55 +0000 | [diff] [blame] | 559 | uint64_t TargetAddress) { |
| 560 | Dyld->mapSectionAddress(LocalAddress, TargetAddress); |
| 561 | } |
| 562 | |
Jim Grosbach | 91dde15 | 2011-03-22 18:22:27 +0000 | [diff] [blame] | 563 | StringRef RuntimeDyld::getErrorString() { |
Jim Grosbach | b3eecaf | 2011-03-22 18:19:42 +0000 | [diff] [blame] | 564 | return Dyld->getErrorString(); |
| 565 | } |
| 566 | |
Rafael Espindola | a2e40fb | 2013-05-05 20:43:10 +0000 | [diff] [blame] | 567 | StringRef RuntimeDyld::getEHFrameSection() { |
| 568 | return Dyld->getEHFrameSection(); |
| 569 | } |
| 570 | |
Jim Grosbach | 6e56331 | 2011-03-21 22:15:52 +0000 | [diff] [blame] | 571 | } // end namespace llvm |