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