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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
6,179 次查看
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.

标签 (1)
标记 (1)
1 解答
5,248 次查看
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

在原帖中查看解决方案

1 回复
5,249 次查看
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