Re: Startup function before main.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



krishna.vamsi@xxxxxxxxx wrote:

> 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

That's incorrect. The kernel's job ends at the point that it inkokes
the loader.

> and linked by the
> Linker. My question is : Can we add one more startup routine before
> executing the main program, if yes how??

Apart from the approach suggested by Steve, you can replace the
run-time startup file (crtbegin.o etc) with your own file (use gcc's
-nostartfiles option), or use your own loader in place of
ld-linux.so.2 (store the name of the loader in the .interp section of
the executable).

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux