Closed Bug 16845 Opened 25 years ago Closed 25 years ago

Add a load-library function with a 'flags' argument

Categories

(NSPR :: NSPR, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: wtc)

References

Details

Attachments

(2 files)

The current PR_LoadLibrary function does not have
a 'flags' argument, so one cannot control the flags
that NSPR passes to the underlying system call
(dlopen on Unix).

We should add a new load-library function that takes
a 'flags' argument.
Status: NEW → ASSIGNED
I've studied the native load-library functions on
Unix and Win32 to see what flags NSPR should support.

The following Unix dlopen flags are useful.  They
have been requested by our clients, and they are
in the UNIX98 standard.
- RTLD_NOW and RTLD_LAZY
- RTLD_GLOBAL and RTLD_LOCAL

The Win32 DONT_RESOLVE_DLL_REFERENCES flag might be
useful, but I am not convinced. At first glance, it
seems to be the same as the Unix RTLD_LAZY flag, but
they are in fact different.

So initially we should only support the equivalent
of RTLD_NOW, RTLD_LAZY, RTLD_GLOBAL, and RTLD_LOCAL.
Can these 4 flags be supported with uniform semantics on all flavors of Unix and
Windows?
Windows doesn't have the equivalent of any of
these four RTLD flags.

These four RTLD flags are in UNIX98, so they
are widely available on Unix platforms.  But
whether they are actually implemented is a
different question.  For example, on IBM AIX,
although RTLD_LAZY is defined in <dlfcn.h>,
it is not implemented.

I propose that we support these four
RTLD flags on a best-effort basis: if the OS
doesn't implement a flag, we just silently
ignore it as opposed to failing.
Just FYI...

On OpenVMS, RTLD_LAZY and RTLD_NOW are both defined in dlfcn.h, but are
ignored by the C RTL since the concept of deferred symbol resolution is
unknown to the operating system. Therefore RTLD_NOW always applies.

When a shareable image (dll) is loaded on OpenVMS, all symbols that were
marked as "universal" are made "global" at the time the image is loaded.
This appears to be what RTLD_GLOBAL does. Note that neither RTLD_GLOBAL
nor RTLD_LOCAL are defined in any header file.
Some useful URLs:
- UNIX98 dlopen: http://www.opengroup.org/onlinepubs/007908799/xsh/dlopen.html
- Win32 LoadLibraryEx:
http://msdn.microsoft.com/library/psdk/winbase/dll_4abc.htm

I like the name PR_LoadLibraryWithFlags that Ramiro suggested.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
I checked in the change.  I also changed to use RTLD_LAZY
on Linux (was using RTLD_NOW) after getting confirmation
from Robey Pointer that RTLD_NOW didn't really worked
around the bug he encountered.
/cvsroot/mozilla/nsprpub/pr/include/prlink.h, revision 3.3
/cvsroot/mozilla/nsprpub/pr/src/linking/prlink.c, revision 3.27

Internal repository:
/m/src/ns/nspr20/pr/include/prlink.h, revision 2.3
/m/src/ns/nspr20/pr/src/linking/prlink.c, revision 2.27
The checkin of nsprpub/pr/src/linking/prlink.c version 3.27
broke the build on my glibc 2.0 system. Bug 18826 describes
problem and I attached a patch to 18826 that fixes the problem.
Blocks: 19150
*** Bug 15828 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: