[llvm-commits] [PATCH] Add basic ELF Dyld loader (on behalf of Andy Kaylor)

Eric Christopher echristo at apple.com
Fri Dec 9 13:34:08 PST 2011


On Dec 8, 2011, at 10:09 AM, Malea, Daniel wrote:

> Hi all,
>  
> 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.
>  
> Thanks,
> Daniel
>  
> From: Malea, Daniel 
> Sent: Wednesday, December 07, 2011 2:13 PM
> To: llvm-commits at cs.uiuc.edu
> Subject: Add basic ELF Dyld loader (on behalf of Andy Kaylor)
>  
> Hi all,
>  
> Please find the attached patch for review. It is the first step toward enabling lli –use-mcjit to work with ELF objects.
>  
> Basic ELF loader in MCJIT (on behalf of Andy Kaylor):
> -        Supports loading ELF object files emitted by MC
> -        Adds minimal x86 relocation support (function calls)
> 

Why the change away from "isKnownFormat"?

-    if (RuntimeDyldMachO::isKnownFormat(InputBuffer))
-      Dyld = new RuntimeDyldMachO(MM);
-    else
-      report_fatal_error("Unknown object format!");
+    sys::LLVMFileType type = sys::IdentifyFileType(InputBuffer->getBufferStart(),
+                            static_cast<unsigned>(InputBuffer->getBufferSize()));
+    switch (type) {
+      case sys::ELF_Relocatable_FileType:
+      case sys::ELF_Executable_FileType:
+      case sys::ELF_SharedObject_FileType:
+      case sys::ELF_Core_FileType:
+          Dyld = new RuntimeDyldELF(MM);
+          break;
+      case sys::Mach_O_Object_FileType:
+      case sys::Mach_O_Executable_FileType:
+      case sys::Mach_O_FixedVirtualMemorySharedLib_FileType:
+      case sys::Mach_O_Core_FileType:
+      case sys::Mach_O_PreloadExecutable_FileType:
+      case sys::Mach_O_DynamicallyLinkedSharedLib_FileType:
+      case sys::Mach_O_DynamicLinker_FileType:
+      case sys::Mach_O_Bundle_FileType:
+      case sys::Mach_O_DynamicallyLinkedSharedLibStub_FileType:
+      case sys::Mach_O_DSYMCompanion_FileType:
+          Dyld = new RuntimeDyldMachO(MM);
+          break;
+      case sys::COFF_FileType:
+      default:
+          report_fatal_error("Unknown object format!");
+    }

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.

-eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111209/f1a922a3/attachment.html>


More information about the llvm-commits mailing list