What purpose does __libc_init_array() in library libc.a serve?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What purpose does __libc_init_array() in library libc.a serve?

Jump to solution
6,092 Views
anaseem
Contributor IV

My development environment is MCUXpresso IDE.  My microcontroller is LPC11E68.  The reset entry point of my code calls __libc_init_array().  This function is in libc.a.  We are not provided with source code for this function?  Map files gives following information:

c:/nxp/mcuxpressoide_10.2.1_795/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v6-m\libc.a(lib_a-init.o)

./LPC_Code/cr_startup_lpc11e6x.o (__libc_init_array)

Why is this function called at startup?  Is there documentation that explains why this function needs to be called in reset initialization code?

I'm using NewLib (Nohost) library.

Labels (1)
Tags (1)
1 Solution
5,161 Views
BlackNight
NXP Employee
NXP Employee

This serves calling constructors and other library initialization which is necessary before calling main. There is a good description about this as well on gcc - understanding the __libc_init_array - Stack Overflow .

I hope this helps,

Erich

View solution in original post

1 Reply
5,162 Views
BlackNight
NXP Employee
NXP Employee

This serves calling constructors and other library initialization which is necessary before calling main. There is a good description about this as well on gcc - understanding the __libc_init_array - Stack Overflow .

I hope this helps,

Erich