Mail Archives: djgpp/1998/08/23/18:17:10
On 23 Aug 98 at 22:37, Thomas Nyberg wrote:
> When you compile with asm-output ex. gcc -S test.c you there's a call to a
> function called ___main (or__main), my question is: what does it do? and is
> it possible to replace it (how)?
You can replace it if you want -- write your own function called
`__main' (in C, or `___main' in assembler). You probably don't want
to do this though; replacing undocumented bits of the startup code is
asking for trouble, unless you really understand what they're doing.
DJGPP's startup code calls `__main' anyway during crt1; gcc seems to
insert an extra call though as you noticed. DJGPP's `__main' calls
constructors. It has a wrapper so that it only gets executed once
per instance of the program. Its source code is in
`src/libc/crt0/_main.c', within djlsr.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
- Raw text -