Related articles |
---|
Adding custom code to the .init section of a library priya@alpha.ece.ucsb.edu (Priya Narasimhan) (1999-11-16) |
Re: Adding custom code to the .init section of a library fjh@cs.mu.OZ.AU (1999-11-18) |
Re: Adding custom code to the .init section of a library mwh@gradin.cis.upenn.edu (1999-11-18) |
Re: Adding custom code to the .init section of a library zandy@cs.wisc.edu (Victor Zandy) (1999-11-18) |
Re: Adding custom code to the .init section of a library plakal@cs.wisc.edu (1999-11-18) |
From: | mwh@gradin.cis.upenn.edu (Michael Hicks) |
Newsgroups: | comp.compilers |
Date: | 18 Nov 1999 02:45:11 -0500 |
Organization: | University of Pennsylvania |
References: | 99-11-082 |
Keywords: | C, linker, comment |
Priya Narasimhan (priya@alpha.ece.ucsb.edu) 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.
Mike
--
Michael Hicks
Ph.D. Candidate, the University of Pennsylvania
mwh@gradient.cis.upenn.edu
[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
comp.compilers page.
Search the
comp.compilers archives again.