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]

Re: LD_PRELOAD and attribute constructor


You really cannot count upon the execution order of constructors across
compilation units. All that is guaranteed is that within one compilation
unit (one source file) the constructors will execute in order. When you
are dealing with more than one compilation unit - all bets are off: all
that is guaranteed is that all static constructors will be called before
main is called, but in what order? No guarantees.

As for the idea of "any ctor like function in a module will be called
before any functions in the module are called" - how do you expect that
could work? What if a file defines 2 ctor functions, the first of which
calls a function within the file? How, then, can both ctor functions be
called before the call of the normal function, when it is the first ctor
that calls the function?




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