www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/23/18:17:10

Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: "George Foot" <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: thomas DOT nyberg AT usa DOT net
Date: Sun, 23 Aug 1998 23:14:29 +0000
MIME-Version: 1.0
Subject: Re: What does __main do???
Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk
CC: djgpp AT delorie DOT com
Message-Id: <E0zAiQU-0001VS-00@sable.ox.ac.uk>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019