Hello All,

I have a .so file libfoo.so which contains the definition for function int
foo(const char*);

My main function looks like this:

int main {
      int (*fptr) (const char *) = 0;
      char *library = "/home/hemanth/Desktop/proj/samples/libfoo.so";
      printf ("libary name(%s), len(%d) \n", library, strlen (library));

      void *handle = dlopen (library, RTLD_NOW);

      if (handle != 0)
    {
  printf ("dlopen worked \n");
  *(void **) &fptr = dlsym (handle, "foo");
  if (fptr != 0)
    {
      printf ("dlsym worked too \n");
      (*fptr) ("1st hello from main");
      (*fptr) ("2nd hello from main again");
    }

    }
}

I use dlopen and dlsym to locate the function foo. However klee flags an
error saying fptr is an invalid function pointer and halts execution. Can
klee support such function calls using function pointers?

The o/p of the program is:

KLEE: WARNING: calling __user_main with extra arguments.
libary name(/home/hemanth/Desktop/proj/samples/libfoo.so), len(44)
dlopen worked
dlsym worked too
KLEE: ERROR: /home/hemanth/Desktop/proj/samples/main.c:51: invalid function
pointer
KLEE: NOTE: now ignoring this error at this location
terminateStateOnError Tid 23935, num_threads 0
KLEE: ctrl-c detected, requesting interpreter to halt.
KLEE: halting execution, dumping remaining states

I can get the program to work using --load option, but my project uses of
dlopen and dlsym extensively and I need to understand how to get klee to
invoke function pointers.

-- 

Thanks,
Hemanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://keeda.Stanford.EDU/pipermail/klee-dev/attachments/20100803/6a435e76/attachment.html
 

Reply via email to