简体   繁体   English

__libc_start_main 和 __libc_start_call_main 有什么区别?

[英]What's the diffrence between __libc_start_main and __libc_start_call_main?

I came to know about the __libc_start_main function. I have been thinking that __libc_start_main call the main function like this , but when I checked ret of main function of my own program, it is the address of __libc_start_call_main.知道了__libc_start_main function,我一直以为__libc_start_main是这样调用main function的,结果查看自己程序的main function的ret时发现是__libc_start_call_main的地址。 What's the diffrence between __libc_start_main and __libc_start_call_main? __libc_start_main 和 __libc_start_call_main 有什么区别?

source code of my program, test.c我程序的源代码,test.c

#include <stdio.h>

int main(void) 
{
    puts("Sunghyeon Lee");
}

gdb output: gdb output:

──(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>

Thank you for your help!谢谢您的帮助!

I have searched about the diffrence between __libc_start_main and __ibc_start_call_main, I have never found the explanation about it.我已经搜索过 __libc_start_main 和 __ibc_start_call_main 之间的区别,我从来没有找到关于它的解释。

I have never found the explanation about it.我从来没有找到关于它的解释。

Take a look at the commit which created __libc_start_call_main .查看创建__libc_start_call_main提交

Effectively a chunk of __libc_start_main was split out into a separate routine.实际上, __libc_start_main的一大块被拆分成一个单独的例程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM