function address in libc?
c, libc, linux
Solution
If you need the address of the `exit` function already present in your process, see answers by Grijesh and others. But if you need to resolve the libc `exit` function by name, for example because libc's `exit` has been shadowed by another library, you can obtain it with `dlsym`:
#define _GNU_SOURCE /* for RTLD_NEXT */
#include <dlfcn.h>
/* ... */
void (*exit_addr)(int) = dlsym(RTLD_NEXT, "exit");
For `dlsym` to resolve, you'll need to link with `-ldl`.
Problem
I am trying to obtain the address (in hex) of function `exit()` provided in libc, but I am not sure where and how to find it. Anyone knows the way to find it please share some idea. Thank you!