我最近学习了__libc_start_main()
函数。我认为__libc_start_main()
调用main()
函数,如this answer中所述,但当我在下面的测试程序中的main()
函数中插入断点后检查堆栈指针$rsp
时,它是__libc_start_call_main()
的地址。__libc_start_main()
和__libc_start_call_main()
有什么区别?
源码
#include <stdio.h>
int main(void)
{
puts("Sunghyeon Lee");
}
字符串
gdb输出
──(kali㉿kali)-[~]
└─$ gdb test
GNU gdb (Debian 12.1-3) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test...
(No debugging symbols found in test)
(gdb) b *main
Breakpoint 1 at 0x1139
(gdb) r
Starting program: /home/kali/test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, 0x0000555555555139 in main ()
(gdb) x/a $rsp
0x7fffffffdec8: 0x7ffff7dd920a <__libc_start_call_main+122>
型
我搜索了关于__libc_start_main()
和__libc_start_call_main()
之间的差异的信息,但我没有找到解释。
1条答案
按热度按时间lyr7nygr1#
我从来没有找到关于它的解释。
看看创建
__libc_start_call_main
的commit。实际上,
__libc_start_main
的一部分被拆分成一个单独的例程。