This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Constructor of external lib called too early


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]