文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>在 main 之前执行代码的方法, 也可用于共享库初始化

在 main 之前执行代码的方法, 也可用于共享库初始化

时间:2006-03-25  来源:ammer

1. Add to .init section, be called in .init before __do_global_ctors_aux

CODE:
int oinit(void)
{
  __asm__ (".section .init \n"
           "bl oinit \n\t"   /* for arm, or "call oinit \n\t" for x86
           ".section .text"); /* you can also put this out of the function */

  printf("In o init by insert to .init section");
}

2. Add to .ctors section, will be called by  function  __do_global_ctors_aux

CODE:
static void *__libinit __attribute__((section(".ctors"))) = libinit;
int libinit(void)
{
......
}

3. Use constructor attribute(alost added to .ctors section as method 2):
void func(void) __attribute__((constructor));

void func(void)
{
  printf("In lib's Constructor.\n");
}
相关阅读 更多 +
排行榜 更多 +
糖糖小镇

糖糖小镇

模拟经营 下载
梦绘界2025

梦绘界2025

浏览阅读 下载
39

39

系统软件 下载