Yaakov (Cygwin/X | 8 Aug 2010 07:49
Picon
Gravatar

[PATCH] define RTLD_LOCAL

POSIX requires RTLD_LOCAL to be defined in <dlfcn.h>[1].  While our
dlopen() does nothing with its second argument, portable software can
rightfully expect the definition to exist alongside the other RTLD_*
macros.

So why 0?  POSIX states wrt dlopen()[2]:

> If neither RTLD_GLOBAL nor RTLD_LOCAL are specified, then the default
> behavior is unspecified.

On Linux, RTLD_LOCAL is the default behaviour[3], and hence is defined
as 0[4], therefore I have done the same here.

Patch attached.  Since this doesn't actually do anything, I wasn't sure
if I should bump CYGWIN_VERSION_API_MINOR for this or not; I can
certainly do so before committing if desired.

Yaakov

[1] http://www.opengroup.org/onlinepubs/9699919799/basedefs/dlfcn.h.html
[2] http://www.opengroup.org/onlinepubs/9699919799/functions/dlopen.html
[3] http://linux.die.net/man/3/dlopen
[4] http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h

Attachment (winsup-RTLD_LOCAL.patch): text/x-patch, 800 bytes
Václav Haisman | 8 Aug 2010 10:35
Picon
Picon
Gravatar

Re: [PATCH] define RTLD_LOCAL


Yaakov (Cygwin/X) wrote, On 8.8.2010 7:49:
> POSIX requires RTLD_LOCAL to be defined in <dlfcn.h>[1].  While our
> dlopen() does nothing with its second argument, portable software can
> rightfully expect the definition to exist alongside the other RTLD_*
> macros.
> 
> So why 0?  POSIX states wrt dlopen()[2]:
> 
>> If neither RTLD_GLOBAL nor RTLD_LOCAL are specified, then the default
>> behavior is unspecified.
> 
> On Linux, RTLD_LOCAL is the default behaviour[3], and hence is defined
> as 0[4], therefore I have done the same here.
> 
> Patch attached.  Since this doesn't actually do anything, I wasn't sure
> if I should bump CYGWIN_VERSION_API_MINOR for this or not; I can
> certainly do so before committing if desired.
Is it not undefined in Cygwin because Windows cannot support the behaviour?
AFAIK once you do LoadLibrary(A.dll) then any subsequent reference to A.dll
and its exports will be satisfied from the already loaded A.dll. IOW, Windows
cannot satisfy "The object's symbols shall not be made available for the
relocation processing of any other object," as specified by [2].

> [1] http://www.opengroup.org/onlinepubs/9699919799/basedefs/dlfcn.h.html
> [2] http://www.opengroup.org/onlinepubs/9699919799/functions/dlopen.html
> [3] http://linux.die.net/man/3/dlopen
> [4] http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h

--

-- 
(Continue reading)

Yaakov (Cygwin/X | 9 Aug 2010 05:45
Picon
Gravatar

Re: [PATCH] define RTLD_LOCAL

On Sun, 2010-08-08 at 10:35 +0200, Václav Haisman wrote:
> Is it not undefined in Cygwin because Windows cannot support the behaviour?
> AFAIK once you do LoadLibrary(A.dll) then any subsequent reference to A.dll
> and its exports will be satisfied from the already loaded A.dll. IOW, Windows
> cannot satisfy "The object's symbols shall not be made available for the
> relocation processing of any other object," as specified by [2].

Remember that Cygwin's dlopen() does nothing with the second argument,
so none of RTLD_* actually affect behaviour.  According to your logic,
we shouldn't define one of RTLD_LAZY or RTLD_NOW, because they can't
both be true, so our dlopen() isn't fulfilling its meaning.  We define
both anyway, and I don't see this as any different.

Secondly, on Linux, RTLD_LOCAL is essentially the default, so lots
(most?) software intended primarily for Linux which passes neither it
nor RTLD_GLOBAL is probably expecting RTLD_LOCAL behaviour anyway.
Therefore actually defining RTLD_LOCAL isn't a notable change.

Thirdly, several times I have seen the following:

#ifndef RTLD_LOCAL
#define RTLD_LOCAL 0
#endif

So they're clearly not too concerned about specific behaviour, they just
don't require RTLD_GLOBAL and therefore specify the opposite.  Defining
RTLD_LOCAL ourselves just saves us from patching this in to other
software.

Yaakov
(Continue reading)

Corinna Vinschen | 9 Aug 2010 09:48
Favicon

Re: [PATCH] define RTLD_LOCAL

On Aug  8 00:49, Yaakov S wrote:
> 	* include/dlfcn.h (RTLD_LOCAL): Define.

Patch applied.

Thanks,
Corinna

--

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Gmane