Finding the address of a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I am trying to find the address of a function whose name is known, using
dlopen/dlsym; for instance, I would have expected this program to print
the address of the main function :

#include <dlfcn.h>
#include <stdio.h>

int main ()
{
  void * lib = dlopen (NULL, RTLD_NOW);
  void * sym = dlsym (lib, "main");
  printf ("error=%s\n", dlerror ());
  printf ("sym=0x%llx\n", sym);
}

But instead, I get the following output :

error=./main.x: undefined symbol: main
sym=0x0

How shall I proceed ?

Cheers,

Philippe




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux