[PATCH] D34326: [ELF] - Allow mixing .init_array.* and .ctors.* sections in linkerscript.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 01:35:27 PDT 2017


grimar added a comment.

In https://reviews.llvm.org/D34326#783412, @davide wrote:

> Please also note that lld doesn't really handle the case when we have mixed `.ctors` and `.init_array` from multiple object files in the non-linkerscript path.


Sure, non-linkerscipt patch is fine and do not need anything, we generate different output sections and the problem does not exist there.
Non-script case just has different implementations for sorting .ctors/.dtors and .init_array/.fini_array

SORT_BY_INIT_PRIORITY is a feature used for placing to .init_array/.fini_array for script case. 
Probably I should not have mention "mixing" here, sorry for possible confusion, it is not really important, it is just how bfd script looks like.

When we use SORT_BY_INIT_PRIORITY(.init_array.*) calculation should be reversed in compare with SORT_BY_INIT_PRIORITY(.ctors.*).
We can have script like

  .init_array : {  SORT_BY_INIT_PRIORITY(.ctors.*)) }

(simplified from bfd. So no mixing happens, .init_array may have only .ctors.*.)
And important to have different calculation for priority basing on section name here.

That is what this patch does.


https://reviews.llvm.org/D34326





More information about the llvm-commits mailing list