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: Alan Modra <amodra at gmail dot com>
- To: Jeffrey Walton <noloader at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Sun, 13 Sep 2015 19:38:06 +0930
- 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>
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.
--
Alan Modra
Australia Development Lab, IBM