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.


Muzaffer Ozakca wrote:
> 
> 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?

Yes it is a gcc extension -- and the best source of information is the
gcc documentation; `info gcc' for a properly installed gcc (and yes
there is a `destructor' attribute; unfortunately its efficacy is
somewhat in doubt).

Any function in the library with external linkage is `global' --
assuming you mean `visible to a process linking to it'; you can control
this by using a version script as an input to `ld' (sometimes you need a
symbol to be global to the library, but _not
_ visible from the outside).


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
--
If it's of it it's `its'.


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