dynamic libraries: custom _init() without losing default _init()
Zagorodnev, Grigory
grigory.zagorodnev@intel.com
Tue Mar 29 22:03:00 GMT 2005
>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
More information about the Gcc-help
mailing list