This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: dynamic libraries: custom _init() without losing default _init()
- From: "Zagorodnev, Grigory" <grigory dot zagorodnev at intel dot com>
- To: "matze" <matze at indymedia dot org>, <gcc-help at gnu dot org>
- Date: Wed, 30 Mar 2005 01:05:26 +0400
- Subject: RE: dynamic libraries: custom _init() without losing default _init()
>to initialize the dynamic library a custom _init() is called. is it
>possible to call default _init() from the custom one or is there
>another way to invoke a custom function from default _init() or
>directly afterwards?
>
>matze
It would be safer to not override default startup code, but use one of
the following:
Once your code is C++ you can create file-scope instance of some
initialization class so its constructor will do the work. This is most
portable approach.
In case library initialization code must be executed _before_ any C++
object constructor, you may use ".preinit_array"
static preinit(int argc, char *argv[]);
static void (*const preinit_ptr) (int argc, char *argv[])
__attribute__ ((section (".preinit_array"))) = &preinit;
- Grigory