If you need the address of the exit function already present in your process, see the answers from Grijesh and others. But if you need to enable the libc exit function by name, for example, because libc exit was obscured by another library, you can get it with dlsym :
#define _GNU_SOURCE #include <dlfcn.h> /* ... */ void (*exit_addr)(int) = dlsym(RTLD_NEXT, "exit");
To enable dlsym , you need to associate with -ldl .
user4815162342
source share