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

Kaylor, Andrew andrew.kaylor at intel.com
Mon Dec 12 16:16:36 PST 2011


On Dec 9, 2011, at 13:34 AM, Eric Christopher wrote:



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

>>

>> 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"?



It seemed better to re-use the existing function to identify the format rather than partially duplicating the functionality in each dynamic loader implementation and having the base RuntimeDyld object deduce the file type by trial and error (though I suppose that trial and error is still happening in the IdentifyFileType function).



>

>-    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.


Yes, I probably should have deleted the RuntimeDyldMachO::isKnownFormat function.  The corresponding isCompatibleFormat function will still be used once a dynamic loader is instantiated, and so the implementation of isKnownFormat can be moved to there.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111212/b07e54d3/attachment.html>


More information about the llvm-commits mailing list