On Fri, 19 Apr 2013 17:46:05 +0200 MARGUINAUD Philippe wrote: > 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 ? > 'main' is not in the program's dynamic symbol table (which is what dlsym() "interrogates"): $ objdump -T example | grep main 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __libc_start_main Make sure the symbol you're looking for has been made available for dynamic linking. -- Mihai Donțu