|
1 |
| -/*------------------------------------------------------------------------- |
| 1 | +/* |
| 2 | + * src/backend/port/dynloader/linux.c |
2 | 3 | *
|
3 |
| - * linux.c |
4 |
| - * Dynamic Loader for Postgres for Linux, generated from those for |
5 |
| - * Ultrix. |
| 4 | + * Dummy file used for nothing at this point |
6 | 5 | *
|
7 |
| - * You need to install the dld library on your Linux system! |
8 |
| - * |
9 |
| - * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group |
10 |
| - * Portions Copyright (c) 1994, Regents of the University of California |
11 |
| - * |
12 |
| - * |
13 |
| - * IDENTIFICATION |
14 |
| - * src/backend/port/dynloader/linux.c |
15 |
| - * |
16 |
| - *------------------------------------------------------------------------- |
| 6 | + * see linux.h |
17 | 7 | */
|
18 |
| - |
19 |
| -#include "postgres.h" |
20 |
| - |
21 |
| -#ifdef HAVE_DLD_H |
22 |
| -#include <dld.h> |
23 |
| -#endif |
24 |
| - |
25 |
| -#include "dynloader.h" |
26 |
| -#include "miscadmin.h" |
27 |
| - |
28 |
| - |
29 |
| -#ifndef HAVE_DLOPEN |
30 |
| - |
31 |
| -void * |
32 |
| -pg_dlopen(const char *filename) |
33 |
| -{ |
34 |
| -#ifndef HAVE_DLD_H |
35 |
| - elog(ERROR, "dynamic load not supported"); |
36 |
| - return NULL; |
37 |
| -#else |
38 |
| - static int dl_initialized = 0; |
39 |
| - |
40 |
| - /* |
41 |
| - * initializes the dynamic loader with the executable's pathname. (only |
42 |
| - * needs to do this the first time pg_dlopen is called.) |
43 |
| - */ |
44 |
| - if (!dl_initialized) |
45 |
| - { |
46 |
| - if (dld_init(dld_find_executable(my_exec_path))) |
47 |
| - return NULL; |
48 |
| - |
49 |
| - /* |
50 |
| - * if there are undefined symbols, we want dl to search from the |
51 |
| - * following libraries also. |
52 |
| - */ |
53 |
| - dl_initialized = 1; |
54 |
| - } |
55 |
| - |
56 |
| - /* |
57 |
| - * link the file, then check for undefined symbols! |
58 |
| - */ |
59 |
| - if (dld_link(filename)) |
60 |
| - return NULL; |
61 |
| - |
62 |
| - /* |
63 |
| - * If undefined symbols: try to link with the C and math libraries! This |
64 |
| - * could be smarter, if the dynamic linker was able to handle shared libs! |
65 |
| - */ |
66 |
| - if (dld_undefined_sym_count > 0) |
67 |
| - { |
68 |
| - if (dld_link("/usr/lib/libc.a")) |
69 |
| - { |
70 |
| - elog(WARNING, "could not link C library"); |
71 |
| - return NULL; |
72 |
| - } |
73 |
| - if (dld_undefined_sym_count > 0) |
74 |
| - { |
75 |
| - if (dld_link("/usr/lib/libm.a")) |
76 |
| - { |
77 |
| - elog(WARNING, "could not link math library"); |
78 |
| - return NULL; |
79 |
| - } |
80 |
| - if (dld_undefined_sym_count > 0) |
81 |
| - { |
82 |
| - int count = dld_undefined_sym_count; |
83 |
| - char **list = dld_list_undefined_sym(); |
84 |
| - |
85 |
| - /* list the undefined symbols, if any */ |
86 |
| - do |
87 |
| - { |
88 |
| - elog(WARNING, "\"%s\" is undefined", *list); |
89 |
| - list++; |
90 |
| - count--; |
91 |
| - } while (count > 0); |
92 |
| - |
93 |
| - dld_unlink_by_file(filename, 1); |
94 |
| - return NULL; |
95 |
| - } |
96 |
| - } |
97 |
| - } |
98 |
| - |
99 |
| - return (void *) strdup(filename); |
100 |
| -#endif |
101 |
| -} |
102 |
| - |
103 |
| -PGFunction |
104 |
| -pg_dlsym(void *handle, const char *funcname) |
105 |
| -{ |
106 |
| -#ifndef HAVE_DLD_H |
107 |
| - return NULL; |
108 |
| -#else |
109 |
| - return (PGFunction) dld_get_func((funcname)); |
110 |
| -#endif |
111 |
| -} |
112 |
| - |
113 |
| -void |
114 |
| -pg_dlclose(void *handle) |
115 |
| -{ |
116 |
| -#ifndef HAVE_DLD_H |
117 |
| -#else |
118 |
| - dld_unlink_by_file(handle, 1); |
119 |
| - free(handle); |
120 |
| -#endif |
121 |
| -} |
122 |
| - |
123 |
| -char * |
124 |
| -pg_dlerror(void) |
125 |
| -{ |
126 |
| -#ifndef HAVE_DLD_H |
127 |
| - return "dynaloader unsupported"; |
128 |
| -#else |
129 |
| - return dld_strerror(dld_errno); |
130 |
| -#endif |
131 |
| -} |
132 |
| - |
133 |
| -#endif /* !HAVE_DLOPEN */ |
0 commit comments