This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
Re: preloading.
- To: glibc-linux at ricardo dot ecn dot wfu dot edu
- Subject: Re: preloading.
- From: Muzaffer Ozakca <muzaffer dot ozakca at bilten dot metu dot edu dot tr>
- Date: Mon, 13 Aug 2001 14:24:26 +0300
- Organization: Tubitak - Bilten
- References: <3B694020.AD7DA2C0@bilten.metu.edu.tr> <3B69A650.EA7D5C56@bga.com>
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
Thank you for the answer.
Artie Gold wrote:
>
> Muzaffer Ozakca wrote:
> >
> > Sorry for the dumb question. For a checkpointing system, I'm trying to
> > add some code to a process when it is started. I've read that the loader
> > (or whatever) is adding a call to the _exit() after main() returns. I
> > want to do a similar thing but before main() is called. Where should I
> > look for information on this? Should I change libc or any other/better
> > method to do this? Thank you for any help.
> >
> > --
> The simplest way to do this is to create an initialization function in
> your shared object (it doesn't matter if it is to be linked in of used
> with LD_PRELOAD) and mark it with
>
> __attribute__((constructor))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Is this a gcc extension? What are other possible "attributes"?
e.g. do we have __attribute__((destructor)) available? If yes, when it
is called? Where can I find more information about building shared
objects? Should I mark my exported functions or making them global is
OK?
>
> as in:
>
> void my_initialization() __attribute((constructor));
>
> void my_initialization() {
> ...
> }
>
> The other option, which in some instances makes compilation/linking a
> little more difficult would be to define a function called `_init' in
> your shared object, and compile with the `-nostartfiles' option.
>
> HTH,
> --ag
> --
> Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info)
> mailto:agold@bga.com or mailto:agold@cs.utexas.edu
> --
> "Verbing weirds language." -- Calvin
--
Muzaffer Ozakca
Researcher/Software Engineer - muzaffer.ozakca@bilten.metu.edu.tr
TUBITAK-Bilten-ODTU - Communications Systems and Comp. Networks Group
ODTU, Ankara, Turkey
http://www.bilten.metu.edu.tr tel: +90-312-210 1311