- 论坛徽章:
- 0
|
本帖最后由 chiuni 于 2011-09-27 17:02 编辑
向各位请教,
我在LK(bootloader)的 /kernel/main.c 文件中发现初始化的时候,会调用 call_constructors(void)函数,如下。
extern void *__ctor_list;
extern void *__ctor_end;
void kmain(void)
{
// get us into some sort of thread context
thread_init_early();
// early arch stuff
arch_early_init();
// do any super early platform initialization
platform_early_init();
// do any super early target initialization
target_early_init();
dprintf(INFO, "welcome to lk\n\n");
// deal with any static constructors
dprintf(SPEW, "calling constructors\n");
call_constructors();
static void call_constructors(void)
{
void **ctor;
ctor = &__ctor_list;
while(ctor != &__ctor_end) {
void (*func)(void);
func = (void (*)())*ctor;
func();
ctor++;
}
}
能否帮忙解释下,这个函数有什么作用? 为什么要在这里调用?
谢谢了先。 |
|