Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa046b6

Browse files
committed
Use RTLD_NOW, not RTLD_LAZY, as binding mode for dlopen() on all platforms.
This restores the Linux behavior to what it was in PG 7.0 and 7.1, andcauses other platforms to agree. (Other well-tested platforms like HPUXwere doing it this way already.) Per pghackers discussion over the pastmonth or so.
1 parentbaa0bb9 commitfa046b6

File tree

17 files changed

+266
-79
lines changed

17 files changed

+266
-79
lines changed

‎src/backend/port/dynloader/README.dlfcn.aix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ table. If the path does not contain a '/' character, dlopen will search
3939
for the module using the LIBPATH environment variable. It returns an
4040
opaque handle to the module or NULL on error. The mode parameter can be
4141
either RTLD_LAZY (for lazy function binding) or RTLD_NOW for immediate
42-
function binding. The AIX implementation currentlydoes treat RTLD_NOW
43-
the same asRTLD_LAZY. The flag RTLD_GLOBAL might be or'ed into the
42+
function binding. The AIX implementation currentlybehaves as RTLD_NOW
43+
even ifRTLD_LAZY is specified. The flag RTLD_GLOBAL might be or'ed into the
4444
mode parameter to allow loaded modules to bind to global variables or
4545
functions in other loaded modules loaded by dlopen(). If RTLD_GLOBAL is
4646
not specified, only globals from the main part of the executable or

