[llvm-commits] [PATH] Properly support ctor / dtor priorities on the targets which support them

Anton Korobeynikov anton at korobeynikov.info
Wed Jan 11 09:59:29 PST 2012


Hello Everyone

Right now our handling of ctor / dtor priorities is broken. The
concept of "structor priority" allows us to order the stuff locally
within single .o file.
However, if one will try to link two .o files together then the
priorities will be broken.

The standard solution to this problem is to emit the ctor with
priority N to section like ".init_array.N" and rely on linker merging
such sections in proper order.
However, here we have to make sure we're doing stuff correct, because
if the target uses .ctor / .dtor sections then we have to *reverse*
the priorities.

This patch allows a target to specify to which section output the
structor with priority N and then rely on linker to order everything
properly.

This finally fixes some priority-related PRs e.g. PR5329 and around.

Tested on darwin, arm-linux-elf, arm-linux-gnueabi, x86_64-linux and
mingw32. Ok to commit?

-- 
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctors.diff
Type: application/octet-stream
Size: 16556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120111/0987b622/attachment.obj>


More information about the llvm-commits mailing list