471,573 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,573 software developers and data experts.

Calling dlsym()-ed function causes segfault

I'm intercepting a library function call using LD_PRELOAD and in-turn
calling the orignial library function. Essentially,

void (*real_func)(void) = (void (*) (void)) dlsym(RTLD_NEXT,
real_func(); //! Calling the original function -- SEGFAULT

This is compiled as:
g++ -shared -fPIC -Wall -o libintercept.so intercept.cc -ldl

When I run it as:
LD_PRELOAD=libintercept.so progname
it leads to a SEGFAULT at the place where real_func() is called. I've
checked to ensure that dlsym() succeeds. In fact, I've also checked
that dladdr() gives the correct function and file name for the resolved
library. The trouble, I guess, is with resolving some things since
things work OK if I replace the call to real_func() with the actual
code implemented in func().

Any leads to what's going wrong?

Machine: FC4-x86_64 with gcc-4.0.0


Aug 12 '06 #1
0 1268

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Vinod | last post: by
7 posts views Thread by Klaus Friese | last post: by
3 posts views Thread by Matt Churchyard | last post: by
17 posts views Thread by Bill Grigg | last post: by
3 posts views Thread by Mike | last post: by
47 posts views Thread by teju | last post: by
10 posts views Thread by sulekhasweety | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.