problems with dlopen() flags change between beta4 - RC1 ?
| From: | Pieter van Prooijen | Date: | Fri, 14 Apr 2000 14:51:08 +0000 |
| Subject: | problems with dlopen() flags change between beta4 - RC1 ? | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-13558@lists.php.net to get a copy of this message | ||
Hello All,
I'm currently developing some extension modules for php4 (for route
planning, map drawing etc.) under linux (RedHat 6.1). I run into some
problems due to changes in the flags given to the dlopen call (defined in
Zend/zend.h)
I'm not sure if this is a bug in my thinking, in the linux runtime linking
environment or in the new flags:
Each extension module (.so) links with a library ("common_lib.a") which
defines a statically allocated C++ object with static scope:
common_lib.a:
static SomeClass anInstance;
When looking with "nm -o" in each extension module:
foo.so: 000aaaa b anInstance
bar.so: 000bbbb b anInstance
The "b" means the instance lives in the BSS (uninitialised data) segment,
lower case means it is a local symbol.
When loaded into the apache/php4 process with dlopen(..., RTLD_NOW)
(php4/beta4), each .so sees its own version of the object (which is what I
want).
When using dlopen(..., RTLD_NOW | RTLD_GLOBAL) (php4/rc1, the runtime
linker somehow merges all local references to the object into one, causing
errors (e.g. the destructor for that merged object is called twice when the
foo.so and bar.so are unloaded from the process).
So my questions are:
- Is this the correct behaviour of the runtime linker (perhaps linux
specific ?), and if so, why does the RTLD_GLOBAL flag affect local symbols
?
- Is it possible to change the flags to dlopen back (in php4) or will this
break other things ?
- If not, how do I get the behaviour I want (file scoped objects, separate
for each .so) even when loaded with the GLOBAL flag.
If I need to supply more info, please let me know,
Many thanks,
Pieter van Prooijen