The priorities in the section name suffixes are zero padded, allowing the linker to just do a lexical sort.
Add zero padding for .ctors sections in ELF as well.
Differential D40407
[COFF] Implement constructor priorities mstorsjo on Nov 24 2017, 12:52 AM. Authored by
Details The priorities in the section name suffixes are zero padded, allowing the linker to just do a lexical sort. Add zero padding for .ctors sections in ELF as well.
Diff Detail
Event TimelineComment Actions Could you give me a context of this patch? .ctors and .dtors are essentially an ELF stuff, so I'm wondering how you are going to use it in COFF. Comment Actions I noticed that the .ctors.1234 numerical suffixes are zero padded by GCC when targeting MinGW, updated this patch accordingly and expanded the test to showcase it. It doesn't seem like any other modern platform actually defaults to using .ctors at all, so I'm not sure if other platforms should have zero padding or not. If linking an object file that contains unpadded .ctors with GNU ld, they are interpreted numerically (and end up in .init_array). If linking for MinGW with GNU ld though, the zero padding is needed for them to be ordered properly.
Comment Actions Added zero padding for ELF as well, rewrote the zero padding in a more idiomatic way, applied Rui's style suggestion. Comment Actions LGTM
|