public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* how to redefine _start ?
@ 2002-01-08 10:18 Yannick PERRET
  2002-01-08 15:00 ` Hans-Peter Nilsson
  0 siblings, 1 reply; 2+ messages in thread
From: Yannick PERRET @ 2002-01-08 10:18 UTC (permalink / raw)
  To: binutils

Hi,

I'm working on a profiler based on the 'instrument-functions'
gcc feature (functioncheck on sourceforge).

For performance reasons, I want to make some inits
before any program execution (before main). In addition
I want to perform these inits before static constructors in
C++ program (which start before main).

I tried to give my own _start, _init and _fini functions by
removing the crt1 ones (-nostartlibs). The problem is
that I cannot figure what _start is supposed to do before
calling main() (return value, args...). The problem is the
same for _fini function.

I checked the gcc source, but crt1 seems to only be ASM
code.


Is it possible to write _start and stuff in C properly ?
If yes, where to find some documentation/exemples ?
If no, anybody got an idea to perform "before-main" treatments
(and of course "after-main") ?


Thank you for any help.

Regards
--
Yannick


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: how to redefine _start ?
  2002-01-08 10:18 how to redefine _start ? Yannick PERRET
@ 2002-01-08 15:00 ` Hans-Peter Nilsson
  0 siblings, 0 replies; 2+ messages in thread
From: Hans-Peter Nilsson @ 2002-01-08 15:00 UTC (permalink / raw)
  To: Yannick PERRET; +Cc: binutils

On Tue, 8 Jan 2002, Yannick PERRET wrote:
> Is it possible to write _start and stuff in C properly ?

Short answer: no.

> If yes, where to find some documentation/exemples ?
> If no, anybody got an idea to perform "before-main" treatments
> (and of course "after-main") ?

See docs on the linker option --wrap, as in "--wrap main".
You will also want "--wrap exit".

brgds, H-P

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-01-08 20:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-08 10:18 how to redefine _start ? Yannick PERRET
2002-01-08 15:00 ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).