[Mono-dev] Mixed Mode Assemblies
jonpryor at vt.edu
Sat Jul 9 13:57:08 EDT 2011
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 . 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...
 This is also potentially a Bad Thing™, depending on how you see it. :-)
More information about the Mono-devel-list