http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
--- Comment #93 from Taras Glek <tglek at mozilla dot com> 2012-04-18 04:48:18 UTC --- (In reply to comment #92) > As I said in comment #47 and elsewhere, you should not confuse the order in > which entries appear in .ctors or .init_array sections with the order in which > they appear in the binary. If you want better layout in the binary, then tell > the linker to change the layout in the binary. The order in the .ctors or > .init_array sections is irrelevant. The fact that reversing the order of > constructors happens to give you faster startup for firefox is just a > coincidence. Don't let that coincidence drive you toward choices that make no > sense. I am not confusing the order in which entries appear. My concerns is the order in which code gets paged in from disk. Right now that's driven entirely by translation unit "concatenation" and how that relates to the order of ctor invocation. Currently the right thing(tm) happens, achieving the same by other means is considerably more complicated. There are 2 problems with using section ordering to solve this a) there is no way to do this kind of section ordering transparently(especially not by default) with current infrastructure. b) it doesn't work without lto because initializers pull in other code... I'll expand on b: We(C++ code like Firefox/Chrome/etc) have one initializer per TU. The initializer is often not self-contained and calls other code within the unit(and rarely in other units...this you can't solve without LTO) So if you pass a list of init sections to the linker...that list needs to be transitive and include all of the sections called from inits in order to achieve a useful level of locality post-reorder. Or you can keep TUs without any reordering, have decent locality(because related init code is generally nearby) and a sane page-in pattern if the order of init executions matches TU layout.