- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Problems regarding symbol scoping from shared libr...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2001 06:56 AM
09-26-2001 06:56 AM
Problems regarding symbol scoping from shared libraries.
We are trying to port our application to hp-ux11 (32-bit) from Sun solaris. The application is written in C++ and we are building with aCC on hp-ux (on solaris, we build using g++). Following are two problems we are facing:
(1) Regarding symbol scope:
On hp-ux the shl_load call by default loads a module in the global scope. This call of shl_load does not offer any flags which can be used to load a module with symbols in local scope (similar to the RTLD_LOCAL flag for dlopen() on solaris). We have two archives (say archive1 and archive2) which have the same functions/classes but are different
versions (i.e. different implementations). We have two shared libraries (say sl1 and sl2). The shared library sl1 links with archive1 and sl2 links with archive2. Both these shared libraries are loaded by the webserver (iPlanet or Apache). Function calls from one shared library (say sl1) to functions in it's archive (archive1) are executing same function from other archive (archive2) instead.
We had faced a similar problem about symbol scoping for apache on solaris, which we resolved by loading the libraries at local scope (using RTLD_LOCAL).
We have tried the following options on hp-ux so far, without any success:
1. Link the shared libraries with '-B symbolic' option to resolve call paths internally.
2. Export only selected functions from the shared libraries using the '+e symbol' option, to ensure that the other symbols become local scope.
(2) Regarding multiple copies of archive files containing static data:
We build an archive file containing some static global data (primitive types like pointers or bool). This archive file is linked in to multiple shared libraries that we create. All these shared libraries get loaded
(dynamically) by our own application server.
My question is, will each shared library maintain/have a private copy of the static global data from the archive or will there exist a single copy of global static data in the server.
Currently with the test driver that we have tried, looks like only one copy of the global static data from the archive is being maintained in the server.
Any help regarding the above two problems will be appreciated.
Thanks,
Paresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2001 09:52 AM
09-26-2001 09:52 AM
Re: Problems regarding symbol scoping from shared libraries.
I have attached an example that demonstrates that symbols
are local to the shared libraries.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2001 08:35 AM
09-27-2001 08:35 AM
Re: Problems regarding symbol scoping from shared libraries.
Thanks a lot for the help.
We tried to download the patch you mentioned, but found that it is not the relevant patch. Was there a typo in the patch number?
Anyways, we downloaded patch number (PHSS_23440) which is "s700_800 11.00 ld(1) and linker tools cumulative patch". After installing this patch, we tried the your sample application. It runs fine. The next thing we tried is as follows: We created a small main2.cpp as shown below:
/* start main2.cpp*/
#include
extern "C" void a(void);
int main(int argc, char *argv[])
{
a();
return 0;
}
/* end main2.cpp */
We built liba.sl and libb.sl using your makefile.
Then we tried the following two things:
1. Implicitly linked main2.cpp with both the shared libraries by
aCC +z main2.cpp -L`pwd` -la -lb
The output from a.out was:
2. Then we changed the order of the libraries on command line as:
aCC +z main2.cpp -L`pwd` -lb -la
The output from a.out was:
Points from the outputs:
(a) The same address is getting used for the global data from both libraries (i.e. 0x7afe8078). And the same is being over written in the second constructor call.
(b) The function common_name is called from the first -lLibrary that we link with on the command line.
What this shows is that for implicitly linked libraries (i.e. with -lLibrary), those are loaded by the run-time linker at global scope.
Is this correct or are we missing something over here?
In our project we have a whole bunch of shared libraries, that we link implicitly with (using -lLibrary option). And we would like these to be loaded at local scope. Is there some way to achieve this?
Thanks once again.
Regards,
Paresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2001 01:06 PM
09-27-2001 01:06 PM
Re: Problems regarding symbol scoping from shared libraries.
I don't know of any link directive that will produce the same binding effects as RTLD_LOCAL. The one approach that will make symbols local regardless of loading style is to hide symbols before the shared library is created.
The attached example uses ld with -r and -h to create one .o from all the .o files that will go into a shared library.
Hiding "global" and "common_name" at that time makes them really local to the single .o and to the shared library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2001 02:33 PM
11-29-2001 02:33 PM
Re: Problems regarding symbol scoping from shared libraries.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2001 08:03 AM
12-03-2001 08:03 AM
Re: Problems regarding symbol scoping from shared libraries.
Here is the excerpt from the "HP-UX Linker and Libraries User's Guide" document.
If you are linking any C++ object files to create an executable or a shared library, you must use the CC command to link. This ensures that c++patch executes and chains together your nonlocal static constructors and destructors. If you use ld, the library or executable may not work correctly and you may not get any error messages.
Refer to
http://docs.hp.com/cgi-bin/onlinedocs.py?mpn=B2355-90655&service=hpux&path=../B2355-90655/00/00/18&title=HP-UX%20Linker%20and%20Libraries%20User%27s%20Guide
To pass the '-B,symbolic' option to the linker from aCC use '-Wl' option. You need to pass '-Wl,-B,symbolic' to aCC. Refer to documentation on the '-W' compiler option.
hope this helps.