diff options
Diffstat (limited to 'src/lib/libcrypto/dso/dso_dlfcn.c')
-rw-r--r-- | src/lib/libcrypto/dso/dso_dlfcn.c | 95 |
1 files changed, 1 insertions, 94 deletions
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c index 5f351b318d..fe5f0ffdb0 100644 --- a/src/lib/libcrypto/dso/dso_dlfcn.c +++ b/src/lib/libcrypto/dso/dso_dlfcn.c | |||
@@ -56,16 +56,6 @@ | |||
56 | * | 56 | * |
57 | */ | 57 | */ |
58 | 58 | ||
59 | /* We need to do this early, because stdio.h includes the header files | ||
60 | that handle _GNU_SOURCE and other similar macros. Defining it later | ||
61 | is simply too late, because those headers are protected from re- | ||
62 | inclusion. */ | ||
63 | #ifdef __linux | ||
64 | # ifndef _GNU_SOURCE | ||
65 | # define _GNU_SOURCE /* make sure dladdr is declared */ | ||
66 | # endif | ||
67 | #endif | ||
68 | |||
69 | #include <stdio.h> | 59 | #include <stdio.h> |
70 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
71 | #include <openssl/dso.h> | 61 | #include <openssl/dso.h> |
@@ -78,18 +68,8 @@ DSO_METHOD *DSO_METHOD_dlfcn(void) | |||
78 | #else | 68 | #else |
79 | 69 | ||
80 | #ifdef HAVE_DLFCN_H | 70 | #ifdef HAVE_DLFCN_H |
81 | # ifdef __osf__ | ||
82 | # define __EXTENSIONS__ | ||
83 | # endif | ||
84 | # include <dlfcn.h> | 71 | # include <dlfcn.h> |
85 | # define HAVE_DLINFO 1 | 72 | # define HAVE_DLINFO 1 |
86 | # if defined(_AIX) || defined(__CYGWIN__) || \ | ||
87 | defined(__SCO_VERSION__) || defined(_SCO_ELF) || \ | ||
88 | (defined(__osf__) && !defined(RTLD_NEXT)) || \ | ||
89 | (defined(__OpenBSD__) && !defined(RTLD_SELF)) || \ | ||
90 | defined(__ANDROID__) | ||
91 | # undef HAVE_DLINFO | ||
92 | # endif | ||
93 | #endif | 73 | #endif |
94 | 74 | ||
95 | /* Part of the hack in "dlfcn_load" ... */ | 75 | /* Part of the hack in "dlfcn_load" ... */ |
@@ -136,30 +116,6 @@ DSO_METHOD *DSO_METHOD_dlfcn(void) | |||
136 | return(&dso_meth_dlfcn); | 116 | return(&dso_meth_dlfcn); |
137 | } | 117 | } |
138 | 118 | ||
139 | /* Prior to using the dlopen() function, we should decide on the flag | ||
140 | * we send. There's a few different ways of doing this and it's a | ||
141 | * messy venn-diagram to match up which platforms support what. So | ||
142 | * as we don't have autoconf yet, I'm implementing a hack that could | ||
143 | * be hacked further relatively easily to deal with cases as we find | ||
144 | * them. Initially this is to cope with OpenBSD. */ | ||
145 | #if defined(__OpenBSD__) || defined(__NetBSD__) | ||
146 | # ifdef DL_LAZY | ||
147 | # define DLOPEN_FLAG DL_LAZY | ||
148 | # else | ||
149 | # ifdef RTLD_NOW | ||
150 | # define DLOPEN_FLAG RTLD_NOW | ||
151 | # else | ||
152 | # define DLOPEN_FLAG 0 | ||
153 | # endif | ||
154 | # endif | ||
155 | #else | ||
156 | # ifdef OPENSSL_SYS_SUNOS | ||
157 | # define DLOPEN_FLAG 1 | ||
158 | # else | ||
159 | # define DLOPEN_FLAG RTLD_NOW /* Hope this works everywhere else */ | ||
160 | # endif | ||
161 | #endif | ||
162 | |||
163 | /* For this DSO_METHOD, our meth_data STACK will contain; | 119 | /* For this DSO_METHOD, our meth_data STACK will contain; |
164 | * (i) the handle (void*) returned from dlopen(). | 120 | * (i) the handle (void*) returned from dlopen(). |
165 | */ | 121 | */ |
@@ -169,7 +125,7 @@ static int dlfcn_load(DSO *dso) | |||
169 | void *ptr = NULL; | 125 | void *ptr = NULL; |
170 | /* See applicable comments in dso_dl.c */ | 126 | /* See applicable comments in dso_dl.c */ |
171 | char *filename = DSO_convert_filename(dso, NULL); | 127 | char *filename = DSO_convert_filename(dso, NULL); |
172 | int flags = DLOPEN_FLAG; | 128 | int flags = RTLD_LAZY; |
173 | 129 | ||
174 | if(filename == NULL) | 130 | if(filename == NULL) |
175 | { | 131 | { |
@@ -177,10 +133,8 @@ static int dlfcn_load(DSO *dso) | |||
177 | goto err; | 133 | goto err; |
178 | } | 134 | } |
179 | 135 | ||
180 | #ifdef RTLD_GLOBAL | ||
181 | if (dso->flags & DSO_FLAG_GLOBAL_SYMBOLS) | 136 | if (dso->flags & DSO_FLAG_GLOBAL_SYMBOLS) |
182 | flags |= RTLD_GLOBAL; | 137 | flags |= RTLD_GLOBAL; |
183 | #endif | ||
184 | ptr = dlopen(filename, flags); | 138 | ptr = dlopen(filename, flags); |
185 | if(ptr == NULL) | 139 | if(ptr == NULL) |
186 | { | 140 | { |
@@ -362,14 +316,8 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1, | |||
362 | return(merged); | 316 | return(merged); |
363 | } | 317 | } |
364 | 318 | ||
365 | #ifdef OPENSSL_SYS_MACOSX | ||
366 | #define DSO_ext ".dylib" | ||
367 | #define DSO_extlen 6 | ||
368 | #else | ||
369 | #define DSO_ext ".so" | 319 | #define DSO_ext ".so" |
370 | #define DSO_extlen 3 | 320 | #define DSO_extlen 3 |
371 | #endif | ||
372 | |||
373 | 321 | ||
374 | static char *dlfcn_name_converter(DSO *dso, const char *filename) | 322 | static char *dlfcn_name_converter(DSO *dso, const char *filename) |
375 | { | 323 | { |
@@ -405,48 +353,8 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename) | |||
405 | return(translated); | 353 | return(translated); |
406 | } | 354 | } |
407 | 355 | ||
408 | #if defined(__sgi) && !defined(__OpenBSD__) | ||
409 | /* | ||
410 | This is a quote from IRIX manual for dladdr(3c): | ||
411 | |||
412 | <dlfcn.h> does not contain a prototype for dladdr or definition of | ||
413 | Dl_info. The #include <dlfcn.h> in the SYNOPSIS line is traditional, | ||
414 | but contains no dladdr prototype and no IRIX library contains an | ||
415 | implementation. Write your own declaration based on the code below. | ||
416 | |||
417 | The following code is dependent on internal interfaces that are not | ||
418 | part of the IRIX compatibility guarantee; however, there is no future | ||
419 | intention to change this interface, so on a practical level, the code | ||
420 | below is safe to use on IRIX. | ||
421 | */ | ||
422 | #include <rld_interface.h> | ||
423 | #ifndef _RLD_INTERFACE_DLFCN_H_DLADDR | ||
424 | #define _RLD_INTERFACE_DLFCN_H_DLADDR | ||
425 | typedef struct Dl_info { | ||
426 | const char * dli_fname; | ||
427 | void * dli_fbase; | ||
428 | const char * dli_sname; | ||
429 | void * dli_saddr; | ||
430 | int dli_version; | ||
431 | int dli_reserved1; | ||
432 | long dli_reserved[4]; | ||
433 | } Dl_info; | ||
434 | #else | ||
435 | typedef struct Dl_info Dl_info; | ||
436 | #endif | ||
437 | #define _RLD_DLADDR 14 | ||
438 | |||
439 | static int dladdr(void *address, Dl_info *dl) | ||
440 | { | ||
441 | void *v; | ||
442 | v = _rld_new_interface(_RLD_DLADDR,address,dl); | ||
443 | return (int)v; | ||
444 | } | ||
445 | #endif /* __sgi */ | ||
446 | |||
447 | static int dlfcn_pathbyaddr(void *addr,char *path,int sz) | 356 | static int dlfcn_pathbyaddr(void *addr,char *path,int sz) |
448 | { | 357 | { |
449 | #ifdef HAVE_DLINFO | ||
450 | Dl_info dli; | 358 | Dl_info dli; |
451 | int len; | 359 | int len; |
452 | 360 | ||
@@ -468,7 +376,6 @@ static int dlfcn_pathbyaddr(void *addr,char *path,int sz) | |||
468 | } | 376 | } |
469 | 377 | ||
470 | ERR_add_error_data(4, "dlfcn_pathbyaddr(): ", dlerror()); | 378 | ERR_add_error_data(4, "dlfcn_pathbyaddr(): ", dlerror()); |
471 | #endif | ||
472 | return -1; | 379 | return -1; |
473 | } | 380 | } |
474 | 381 | ||