[Mono-dev] Mixed Mode Assemblies

Tom Spink tspink at gmail.com
Sat Jul 9 14:12:56 EDT 2011


On 9 July 2011 18:57, Jonathan Pryor <jonpryor at vt.edu> wrote:

> On Jul 9, 2011, at 1:06 PM, arkain wrote:
> > Here's another possibility. I don't see what the problem would be in
> > embedding ELF objects into a PE following the usual COFF objects. Doesn't
> PE
> > have a text section that could be used to tag for extraction the native
> > portion of the assembly? If that were used, then it would be possible to
> > create a PE that contained COFF for the .NET  code and ELF for the native
> > code (on linux). The assembly loader in Linux could then extract the ELF
> > content into a separate file in a temp directory and load it with dlopen.
>
> That's only a halfway solution. One of the Nice Things about C++/CLI (and
> COM interop, for that matter) is that native clients can load managed
> assemblies without even realizing it [0]. Things Just Work because
> LoadLibrary() loads a mixed-mode assembly the same way it loads any other
> native library, and the loading app doesn't need to do anything differently.
>
> Consequently, what you really want is to embed IL/etc. into ELF/Mach-O/etc.
> file formats, and add support to mono for these alternative file formats.
> This would allow existing native code to continue to use dlopen(3)/etc.
> against platform-native libraries which "just happen" to contain IL as well,
> implicitly pulling in mono (via shared library dependencies, more or less
> how things work with PE on Windows).
>
> This was previously discussed on this thread, and given that ELF allows
> embedding ~arbitrary text/binary sections into .so files (and presumably
> .dylib does as well), adding support for this likely wouldn't be _too_
> difficult...
>
>  - Jon
>

I agree with you here, Jon, and it sounds like quite an interesting
exercise.  Of course, one of the other interesting things here would be what
compiler do you use to generate a mixed-mode ELF?  Or, how do you embed IL
(and associated metadata) into your ELF - what process do you run to create
this combination ELF?

Also, not having looked at the Mono PE loader (in depth), I don't know how
hard it would be to abstract the container format away from reading
metadata.  And after having glanced at it just now - it doesn't look /too/
horrendous.

-- 
Tom Spink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110709/28d11f87/attachment.html 


More information about the Mono-devel-list mailing list