This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: More on entry point option for ld


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]