This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: How to verify init_priorty for C++ static object initialization order?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Sun, 13 Sep 2015 06:29:13 -0400
- Subject: Re: How to verify init_priorty for C++ static object initialization order?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8kRPOhc0XmjOakL2AcXDoUJmjv8VzCurhhRPU5jckukBA at mail dot gmail dot com> <20150913100806 dot GA7224 at bubble dot grove dot modra dot org>
- Reply-to: noloader at gmail dot com
On Sun, Sep 13, 2015 at 6:08 AM, Alan Modra <amodra@gmail.com> wrote:
> On Sun, Sep 13, 2015 at 04:11:25AM -0400, Jeffrey Walton wrote:
>> I have an object file and an archive. How can I verify the priority is
>> embedded in both the object file and archive?
>
> The priority is encoded in section names, so use readelf -S or
> objdump -h to display the section headers.
>
> For this:
> #include <stdio.h>
>
> class A
> {
> public:
> A() {
> printf ("A\n");
> }
> public:
> ~A() {
> printf ("~A\n");
> }
> };
>
> A a __attribute__ ((init_priority (1000)));
>
> You'll see sections like .init_array.01000 for reasonably recent gcc.
>
Perfect, thanks.
I think I stumbles across it with either -i or -s (but was not sure
because it was names init_array rather than init_priority).
Thanks again.