linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Steve Graegert" <graegerts@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: Startup function before main.
Date: Mon, 27 Mar 2006 13:48:16 +0200	[thread overview]
Message-ID: <6a00c8d50603270348j3966c663w3ff789c809e65228@mail.gmail.com> (raw)
In-Reply-To: <DC91351678E31E4FB24B551221F507EC028D5063@blr-itp-msg.wipro.com>

On 3/27/06, krishna.vamsi@wipro.com <krishna.vamsi@wipro.com> wrote:
> Hi List,
>
> Before Executing the main function, a startup routine will be executed
> which will set up the initial environment for the process.
>
> This Startup routine will be supplied by the kernel and linked by the
> Linker. My question is : Can we add one more startup routine before
> executing the main program, if yes how??

No, not programmatically, only by patching the executable or object file.
You can call other functions from within the constructor:

	void __attribute__ ((constructor)) my_ctor() {
		int i = my_func();
	}

You should not need a second constructor.  Who shall decide which one
comes first and how should it be done?

	\Steve

  reply	other threads:[~2006-03-27 11:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-27 11:07 Startup function before main krishna.vamsi
2006-03-27 11:48 ` Steve Graegert [this message]
2006-03-27 12:01 ` Uday Karan
2006-03-27 12:20   ` Steve Graegert
2006-03-27 17:48 ` Glynn Clements
  -- strict thread matches above, loose matches on Subject: below --
2006-03-27 12:22 krishna.vamsi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a00c8d50603270348j3966c663w3ff789c809e65228@mail.gmail.com \
    --to=graegerts@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).