glibc中的哪個函數調用main函數

[英]Which function in glibc calls the main function


I am trying to understand how Linux launches a program. I read somewhere that some function in glibc calls the main function. Profiling with callgrind and looking at the call-graphs in Kcachegrind, I see below main which calls main. But I don't understand this, a function can't be named such. So my question is which function in the glibc actually starts the main function.

我試圖了解Linux如何啟動程序。我在某處讀到glibc中的某些函數調用main函數。使用callgrind進行分析並查看Kcachegrind中的調用圖,我在下面看到main調用main。但是我不明白這個,一個函數不能這樣命名。所以我的問題是glibc中的哪個函數實際上啟動了main函數。

1 个解决方案

#1


11  

Following valgrind's own help you'll find this explanation for the option --show-below-main:

按照valgrind自己的幫助,你會找到選項--show-below-main的解釋:

By default, stack traces for errors do not show any functions that appear beneath main because most of the time it's uninteresting C library stuff and/or gobbledygook. Alternatively, if main is not present in the stack trace, stack traces will not show any functions below main-like functions such as glibc's __libc_start_main. Furthermore, if main-like functions are present in the trace, they are normalised as (below main), in order to make the output more deterministic.

默認情況下,錯誤的堆棧跟蹤不顯示在main下面顯示的任何函數,因為大多數時候它是不感興趣的C庫內容和/或gobbledygook。或者,如果堆棧跟蹤中不存在main,則堆棧跟蹤將不會在類似主函數(如glibc的__libc_start_main)下顯示任何函數。此外,如果跟蹤中存在類似主函數,則將它們標准化為(在主下方),以使輸出更具確定性。

As such, below main is not the function which calls main itself, but __libc_start_main.

因此,main下面不是調用main本身的函數,而是__libc_start_main。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/05/17/72f09ff9ed70b3a3f2a4626f63cad820.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com