How to verify init_priorty for C++ static object initialization order?
Alan Modra
amodra@gmail.com
Sun Sep 13 10:08:00 GMT 2015
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
More information about the Binutils
mailing list