This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


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

Re: preloading.


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


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