Lines 70-78
Link Here
|
70 |
#include <secitem.h> |
70 |
#include <secitem.h> |
71 |
#include <blapi.h> |
71 |
#include <blapi.h> |
72 |
|
72 |
|
73 |
#define FREEBL_NO_WEAK 1 |
73 |
#ifdef __sgi |
|
|
74 |
# include <rld_interface.h> |
75 |
# ifndef _RLD_INTERFACE_DLFCN_H_DLADDR |
76 |
# define _RLD_INTERFACE_DLFCN_H_DLADDR |
77 |
typedef struct Dl_info { |
78 |
const char * dli_fname; |
79 |
void * dli_fbase; |
80 |
const char * dli_sname; |
81 |
void * dli_saddr; |
82 |
int dli_version; |
83 |
int dli_reserved1; |
84 |
long dli_reserved[4]; |
85 |
} Dl_info; |
86 |
# endif |
87 |
# define _RLD_DLADDR 14 |
88 |
int dladdr(void *address, Dl_info *dl); |
89 |
|
90 |
int dladdr(void *address, Dl_info *dl) |
91 |
{ |
92 |
void *v; |
93 |
v = _rld_new_interface(_RLD_DLADDR,address,dl); |
94 |
return (int)v; |
95 |
} |
96 |
#endif |
74 |
|
97 |
|
75 |
#define WEAK __attribute__((weak)) |
98 |
#define FREEBL_NO_WEAK 1 |
76 |
|
99 |
|
77 |
#ifdef FREEBL_NO_WEAK |
100 |
#ifdef FREEBL_NO_WEAK |
78 |
|
101 |
|
Lines 93-109
Link Here
|
93 |
static type_##fn ptr_##fn = NULL |
116 |
static type_##fn ptr_##fn = NULL |
94 |
|
117 |
|
95 |
#define STUB_SAFE_CALL0(fn) \ |
118 |
#define STUB_SAFE_CALL0(fn) \ |
96 |
if (ptr_##fn) { return ptr_##fn(); } |
119 |
if (ptr_##fn) { ptr_##fn(); } |
97 |
#define STUB_SAFE_CALL1(fn,a1) \ |
120 |
#define STUB_SAFE_CALL1(fn,a1) \ |
98 |
if (ptr_##fn) { return ptr_##fn(a1); } |
121 |
if (ptr_##fn) { ptr_##fn(a1); } |
99 |
#define STUB_SAFE_CALL2(fn,a1,a2) \ |
122 |
#define STUB_SAFE_CALL2(fn,a1,a2) \ |
100 |
if (ptr_##fn) { return ptr_##fn(a1,a2); } |
123 |
if (ptr_##fn) { ptr_##fn(a1,a2); } |
101 |
#define STUB_SAFE_CALL3(fn,a1,a2,a3) \ |
124 |
#define STUB_SAFE_CALL3(fn,a1,a2,a3) \ |
102 |
if (ptr_##fn) { return ptr_##fn(a1,a2,a3); } |
125 |
if (ptr_##fn) { ptr_##fn(a1,a2,a3); } |
103 |
#define STUB_SAFE_CALL4(fn,a1,a2,a3,a4) \ |
126 |
#define STUB_SAFE_CALL4(fn,a1,a2,a3,a4) \ |
104 |
if (ptr_##fn) { return ptr_##fn(a1,a2,a3,a4); } |
127 |
if (ptr_##fn) { ptr_##fn(a1,a2,a3,a4); } |
105 |
#define STUB_SAFE_CALL6(fn,a1,a2,a3,a4,a5,a6) \ |
128 |
#define STUB_SAFE_CALL6(fn,a1,a2,a3,a4,a5,a6) \ |
106 |
if (ptr_##fn) { return ptr_##fn(a1,a2,a3,a4,a5,a6); } |
129 |
if (ptr_##fn) { ptr_##fn(a1,a2,a3,a4,a5,a6); } |
107 |
|
130 |
|
108 |
#define STUB_FETCH_FUNCTION(fn) \ |
131 |
#define STUB_FETCH_FUNCTION(fn) \ |
109 |
ptr_##fn = (type_##fn) dlsym(lib,#fn); \ |
132 |
ptr_##fn = (type_##fn) dlsym(lib,#fn); \ |
Lines 118-123
Link Here
|
118 |
* libutil will not resolve these symbols. |
141 |
* libutil will not resolve these symbols. |
119 |
*/ |
142 |
*/ |
120 |
|
143 |
|
|
|
144 |
#define WEAK __attribute__((weak)) |
145 |
|
121 |
#define STUB_DECLARE(ret, fn, args) \ |
146 |
#define STUB_DECLARE(ret, fn, args) \ |
122 |
WEAK extern ret fn args |
147 |
WEAK extern ret fn args |
123 |
|
148 |
|
Lines 200-206
extern void
Link Here
|
200 |
PORT_Free_stub(void *ptr) |
225 |
PORT_Free_stub(void *ptr) |
201 |
{ |
226 |
{ |
202 |
STUB_SAFE_CALL1(PORT_Free_Util, ptr); |
227 |
STUB_SAFE_CALL1(PORT_Free_Util, ptr); |
203 |
return free(ptr); |
228 |
free(ptr); |
204 |
} |
229 |
} |
205 |
|
230 |
|
206 |
extern void * |
231 |
extern void * |
Lines 220-233
PORT_ZFree_stub(void *ptr, size_t len)
Link Here
|
220 |
{ |
245 |
{ |
221 |
STUB_SAFE_CALL2(PORT_ZFree_Util, ptr, len); |
246 |
STUB_SAFE_CALL2(PORT_ZFree_Util, ptr, len); |
222 |
memset(ptr, 0, len); |
247 |
memset(ptr, 0, len); |
223 |
return free(ptr); |
248 |
free(ptr); |
224 |
} |
249 |
} |
225 |
|
250 |
|
226 |
extern void |
251 |
extern void |
227 |
PR_Free_stub(void *ptr) |
252 |
PR_Free_stub(void *ptr) |
228 |
{ |
253 |
{ |
229 |
STUB_SAFE_CALL1(PR_Free, ptr); |
254 |
STUB_SAFE_CALL1(PR_Free, ptr); |
230 |
return free(ptr); |
255 |
free(ptr); |
231 |
} |
256 |
} |
232 |
|
257 |
|
233 |
/* |
258 |
/* |
Lines 530-536
freebl_InitNSSUtil(void *lib)
Link Here
|
530 |
* fetch the library if it's loaded. For NSS it should already be loaded |
555 |
* fetch the library if it's loaded. For NSS it should already be loaded |
531 |
*/ |
556 |
*/ |
532 |
#define freebl_getLibrary(libName) \ |
557 |
#define freebl_getLibrary(libName) \ |
533 |
dlopen (libName, RTLD_LAZY|RTLD_NOLOAD) |
558 |
dlopen (libName, RTLD_LAZY) |
534 |
|
559 |
|
535 |
#define freebl_releaseLibrary(lib) \ |
560 |
#define freebl_releaseLibrary(lib) \ |
536 |
if (lib) dlclose(lib) |
561 |
if (lib) dlclose(lib) |
Lines 538-544
freebl_InitNSSUtil(void *lib)
Link Here
|
538 |
static void * FREEBLnsprGlobalLib = NULL; |
563 |
static void * FREEBLnsprGlobalLib = NULL; |
539 |
static void * FREEBLnssutilGlobalLib = NULL; |
564 |
static void * FREEBLnssutilGlobalLib = NULL; |
540 |
|
565 |
|
541 |
void __attribute ((destructor)) FREEBL_unload() |
566 |
void FREEBL_unload() |
542 |
{ |
567 |
{ |
543 |
freebl_releaseLibrary(FREEBLnsprGlobalLib); |
568 |
freebl_releaseLibrary(FREEBLnsprGlobalLib); |
544 |
freebl_releaseLibrary(FREEBLnssutilGlobalLib); |
569 |
freebl_releaseLibrary(FREEBLnssutilGlobalLib); |