[LLVMdev] [lld] Handling multiple -init/-fini command line options

Simon Atanasyan simon at atanasyan.com
Mon Dec 8 12:26:26 PST 2014

On Mon, Dec 8, 2014 at 10:57 PM, Shankar Easwaran
<shankare at codeaurora.org> wrote:
> The dynamic loader handles only one entry for DT_INIT. If there is more than
> one init option, we could convert this as an .init_array instead ?
> If that doesnot work, we can come up with a .init_array option but I am not
> sure about how will you handle priority with init_array's ? Do you set
> linker defined init/fini symbols the last in priority ?

My idea:
1. -init/-fini options affects DT_INIT/DT_FINI tags only. If there is
no any option, the linker searches _init/_finit symbols and configure
DT_INIT/DT_FINI tags. This behaviour exactly corresponds to the GNU
linker. By the way symbols specified in the -init/-fini options can be
in any sections, not only .init/.fini.

2. -init-array/-fini-array options (I still not sure we need this
functionality) affect .init_array/.fini_array and
DT_INIT_ARRAY/DT_FINI_ARRAY tags. The order of these options define

The only problem is that we cannot setup priority of DT_INIT vs DT_INIT_ARRAY.

Simon Atanasyan

More information about the llvm-dev mailing list