This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: More on entry point option for ld
- To: Jeff Parker <JEFFREY dot H dot PARKER at saic dot com>
- Subject: Re: More on entry point option for ld
- From: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Date: Sat, 30 Jun 2001 01:26:51 +1000
- Cc: gcc at gcc dot gnu dot org
- References: <3B3C9591.A221F6BF@mtg.saic.com>
On 29-Jun-2001, Jeff Parker <JEFFREY.H.PARKER@saic.com> wrote:
> My original message:
>
> I would like to link an object file to existing programs that I could
> call first, run some
> initialization functions, then call the original 'main' function.
>
> I've tried using the '-e <entry point>' option for 'ld'
That won't work, since the entry point is a procedure in the C runtime
start-up code (often named `_start'), not `main'. The procedure _start
initializes the C runtime, sets up the values of argc and argv, and then
calls main().
Rather than using `-e', you should use `--wrap main'.
See the documentation for `--wrap' in the GNU ld manual.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.