[Mono-dev] Mixed Mode Assemblies

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

On 9 July 2011 19:31, Alex Corrado <alexander.corrado at gmail.com> wrote:

> On Sat, Jul 9, 2011 at 2:12 PM, Tom Spink <tspink at gmail.com> wrote:
> > 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?
> That would be nice and easy if the linker supported adding arbitrary
> sections. Then we'd just need a tool to extract the CLI parts from the
> PE file and create a binary blob that could be passed off to the
> linker. We would also need a way to generate native stubs that would
> load and initialize the mono runtime and a way to expose the managed
> API as native entry points. Since the CLI is OO, it would make sense
> to expose the managed API in a way that would be consumable from some
> native object system, like C++, Obj-C, or GObject.

Well, ld is our friend here.  You can pretty much do any sort of linking you
want, given the right linker script.

And embedding a wee stub to load mono should be easy enough.

> > 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.
> Would this really be necessary? Wouldn't it be cleaner if the
> ELF/Mach-o binary just linked with libMono and we exposed a native
> entry point that would use the Mono embedding APIs to call the managed
> Main method?

Hmm, I think probably yes, because at some point Mono still needs to read
the metadata header, and associated metadata tables, which means it'll need
to do a bit o' parsing to get the location of those structures into memory.
 Provided, however, the metadata format is kept exactly the same, then all
that would need to happen is to locate the start of the metadata header, and
(luckily) all the metadata just follows that.

> This does, indeed sound like quite an interesting exercise.
> Best,
> Alex Corrado

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

More information about the Mono-devel-list mailing list