[Mono-list] We need Linux.NET Stub
Wed, 26 May 2004 07:31:27 -0400
On Wed, 2004-05-26 at 04:34, Ian MacLean wrote:
> It probably depends on whether you need to keep the file as a valid P.E.
> file. I'm not sure its possible to create a file thats both a valid P.E
> and is also recognizable to the linux loader as a native binary. I don't
> know that much about the linux loader so I could be wrong here.
I'm quite sure that a "native" Linux .NET Stub is impossible. .NET
assemblies use the PE format, while the Linux image format is ELF. Both
of these formats, like all good file formats, contain magic numbers at
the beginning of the file, and the magic numbers wouldn't be any good if
they were the same...
Unless you can imagine a way of creating a file that is *both* ELF and
PE, *and* will be recognized as such on both Linux and Windows, this
simply can't be done. (Embedding one inside the other can't work, as
both PE and ELF loaders expect the magic number to appear at the start
of the file, give or take a few bytes, and they won't scan the entire
file looking for the start of an appropriate image.)
Just stick with binfmt_misc or shell scripts. Shell scripts are
probably preferred, as they don't need the ".exe" to be typed, which
seems to be a turn-off to a number of users...
Now, if you don't care about compatibility, you could always fork Mono
to generate PE images with an ELF header + Stub, which would make them
Linux friendly. However, these images would not be compatible or
readable by .NET, Rotor, PNET, or any other implementation, so such a
fork is of dubious value.