linux

您所在的位置:网站首页 libc_start_main linux

linux

2024-03-10 02:24| 来源: 网络整理| 查看: 265

The other function calls described in the linked answer give a synopsis of what needs to happen; the actual implementation details in the GNU C library are different, either using “constructors” (_dl_start_user), or explicitly in __libc_start_main. __libc_start_main also takes care of calling the user’s main, which is why you don’t see it called in your disassembly — but its address is passed along (see the lea just the callq). __libc_start_main also takes care of the program exit, and never returns; that’s the reason for the hlt just after the callq, which will crash the program if the function returns.

The library needs quite a lot of setup nowadays:

some of its own relocation thread-local storage setup pthread setup destructor registration vDSO setup (on Linux) ctype initialisation copying the program name, arguments and environment to various library variables

etc. See the x86-64-specific sysdeps/x86_64/start.S and the generic csu/libc-start.c, csu/init-first.c, and misc/init-misc.c among others.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3