Given this program:
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello world\n");
return 0;
}
I'm trying to profile it:
$ gcc -g -pg -Wl,-R/usr/lib -L/usr/lib -lcurses -o prog prog.c
ld: /usr/lib/libc.so.12: warning: warning: __findenv is an internal
obsolete function.
$ ./prog
zsh: segmentation fault (core dumped) ./prog
...
As you can see, it segfaults. I added -g flag only to get some information
into
the core dump, but it still segfaults without the -g flag.
It happens only if I try to link external libraries.