[Bug target/46770] Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Dec 11 23:48:00 GMT 2010
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
--- Comment #35 from H.J. Lu <hjl.tools at gmail dot com> 2010-12-11 23:48:29 UTC ---
(In reply to comment #34)
> On 12/11/2010 3:28 PM, hjl.tools at gmail dot com wrote:
>
> > 1. How do you find out what priority "foo" constructor has?
>
> If you're looking at source code, read the source.
This is not the problem.
> If you're looking at
> object code, look at what section the constructor is in; the numerical
> value of .ctor.NNNNN indicates the priority.
You have 2 problems:
1. __attribute__((init_priority(1005))) doesn't map to
.ctors.1005 section.
2. You need to check .init_array.NNNN sections on some
platforms.
> > 2. How do you run your constructor before "foo"?
>
> Given it a higher priority.
The highest priority is 65535. What if foo's
constructor already has 65535 priority?
My point is GCC supports:
--
In the following example, `A' would normally be created before
`B', but the `init_priority' attribute has reversed that order:
Some_Class A __attribute__ ((init_priority (2000)));
Some_Class B __attribute__ ((init_priority (543)));
Note that the particular values of PRIORITY do not matter; only
their relative ordering.
--
That is the constructor order between A and B. We don't support
"interleaving constructor priorities" between object files.
More information about the Gcc-bugs
mailing list