Reputation: 1038
I got a segmentation fault from running a program. The backtrace
command in gdb
shows that the calling stack is
#0 0x000000001048d594 in .__libc_csu_init ()
#1 0x000000001048ce20 in .generic_start_main ()
#2 0x000000001048d030 in .__libc_start_main ()
#3 0x0000000000000000 in ?? ()
Can someone tell me where generic_start_main()
is defined? I tried to search in glibc
with
grep -R generic_start_main *
but only got
sysdeps/unix/sysv/linux/powerpc/libc-start.c:29:#define LIBC_START_MAIN generic_start_main
sysdeps/unix/sysv/linux/powerpc/libc-start.c:102: return generic_start_main (stinfo->main, argc, argv, auxvec,
I'm running programs on a 3.10.0 Linux
on a 64-bit PowerPC machine.
Upvotes: 2
Views: 759
Reputation: 213446
but only got
You give up too easily. Look in sysdeps/unix/sysv/linux/powerpc/libc-start.c
, and you'll see that it #include <csu/libc-start.c>
after defining LIBC_START_MAIN
, and the csu/libc-start.c
has:
STATIC int
LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
int argc, char **argv,
#ifdef LIBC_START_MAIN_AUXVEC_ARG
ElfW(auxv_t) *auxvec,
#endif
__typeof (main) init,
void (*fini) (void),
void (*rtld_fini) (void), void *stack_end)
{ ...
Update:
I'm not very familiar with how the #define macro works.
The #define
creates a text substitution rule for the preprocessor. For example:
#define FOO Bar
tells the preprocessor: every time you see FOO
, replace it with Bar
(there are some details I am sweeping under the rug here, but they are not important for this question).
So, given:
#define LIBC_START_MAIN generic_start_main
int LIBC_START_MAIN() { ... }
This is what the compiler sees after preprocessing:
int generic_start_main() { ... }
Upvotes: 1