Shared Library Question

M

maven22

Hello,

I wrote a little app which uses a shared library (DLL). Normally, I
load the shlib using "dlopen()", and find the functions I want using
"dlsym()". However, I am attempting to get rid of any overhead and am
curious about a little problem I'm having.

I decided to make a function in my shlib called
"get_function_list()". When I start my program, I open the shlib
using "dlopen()" and use "dlsym()" to get the "get_function_list()"
function. That function returns a list of all the methods inside the
shlib that I will be using.

Therein lies the problem. For any function in my shlib, the address
returned by dlsym() and the address returned in my function list are
different. I've placed a bunch of debug code in both my shlib and my
sample app to printf the address of the function. Using dlsym(), the
function I want is located at "0x2405e0e8", but the address in my list
is "0x24032e38". Unfortunately, the difference between dlsym and my
list is not always 2b2b0 as in this case.

Has anyone ever experienced this or does anyone have any insight in to
the issue?

Any help will be greatly appreciated.

Thanks!
 
F

Flash Gordon

maven22 wrote, On 15/03/07 13:29:
Hello,

I wrote a little app which uses a shared library (DLL). Normally, I
load the shlib using "dlopen()", and find the functions I want using
"dlsym()". However, I am attempting to get rid of any overhead and am
curious about a little problem I'm having.

I decided to make a function in my shlib called
"get_function_list()". When I start my program, I open the shlib
using "dlopen()" and use "dlsym()" to get the "get_function_list()"

<snip>

That is all system specific and not standard C so you will have to ask
in a group dedicated to your implementation. I'm guessing
comp.unix.programmer might be a good starting point. One thing I would
say though, have you profiled and proved that there is a significant
overhead and also that the overhead is actually a problem? My guess is
that you have not and if you did you would find it was not your
bottleneck, so you are probably wasting your time even if you solve the
problem you are having.

1st rule of optimisation, don't do it.

One you have mastered the first rule and have also proved you have a
problem the 1st rule does not solve (it solve a surprisingly large
number) then we will tell you the second rule.
 
M

maven22

maven22 wrote, On 15/03/07 13:29:




<snip>

That is all system specific and not standard C so you will have to ask
in a group dedicated to your implementation. I'm guessing
comp.unix.programmer might be a good starting point. One thing I would
say though, have you profiled and proved that there is a significant
overhead and also that the overhead is actually a problem? My guess is
that you have not and if you did you would find it was not your
bottleneck, so you are probably wasting your time even if you solve the
problem you are having.

1st rule of optimisation, don't do it.

One you have mastered the first rule and have also proved you have a
problem the 1st rule does not solve (it solve a surprisingly large
number) then we will tell you the second rule.

Thanks for the pointer. However, my goal of this project was not not
use dlsym for every function, thus that's rule #1 of this project.

I take it you have no idea why I'm having this issue, do you? Thanks
anyway.
 
K

Kenneth Brody

maven22 said:
Hello,

I wrote a little app which uses a shared library (DLL). Normally, I
[... function in shared library returns address of other functions
differently than using something called "dlsym()"
....]
Has anyone ever experienced this or does anyone have any insight in to
the issue?

Any help will be greatly appreciated.

If you statically link to the library, does get_function_list() return
the address you expect? If so, then it's something specific to how
shared libraries are working on your system, and shared libraries are
off-topic in clc. You will need to discuss it in a group that is
specific to your platform and/or shared libraries.

If statically linking still doesn't "work" as expected, then it is
possible that you are doing something wrong. In that case, you can
post the relevent code here showing what you are doing, and what is
"wrong" about what you get.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top