[Mono-list] tool to convert from CIL to Native file?

Jonathan Pryor jonpryor@vt.edu
19 Sep 2002 13:51:17 -0400


Your subject and your message body seem to have two different questions.

To answer the subject question, it is possible to convert CIL to a
native executable...with some restrictions.  Do a search for
``ngen.exe'' on google (which does the nearest equivalent on .NET) and
``ngen'' on the list archvies; Zoltan.2.Varga announced an ngen clone
back in July; see
http://lists.ximian.com/archives/public/mono-list/2002-July/001117.html
for the announcement.  Much discussion followed; it's by no means
perfect, but it's a start.

As for the question in your message body (native executable to CIL), it
might be possible.  Maybe.  I can certainly imagine that, for some
subset of programs, it would be possible to interpret the instruction
stream and transform the stream to CIL.  However, this would be for a
very limited subset of programs, as some programs require certain memory
layouts, interrupts, etc., that cannot be represented by CIL.  (A good
example of this would be a DOS program, which expects memory to be in
certain spots, and directly invokes interrupts for the DOS equivalent of
system calls.)  If a program never used interrupts, never directly used
hardware, and lots of other restrictions I'm sure I don't know, it might
be possible to convert it to CIL.

For example, it seams that it should be reasonable to take a C program
that only uses `printf' (dynamically linked to the program) to be
converted to CIL.  The compiler would only need to add a P/Invoke call
for `printf' (probably possible from the ELF header) and convert the
instruction stream.

Except that doing so would require that whatever platform the resulting
CIL code executed on had a library (libc.so) with the required export
(printf).  Meaning it couldn't work on .NET.

So, yes, it might be possible for some subset of programs, but it would
be very difficult,  and will not work as expected some (most?) of the
time.

Finally, no one (that I'm aware of) has started working on such a
thing.  The issues described above are probably why.

 - Jon

On Thu, 2002-09-19 at 10:56, mani gandan wrote:
> Hi,
> 
> any tool to convert CIL from native executable?
> 
> manigandan
> 
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list