Re: win32/linux executables

Fabrice Medio <>
5 Jan 2002 01:45:01 -0500

          From comp.compilers

Related articles
win32/linux executables (2002-01-03)
Re: win32/linux executables (Fabrice Medio) (2002-01-05)
Re: win32/linux executables (Carsten Kuckuk) (2002-01-05)
Re: win32/linux executables (2002-01-05)
Re: win32/linux executables (Peter Cooper) (2002-01-05)
| List of all articles for this month |

From: Fabrice Medio <>
Newsgroups: comp.compilers
Date: 5 Jan 2002 01:45:01 -0500
Organization: Wanadoo, l'internet avec France Telecom
References: 02-01-010
Keywords: code, linker
Posted-Date: 05 Jan 2002 01:45:00 EST (gods1child) writes:
> Now as a next step towards writing compilers that create binary
> executables, I wanted to write a small compiler. The compiler would
> read an arithmetic expression and create an executable file that would
> accept a number from the console, run it through the compiled
> expression, and output the result to the console. The executable
> should work on win32 (later i want to move to linux too maybe by using
> a common intermediate language that would then be compiled for linux
> and windows).
> where do i start?

These pointers have been extremely precious to me as I wanted to
perform roughly the same task a couple of months ago :

And, obviously, you can give a read at

Unless you want to reinvent hot water, you'll probably have to link
your code to the C library or an equivalent like dietlibc[1]. The key
aspect of linking to foreign code is to understand the argument
passing conventions that are used by the foreign compiler.

By the way, if you're using gcc, beware of poorly documented calling
conventions. Here are a few tricks : arguments are pushed in reverse
order on the stack, and the stack is caller-safe (means the callee
function must give the stack back to the caller in the same state that
it received it). Playing around with gcc -S definitely helps.



Fabrice Medio

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.