This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Display initialization order of static C++ objects in a library or program?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Matt Rice <ratmice at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sat, 9 Jan 2016 18:19:41 -0500
- Subject: Re: Display initialization order of static C++ objects in a library or program?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8mRamf3ZR+Onm5ny3w13dvsyLjbZ2QCDafAXF_WzM4CPQ at mail dot gmail dot com> <CACTLOFoPHZFVF64dGB40n-0iSpJ8AQgXwLkBOMM_MWt38=W8Pg at mail dot gmail dot com>
- Reply-to: noloader at gmail dot com
> This is by its nature platform dependent, with glibc you can get this
> information by setting the environment variable LD_DEBUG=libs (the
> calling init: lines), but don't expect the initialization order to
> produce the same results on another platform.
Thanks Matt. That may come in handy.
Below is what I am seeing. I'm looking for more detail at "32732:
initialize program: ./cryptest.exe". I want to see the symbolic name
of each object created, and the order in which it was created. For
example,
32732: initialize program: ./cryptest.exe
32732: initializing std::string DEFAULT_CHANNEL
32732: initializing std::string AAD_CHANNEL
...
32732: initializing Foo g_bar
...
Is that possible to do?
If not, how do folks tell that init_priority is being honored? And if
init_priority in not in effect, how can we tell the order of object
creation?
Jeff
$ LD_DEBUG=libs ./cryptest.exe v
32732: find library=libstdc++.so.6 [0]; searching
32732: search cache=/etc/ld.so.cache
32732: trying file=/usr/lib/aarch64-linux-gnu/libstdc++.so.6
32732:
32732: ...
32732: initialize program: ./cryptest.exe
32732:
32732: transferring control: ./cryptest.exe
32732: