What is the purpose of _init() and _fini() in the GCC toolchain?

I'm writing a bare metal ARM program in C and C++, using the linker and startup scripts provided by CMSIS_5. To get C++ global constructors etc. working, the linker must iterate through and execute the function pointers located in the memory between __init_array_start and __init_array_end which are defined in the linker script.

To do this, the __libc_init_array() function is called (init.c) from (I think) crt0.S. This function calls _init() However, my program only compiles (undefined reference) if I manually define _init(), and I have done so as such:

void _init(void) {};

My global constructors are called by __libc_init_array() just fine. So, what is the purpose of _init()? Is this simply for custom user initialisation code? Or am I calling these functions incorrectly?



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation