|Adding custom code to the .init section of a library email@example.com (Priya Narasimhan) (1999-11-16)|
|Re: Adding custom code to the .init section of a library firstname.lastname@example.org.OZ.AU (1999-11-18)|
|Re: Adding custom code to the .init section of a library email@example.com (1999-11-18)|
|Re: Adding custom code to the .init section of a library firstname.lastname@example.org (Victor Zandy) (1999-11-18)|
|Re: Adding custom code to the .init section of a library email@example.com (1999-11-18)|
|From:||firstname.lastname@example.org (Michael Hicks)|
|Date:||18 Nov 1999 02:45:11 -0500|
|Organization:||University of Pennsylvania|
|Keywords:||C, linker, comment|
Priya Narasimhan (email@example.com) wrote:
: On a SPARC Solaris 2.x machine, I am able to add custom code
: to the .init section of a library using
: #pragma init (blah-blah)
: where blah-blah() is written in C code. How can I do this on
: an Intel machine running RedHatLinux 6.0 with gcc? I tried the
: #pragma init, and it did not work. I really would like to add
: something to the .init section so that every executable that
: links with my library can take advantage of the custom code
: within the library.
According to the dlopen manpage, you might be able to achieve the
same effect by defining a void _init(void) function in your library:
"If the library exports a routine named _init, then that code is
executed before dlopen returns."
This is probably specific to dlopen, however, and it may not be
that the libdl library (of which dlopen is a part) is unilaterally
used to load .so files.
Ph.D. Candidate, the University of Pennsylvania
[I looked at the BSD/OS dlopen() which is derived from the Linux one, and
I don't see anything that does that. -John]
Return to the
Search the comp.compilers archives again.