‎src/backend/port/dynloader/aix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: aix.h,v 1.10 2001/11/08 20:37:52 momjian Exp $
2+
* $Id: aix.h,v 1.11 2002/02/12 23:39:46 tgl Exp $
33
*
44
* @(#)dlfcn.h1.4 revision of 95/04/25 09:36:52
55
* This is an unpublished work copyright (c) 1992 HELIOS Software GmbH
@@ -57,7 +57,7 @@ intdlclose();
5757

5858
#include"utils/dynamic_loader.h"
5959

60-
#definepg_dlopen(f)dlopen((f),RTLD_LAZY | RTLD_GLOBAL)
60+
#definepg_dlopen(f)dlopen((f),RTLD_NOW | RTLD_GLOBAL)
6161
#definepg_dlsymdlsym
6262
#definepg_dlclose dlclose
6363
#definepg_dlerror dlerror

‎src/backend/port/dynloader/bsdi.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*-------------------------------------------------------------------------
22
*
3-
*Dynamic loader interface for BSD/OS
4-
*
3+
*bsdi.h
4+
*Dynamic loader interface for BSD/OS
55
*
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*port_protos.h,v 1.2 1995/05/25 22:51:03 andrew Exp
9+
*$Id: bsdi.h,v 1.15 2002/02/12 23:39:57 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -19,7 +19,21 @@
1919
#ifdefHAVE_DLOPEN
2020

2121
#include<dlfcn.h>
22-
#definepg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
22+
23+
/*
24+
* In some older systems, the RTLD_NOW flag isn't defined and the mode
25+
* argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
26+
* if available, but it doesn't exist everywhere.
27+
* If it doesn't exist, set it to 0 so it has no effect.
28+
*/
29+
#ifndefRTLD_NOW
30+
#defineRTLD_NOW 1
31+
#endif
32+
#ifndefRTLD_GLOBAL
33+
#defineRTLD_GLOBAL 0
34+
#endif
35+
36+
#definepg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
2337
#definepg_dlsym dlsym
2438
#definepg_dlclose dlclose
2539
#definepg_dlerror dlerror
@@ -32,6 +46,7 @@ do { \
3246
dld_unlink_by_file(handle, 1); \
3347
free(handle); \
3448
} while (0)
49+
3550
#endif/* not HAVE_DLOPEN */
3651

3752
#endif/* PORT_PROTOS_H */

‎src/backend/port/dynloader/dgux.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: dgux.h,v 1.13 2001/11/05 17:46:27 momjian Exp $
8+
* $Id: dgux.h,v 1.14 2002/02/12 23:40:03 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -21,9 +21,22 @@
2121
* this dynamic loader uses the system dynamic loading interface for shared
2222
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
2323
* library as the file to be dynamically loaded.
24-
*
2524
*/
26-
#definepg_dlopen(f) dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
25+
26+
/*
27+
* In some older systems, the RTLD_NOW flag isn't defined and the mode
28+
* argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
29+
* if available, but it doesn't exist everywhere.
30+
* If it doesn't exist, set it to 0 so it has no effect.
31+
*/
32+
#ifndefRTLD_NOW
33+
#defineRTLD_NOW 1
34+
#endif
35+
#ifndefRTLD_GLOBAL
36+
#defineRTLD_GLOBAL 0
37+
#endif
38+
39+
#definepg_dlopen(f)dlopen((f), RTLD_NOW | RTLD_GLOBAL)
2740
#definepg_dlsymdlsym
2841
#definepg_dlclosedlclose
2942
#definepg_dlerrordlerror

‎src/backend/port/dynloader/freebsd.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/*-------------------------------------------------------------------------
22
*
3-
* port_protos.h
4-
* port-specific prototypes for NetBSD 1.0
5-
*
3+
* freebsd.h
4+
* port-specific prototypes for FreeBSD
65
*
76
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
87
* Portions Copyright (c) 1994, Regents of the University of California
98
*
10-
* $Id: freebsd.h,v 1.14 2002/02/11 21:38:11 petere Exp $
9+
* $Id: freebsd.h,v 1.15 2002/02/12 23:40:12 tgl Exp $
1110
*
1211
*-------------------------------------------------------------------------
1312
*/
@@ -21,7 +20,6 @@
2120

2221
#include"utils/dynamic_loader.h"
2322

24-
/* dynloader.c */
2523
/*
2624
* Dynamic Loader on NetBSD 1.0.
2725
*
@@ -35,11 +33,20 @@
3533
* NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.)
3634
*/
3735

36+
/*
37+
* In some older systems, the RTLD_NOW flag isn't defined and the mode
38+
* argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
39+
* if available, but it doesn't exist everywhere.
40+
* If it doesn't exist, set it to 0 so it has no effect.
41+
*/
42+
#ifndefRTLD_NOW
43+
#defineRTLD_NOW 1
44+
#endif
3845
#ifndefRTLD_GLOBAL
3946
#defineRTLD_GLOBAL 0
4047
#endif
4148

42-
#definepg_dlopen(f) BSD44_derived_dlopen((f),RTLD_LAZY | RTLD_GLOBAL)
49+
#definepg_dlopen(f) BSD44_derived_dlopen((f),RTLD_NOW | RTLD_GLOBAL)
4350
#definepg_dlsym BSD44_derived_dlsym
4451
#definepg_dlclose BSD44_derived_dlclose
4552
#definepg_dlerror BSD44_derived_dlerror

‎src/backend/port/dynloader/irix5.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
3-
*port_protos.h
3+
*irix5.h
44
* port-specific prototypes for Irix 5
55
*
66
*
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
*port_protos.h,v 1.2 1995/03/17 06:40:18 andrew Exp
10+
*$Id: irix5.h,v 1.12 2002/02/12 23:40:24 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -17,16 +17,28 @@
1717
#include<dlfcn.h>
1818
#include"utils/dynamic_loader.h"
1919

20-
/* dynloader.c */
2120
/*
2221
* Dynamic Loader on SunOS 4.
2322
*
2423
* this dynamic loader uses the system dynamic loading interface for shared
2524
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
2625
* library as the file to be dynamically loaded.
27-
*
2826
*/
29-
#definepg_dlopen(f)dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
27+
28+
/*
29+
* In some older systems, the RTLD_NOW flag isn't defined and the mode
30+
* argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
31+
* if available, but it doesn't exist everywhere.
32+
* If it doesn't exist, set it to 0 so it has no effect.
33+
*/
34+
#ifndefRTLD_NOW
35+
#defineRTLD_NOW 1
36+
#endif
37+
#ifndefRTLD_GLOBAL
38+
#defineRTLD_GLOBAL 0
39+
#endif
40+
41+
#definepg_dlopen(f)dlopen((f), RTLD_NOW | RTLD_GLOBAL)
3042
#definepg_dlsymdlsym
3143
#definepg_dlclosedlclose
3244
#definepg_dlerrordlerror

‎src/backend/port/dynloader/linux.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
3-
* Dynamic loader interface for Linux
3+
* linux.h
4+
*Port-specific prototypes for Linux
45
*
56
*
67
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
78
* Portions Copyright (c) 1994, Regents of the University of California
89
*
9-
* $Id: linux.h,v 1.16 2001/11/05 17:46:27 momjian Exp $
10+
* $Id: linux.h,v 1.17 2002/02/12 23:40:29 tgl Exp $
1011
*
1112
*-------------------------------------------------------------------------
1213
*/
@@ -35,7 +36,20 @@ do { \
3536

3637
#else/* HAVE_DLOPEN */
3738

38-
#definepg_dlopen(f)dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
39+
/*
40+
* In some older systems, the RTLD_NOW flag isn't defined and the mode
41+
* argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
42+
* if available, but it doesn't exist everywhere.
43+
* If it doesn't exist, set it to 0 so it has no effect.
44+
*/
45+
#ifndefRTLD_NOW
46+
#defineRTLD_NOW 1
47+
#endif
48+
#ifndefRTLD_GLOBAL
49+
#defineRTLD_GLOBAL 0
50+
#endif
51+
52+
#definepg_dlopen(f)dlopen((f), RTLD_NOW | RTLD_GLOBAL)
3953
#definepg_dlsymdlsym
4054
#definepg_dlclosedlclose
4155
#definepg_dlerrordlerror

‎src/backend/port/dynloader/netbsd.h

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
3-
*port_protos.h
4-
* port-specific prototypes for NetBSD 1.0
3+
*netbsd.h
4+
* port-specific prototypes for NetBSD
55
*
66
*
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: netbsd.h,v 1.8 2001/11/05 17:46:27 momjian Exp $
10+
* $Id: netbsd.h,v 1.9 2002/02/12 23:40:37 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -21,7 +21,6 @@
2121

2222
#include"utils/dynamic_loader.h"
2323

24-
/* dynloader.c */
2524
/*
2625
* Dynamic Loader on NetBSD 1.0.
2726
*
@@ -34,7 +33,21 @@
3433
* begin with an underscore is fairly tricky, and some versions of
3534
* NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.)
3635
*/
37-
#definepg_dlopen(f) BSD44_derived_dlopen((f), RTLD_LAZY | RTLD_GLOBAL)
36+
37+
/*
38+
* In some older systems, the RTLD_NOW flag isn't defined and the mode
39+
* argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
40+
* if available, but it doesn't exist everywhere.
41+
* If it doesn't exist, set it to 0 so it has no effect.
42+
*/
43+
#ifndefRTLD_NOW
44+
#defineRTLD_NOW 1
45+
#endif
46+
#ifndefRTLD_GLOBAL
47+
#defineRTLD_GLOBAL 0
48+
#endif
49+
50+
#definepg_dlopen(f) BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)
3851
#definepg_dlsym BSD44_derived_dlsym
3952
#definepg_dlclose BSD44_derived_dlclose
4053
#definepg_dlerror BSD44_derived_dlerror

‎src/backend/port/dynloader/openbsd.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*-------------------------------------------------------------------------
22
*
3-
* Dynamic loader for OpenBSD
3+
* openbsd.h
4+
* port-specific prototypes for OpenBSD
45
*
56
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
67
* Portions Copyright (c) 1994, Regents of the University of California
78
*
8-
* $Id: openbsd.h,v 1.9 2001/11/05 17:46:27 momjian Exp $
9+
* $Id: openbsd.h,v 1.10 2002/02/12 23:40:40 tgl Exp $
910
*
1011
*-------------------------------------------------------------------------
1112
*/
@@ -19,7 +20,6 @@
1920

2021
#include"utils/dynamic_loader.h"
2122

22-
/* dynloader.c */
2323
/*
2424
* Dynamic Loader on NetBSD 1.0.
2525
*
@@ -32,7 +32,21 @@
3232
* begin with an underscore is fairly tricky, and some versions of
3333
* NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.)
3434
*/
35-
#definepg_dlopen(f) BSD44_derived_dlopen((f), RTLD_LAZY)
35+
36+
/*
37+
* In some older systems, the RTLD_NOW flag isn't defined and the mode
38+
* argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
39+
* if available, but it doesn't exist everywhere.
40+
* If it doesn't exist, set it to 0 so it has no effect.
41+
*/
42+
#ifndefRTLD_NOW
43+
#defineRTLD_NOW 1
44+
#endif
45+
#ifndefRTLD_GLOBAL
46+
#defineRTLD_GLOBAL 0
47+
#endif
48+
49+
#definepg_dlopen(f) BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)
3650
#definepg_dlsym BSD44_derived_dlsym
3751
#definepg_dlclose BSD44_derived_dlclose
3852
#definepg_dlerror BSD44_derived_dlerror

‎src/backend/port/dynloader/osf.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
3-
*alpha.h
3+
*osf.h
44
* prototypes for OSF/1-specific routines
55
*
66
*
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: osf.h,v 1.7 2001/11/15 16:08:15 petere Exp $
10+
* $Id: osf.h,v 1.8 2002/02/12 23:40:43 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -18,23 +18,28 @@
1818
#include<dlfcn.h>
1919
#include"utils/dynamic_loader.h"
2020

21-
/* dynloader.c */
22-
2321
/*
2422
* Dynamic Loader on Alpha OSF/1.x
2523
*
2624
* this dynamic loader uses the system dynamic loading interface for shared
2725
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
2826
* library as the file to be dynamically loaded.
29-
*
3027
*/
3128

32-
/* RTLD_GLOBAL is not available in <5.x */
29+
/*
30+
* In some older systems, the RTLD_NOW flag isn't defined and the mode
31+
* argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
32+
* if available, but it doesn't exist everywhere.
33+
* If it doesn't exist, set it to 0 so it has no effect.
34+
*/
35+
#ifndefRTLD_NOW
36+
#defineRTLD_NOW 1
37+
#endif
3338
#ifndefRTLD_GLOBAL
3439
#defineRTLD_GLOBAL 0
3540
#endif
3641

37-
#definepg_dlopen(f)dlopen((f),RTLD_LAZY | RTLD_GLOBAL)
42+
#definepg_dlopen(f)dlopen((f),RTLD_NOW | RTLD_GLOBAL)
3843
#definepg_dlsym(h,f) ((PGFunction) dlsym(h, f))
3944
#definepg_dlclose(h)dlclose(h)
4045
#definepg_dlerror()dlerror()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp