c - glibc中哪个函数调用了main函数

标签 c linux gcc glibc

我想了解 Linux 如何启动程序。我在某处读到 glibc 中的某些函数调用了 main 函数。使用 callgrind 进行分析并查看 Kcachegrind 中的调用图,我看到 below main 调用了 main。但是我不明白这一点,函数不能这样命名。所以我的问题是 glibc 中的哪个函数实际启动了 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 下 不是调用 main 本身的函数,而是 __libc_start_main

关于c - glibc中哪个函数调用了main函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10642852/

相关文章:

c - 如何从 K&R C 转换为 ANSI C?

c - 另一个 typedef 结构中的 typedef 结构格式

linux - 如何向 Elementary OS Luna 中的 WingPanel 添加状态图标?

regex - 使用正则表达式列出 Linux 驱动程序

c - 将 int 转换为 LPCWSTR (Win32) 的正确方法

为 x86 和 arm 编译 sparc 代码

linux - 在 linux 中获取硬盘的可用空间

macos - 在 OS X 10.11 上构建 GCC

xcode - GCC 警告 "incompatible implicit declaration of built-in function ‘printf’“在 Mac OS X Snow Leopard 下

linux - GCC 汇编语言编译器错误