<html><head><base href="x-msg://10024/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 8, 2011, at 10:09 AM, Malea, Daniel wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="WordSection1" style="page: WordSection1; "><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); ">Hi all,<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); "><o:p> </o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); ">There was a bug (related to symbol address computation) in the patch I posted here earlier. If anyone’s interested in a very minimal runtime ELF loader (with a workaround for the aforementioned bug) please take a look at the attached patch.<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); "><o:p> </o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); ">Thanks,<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); ">Daniel<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="color: rgb(31, 73, 125); "><o:p> </o:p></span></div><div><div style="border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; border-top-style: solid; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding-top: 3pt; padding-right: 0in; padding-bottom: 0in; padding-left: 0in; "><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; ">From:</span></b><span style="font-size: 10pt; font-family: Tahoma, sans-serif; "><span class="Apple-converted-space"> </span>Malea, Daniel<span class="Apple-converted-space"> </span><br><b>Sent:</b><span class="Apple-converted-space"> </span>Wednesday, December 07, 2011 2:13 PM<br><b>To:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-commits@cs.uiuc.edu" style="color: blue; text-decoration: underline; ">llvm-commits@cs.uiuc.edu</a><br><b>Subject:</b><span class="Apple-converted-space"> </span>Add basic ELF Dyld loader (on behalf of Andy Kaylor)<o:p></o:p></span></div></div></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Hi all,<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Please find the attached patch for review. It is the first step toward enabling lli –use-mcjit to work with ELF objects.<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-family: Consolas; ">Basic ELF loader in MCJIT (on behalf of Andy Kaylor):<span style="color: rgb(31, 73, 125); "><o:p></o:p></span></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0.5in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: -0.25in; "><span>-<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">       <span class="Apple-converted-space"> </span></span></span><span style="font-family: Consolas; ">Supports loading ELF object files emitted by MC<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0.5in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: -0.25in; "><span>-<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">       <span class="Apple-converted-space"> </span></span></span><span style="font-family: Consolas; ">Adds minimal x86 relocation support (function calls)<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-left: 0in; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><br></div></div></div></blockquote><br></div><div>Why the change away from "isKnownFormat"?</div><div><br></div><div><div>-    if (RuntimeDyldMachO::isKnownFormat(InputBuffer))</div><div>-      Dyld = new RuntimeDyldMachO(MM);</div><div>-    else</div><div>-      report_fatal_error("Unknown object format!");</div><div>+    sys::LLVMFileType type = sys::IdentifyFileType(InputBuffer->getBufferStart(),</div><div>+                            static_cast<unsigned>(InputBuffer->getBufferSize()));</div><div>+    switch (type) {</div><div>+      case sys::ELF_Relocatable_FileType:</div><div>+      case sys::ELF_Executable_FileType:</div><div>+      case sys::ELF_SharedObject_FileType:</div><div>+      case sys::ELF_Core_FileType:</div><div>+          Dyld = new RuntimeDyldELF(MM);</div><div>+          break;</div><div>+      case sys::Mach_O_Object_FileType:</div><div>+      case sys::Mach_O_Executable_FileType:</div><div>+      case sys::Mach_O_FixedVirtualMemorySharedLib_FileType:</div><div>+      case sys::Mach_O_Core_FileType:</div><div>+      case sys::Mach_O_PreloadExecutable_FileType:</div><div>+      case sys::Mach_O_DynamicallyLinkedSharedLib_FileType:</div><div>+      case sys::Mach_O_DynamicLinker_FileType:</div><div>+      case sys::Mach_O_Bundle_FileType:</div><div>+      case sys::Mach_O_DynamicallyLinkedSharedLibStub_FileType:</div><div>+      case sys::Mach_O_DSYMCompanion_FileType:</div><div>+          Dyld = new RuntimeDyldMachO(MM);</div><div>+          break;</div><div>+      case sys::COFF_FileType:</div><div>+      default:</div><div>+          report_fatal_error("Unknown object format!");</div><div>+    }</div><div><br></div><div>I don't have a problem with using sys::IdentifyFileType, but basically the function is now unused and should be deleted, though it makes a convenient interface if we want to keep it around.</div><div><br></div></div>-eric</body></html>