This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Constructor of external lib called too early
- From: Dominik Vogt <vogt at linux dot vnet dot ibm dot com>
- To: libc-help at sourceware dot org
- Date: Mon, 29 Jul 2013 14:55:43 +0200
- Subject: Constructor of external lib called too early
- Reply-to: vogt at linux dot vnet dot ibm dot com
An external library - say, libfoo.{a,so} - defines a costructor
static void __attribute__ ((constructor 65535))
__foo_ctor (void)
{
const char *val;
val = getenv ("FOO_CFG");
...
}
and glibc is built and linked with -lfoo.
A program is linked against that the modified glibc. Now, when
the program is started, at the time __foo_ctor is called, the
environment is empty and FOO is never evaluated. I guess this
means that the constructor is called before the environment is
initialized.
Is there a way / what is the right way to have __foo_ctor called
_after_ the initialization of the environment? (Note that calling
the constructor from the executable instead of from glibc is not
an option.)
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany