Calling Global Constructors: Difference between revisions

Improve ARM information
[unchecked revision][unchecked revision]
(Add information about GCC extensions)
(Improve ARM information)
Line 177:
func_ptr _fini_array_end[0] __attribute__ ((used, section(".fini_array"), aligned(sizeof(func_ptr)))) = { };
</source>
 
Additionally, if you use constructor/desctructor priorities, the compiler will append these priorities to the section name. The linker script is expected to expected to sort these, so you will have to add the following to your linker script. Note that we have to treat the crti.o and crtn.o objects specially because we need to put the symbols in the right order. Alternatively, you can emit the _init_array_start, _init_array_end, _fini_array_start, _fini_array_end symbols yourself from the linker script.
 
/* Include the list of initialization functions sorted. */
.init_array :
{
crti.o(.init_array)
KEEP (*(SORT(EXCLUDE_FILE(crti.o crtn.o) .init_array.*)))
KEEP (*(EXCLUDE_FILE(crti.o crtn.o) .init_array))
crtn.o(.init_array)
}
 
/* Include the list of termination functions sorted. */
.fini_array :
{
crti.o(.fini_array)
KEEP (*(SORT(EXCLUDE_FILE(crti.o crtn.o) .fini_array.*)))
KEEP (*(EXCLUDE_FILE(crti.o crtn.o) .fini_array))
crtn.o(.fini_array)
}
 
= Clang =
Anonymous user