http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
--- Comment #51 from H.J. Lu <hjl.tools at gmail dot com> 2010-12-13 20:30:58 UTC --- (In reply to comment #50) > > If gcc switches from .ctors to .init_array, it needs to make sure to generate > the constructors in forward order within the TU, rather than backwards order > as > it does in the .ctors section. I didn't see anything in HJ's patch that does > that. > It is handled in static section * get_elf_initfini_array_priority_section (int priority, bool constructor_p) { section *sec; if (priority != DEFAULT_INIT_PRIORITY) { char buf[18]; sprintf (buf, "%s.%.5u", constructor_p ? ".init_array" : ".fini_array", priority); sec = get_section (buf, SECTION_WRITE, NULL_TREE); } else sec = constructor_p ? init_array_section : fini_array_section; return sec; } It uses priority, instead of MAX_INIT_PRIORITY - priority, to generate NNNN for .init_arry.NNNN.