This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: How to verify init_priorty for C++ static object initialization order?


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


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