文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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");
}
相关阅读 更多 +
排行榜 更多 +
暴打木偶人(Beat The Puppet)

暴打木偶人(Beat The Puppet)

飞行射击 下载
星际队长(Tap! Captain Star)

星际队长(Tap! Captain Star)

飞行射击 下载
棒棒勇者大冒险

棒棒勇者大冒险

飞行射击 下载