IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • No replies
dickdunbar
dickdunbar
2 Posts

Pinned topic How do you display init/term priorities for existing libraries?

‏2011-09-06T14:26:56Z |
I have read through multiple discusions to use -qpriority to establish C++ init/destructor order.

How do I display the priority number for an existing library ...
  • To verify it has been set correctly if I'm building the code
  • To understand third-party libraries I might dynamically load
Updated on 2011-10-12T05:17:59Z at 2011-10-12T05:17:59Z by dickdunbar
  • SystemAdmin
    SystemAdmin
    196 Posts

    Re: How do you display init/term priorities for existing libraries?

    ‏2011-10-11T21:19:13Z  
    You can find the priority by doing nm on the object or shared library.
    For example, compile the following and observe the priority in the object.

    int bar();
    static int i = bar();
    #pragma priority(-5)
    static int j = bar();
    #pragma priority(5)
    static int k = bar();
    int foo() { return i+j+k; }

    nm t.o | grep ^__sinit
    __sinit7ffffffb_x_2fhome_2fzibi_2ft_2eC() D 696 12
    __sinit7ffffffb_x_2fhome_2fzibi_2ft_2eC() d 656 4
    __sinit80000000_x_2fhome_2fzibi_2ft_2eC() D 660 12
    __sinit80000000_x_2fhome_2fzibi_2ft_2eC() d 640 4
    __sinit80000005_x_2fhome_2fzibi_2ft_2eC() D 684 12
    __sinit80000005_x_2fhome_2fzibi_2ft_2eC() d 652 4

    The __sinit7ffffffb* is a function to initialized j (priority -5).
    The __sinit80000000* uses a default priority 0 and __sinit80000005* has priority 5.
    Therefore the higher the number in the signature indicate lower priority.
  • dickdunbar
    dickdunbar
    2 Posts

    Re: How do you display init/term priorities for existing libraries?

    ‏2011-10-12T05:17:59Z  
    You can find the priority by doing nm on the object or shared library.
    For example, compile the following and observe the priority in the object.

    int bar();
    static int i = bar();
    #pragma priority(-5)
    static int j = bar();
    #pragma priority(5)
    static int k = bar();
    int foo() { return i+j+k; }

    nm t.o | grep ^__sinit
    __sinit7ffffffb_x_2fhome_2fzibi_2ft_2eC() D 696 12
    __sinit7ffffffb_x_2fhome_2fzibi_2ft_2eC() d 656 4
    __sinit80000000_x_2fhome_2fzibi_2ft_2eC() D 660 12
    __sinit80000000_x_2fhome_2fzibi_2ft_2eC() d 640 4
    __sinit80000005_x_2fhome_2fzibi_2ft_2eC() D 684 12
    __sinit80000005_x_2fhome_2fzibi_2ft_2eC() d 652 4

    The __sinit7ffffffb* is a function to initialized j (priority -5).
    The __sinit80000000* uses a default priority 0 and __sinit80000005* has priority 5.
    Therefore the higher the number in the signature indicate lower priority.
    Thank you very much. I don't think I ever could have figured it out on my own.