Operating System - HP-UX
1748198 Members
2571 Online
108759 Solutions
New Discussion юеВ

Re: Another share library question.

 
jack_8
Contributor

Another share library question.

I have a program A which call a shared library b.sl, using shl_load.
the make file is:
b.sl: b.C
$(CC) +z -b -Wl,-E,-B,immediate,+s -o b.sl b.C -L/test/lib -lmylib

A: A.C
$(CC) -z +z -Wl,+s +DAportable -o A A.C -ldld

mylib is another share library. mylib isn't used anywhere, just for test.
when I run A, I was told "can't load the library".(the shl_load return value is equal to NULL).

After I changed my make file to this:

b.sl: b.C
$(CC) +z -b -Wl,-E,-B,immediate,+s -o b.sl b.C -L/test/lib -lmylib

A: A.C
$(CC) -z +z -Wl,+s +DAportable -o A A.C -ldld -L /test/lib -lmylib

( add -L/test/lib -lmylib when compile A).
it can work correctly.
I use hp11 and aCC 3.25 and my SHLIB_PATH=.:/test/lib
I don't know the reason.
2 REPLIES 2
Kiran N. Mehta
Advisor

Re: Another share library question.

If your "mylib" uses the thread-local-storage APIs, then the problem could well be this: when program A tries to shl_load shared-library B which in turn has mylib --if not as a run-time dependency-- at least as a build-time dependency, the classic dynamic-loader limitation is in effect, viz. it cannot load, at runtime, a library which either itself or through its dependents uses TLStorage.

When you modify the build-script of program A to link with mylib at compile-time (instead of linking at run-time as a dependency of B), shl_load(B) does not have to load mylib because it is already there...

Hope this explains it.
jack_8
Contributor

Re: Another share library question.

thank you for your reply. I find the reason. I use shl_load only with bind_immediate. when I change to use shl_load with bind_immediate and bind_nonfatal. it can work. But one thing I can't understand is I add -Wl,B,immediate in the make file. I thought it can check unresolved symbol. but the fact is that it don't work. I don't know the reason. By the way, mylib is no relation to thread.