-rw-r--r-- | library/qlibrary_unix.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/qlibrary_unix.cpp b/library/qlibrary_unix.cpp index 0229b7b..ff69286 100644 --- a/library/qlibrary_unix.cpp +++ b/library/qlibrary_unix.cpp | |||
@@ -68,176 +68,176 @@ void* QLibraryPrivate::resolveSymbol( const char* symbol ) | |||
68 | 68 | ||
69 | void* address = 0; | 69 | void* address = 0; |
70 | if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, address ) < 0 ) { | 70 | if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, address ) < 0 ) { |
71 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 71 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
72 | qDebug( "Couldn't resolve symbol \"%s\"", symbol ); | 72 | qDebug( "Couldn't resolve symbol \"%s\"", symbol ); |
73 | #endif | 73 | #endif |
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | return address; | 76 | return address; |
77 | } | 77 | } |
78 | 78 | ||
79 | #elif defined(_NULL_LIB_) | 79 | #elif defined(_NULL_LIB_) |
80 | 80 | ||
81 | bool QLibraryPrivate::loadLibrary() | 81 | bool QLibraryPrivate::loadLibrary() |
82 | { | 82 | { |
83 | //qDebug("QLibraryPrivate::loadLibrary\n"); | 83 | //qDebug("QLibraryPrivate::loadLibrary\n"); |
84 | return FALSE; | 84 | return FALSE; |
85 | } | 85 | } |
86 | bool QLibraryPrivate::freeLibrary() | 86 | bool QLibraryPrivate::freeLibrary() |
87 | { | 87 | { |
88 | //qDebug("QLibraryPrivate::freeLibrary\n"); | 88 | //qDebug("QLibraryPrivate::freeLibrary\n"); |
89 | return FALSE; | 89 | return FALSE; |
90 | } | 90 | } |
91 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) | 91 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) |
92 | { | 92 | { |
93 | //qDebug("QLibraryPrivate::resolveSymbol\n"); | 93 | //qDebug("QLibraryPrivate::resolveSymbol\n"); |
94 | return FALSE; | 94 | return FALSE; |
95 | } | 95 | } |
96 | 96 | ||
97 | #elif defined(Q_OS_MACX) | 97 | #elif defined(Q_OS_MACX) |
98 | 98 | ||
99 | #define ENUM_DYLD_BOOL | 99 | #define ENUM_DYLD_BOOL |
100 | enum DYLD_BOOL { | 100 | enum DYLD_BOOL { |
101 | DYLD_FALSE, | 101 | DYLD_FALSE, |
102 | DYLD_TRUE | 102 | DYLD_TRUE |
103 | }; | 103 | }; |
104 | #include <mach-o/dyld.h> | 104 | #include <mach-o/dyld.h> |
105 | typedef struct { | 105 | typedef struct { |
106 | NSObjectFileImage img; | 106 | NSObjectFileImage img; |
107 | NSModule mod; | 107 | NSModule mod; |
108 | } DyldLibDesc; | 108 | } DyldLibDesc; |
109 | 109 | ||
110 | bool QLibraryPrivate::loadLibrary() | 110 | bool QLibraryPrivate::loadLibrary() |
111 | { | 111 | { |
112 | // qDebug("QLibraryPrivate::loadLibrary\n"); | 112 | // qDebug("QLibraryPrivate::loadLibrary\n"); |
113 | // return FALSE; | 113 | // return FALSE; |
114 | if ( pHnd ) | 114 | if ( pHnd ) |
115 | return TRUE; | 115 | return TRUE; |
116 | 116 | ||
117 | QString filename = library->library(); | 117 | QString filename = library->library(); |
118 | 118 | ||
119 | NSObjectFileImage img = 0; | 119 | NSObjectFileImage img = 0; |
120 | NSModule mod = 0; | 120 | NSModule mod = 0; |
121 | NSObjectFileImageReturnCode ret = NSCreateObjectFileImageFromFile( filename.latin1() , &img ); | 121 | NSObjectFileImageReturnCode ret = NSCreateObjectFileImageFromFile( filename.latin1() , &img ); |
122 | if ( ret != NSObjectFileImageSuccess ) { | 122 | if ( ret != NSObjectFileImageSuccess ) { |
123 | qWarning( "Error in NSCreateObjectFileImageFromFile(): %d; Filename: %s", ret, filename.latin1() ); | 123 | qWarning( "Error in NSCreateObjectFileImageFromFile(): %d; Filename: %s", ret, filename.latin1() ); |
124 | if (ret == NSObjectFileImageAccess) { | 124 | if (ret == NSObjectFileImageAccess) { |
125 | qWarning ("(NSObjectFileImageAccess)" ); | 125 | qWarning ("(NSObjectFileImageAccess)" ); |
126 | } | 126 | } |
127 | } else { | 127 | } else { |
128 | mod = NSLinkModule(img, filename.latin1(), NSLINKMODULE_OPTION_BINDNOW | | 128 | mod = NSLinkModule(img, filename.latin1(), NSLINKMODULE_OPTION_BINDNOW | |
129 | NSLINKMODULE_OPTION_PRIVATE | | 129 | NSLINKMODULE_OPTION_PRIVATE | |
130 | NSLINKMODULE_OPTION_RETURN_ON_ERROR); | 130 | NSLINKMODULE_OPTION_RETURN_ON_ERROR); |
131 | if (mod == 0) { | 131 | if (mod == 0) { |
132 | qWarning( "Error in NSLinkModule()" ); | 132 | qWarning( "Error in NSLinkModule()" ); |
133 | NSDestroyObjectFileImage(img); | 133 | NSDestroyObjectFileImage(img); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | DyldLibDesc* desc = 0; | 136 | DyldLibDesc* desc = 0; |
137 | if (img != 0 && mod != 0) { | 137 | if (img != 0 && mod != 0) { |
138 | desc = new DyldLibDesc; | 138 | desc = new DyldLibDesc; |
139 | desc->img = img; | 139 | desc->img = img; |
140 | desc->mod = mod; | 140 | desc->mod = mod; |
141 | } | 141 | } |
142 | pHnd = desc; | 142 | pHnd = desc; |
143 | return pHnd != 0; | 143 | return pHnd != 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | bool QLibraryPrivate::freeLibrary() | 146 | bool QLibraryPrivate::freeLibrary() |
147 | { | 147 | { |
148 | //qDebug("QLibraryPrivate::freeLibrary\n"); | 148 | //qDebug("QLibraryPrivate::freeLibrary\n"); |
149 | //return FALSE; | 149 | //return FALSE; |
150 | if ( !pHnd ) | 150 | if ( !pHnd ) |
151 | return TRUE; | 151 | return TRUE; |
152 | 152 | ||
153 | DyldLibDesc* desc = (DyldLibDesc*) pHnd; | 153 | DyldLibDesc* desc = (DyldLibDesc*) pHnd; |
154 | NSModule mod = desc->mod; | 154 | NSModule mod = desc->mod; |
155 | NSObjectFileImage img = desc->img; | 155 | NSObjectFileImage img = desc->img; |
156 | DYLD_BOOL success = NSUnLinkModule(mod, NSUNLINKMODULE_OPTION_NONE); | 156 | DYLD_BOOL success = NSUnLinkModule(mod, NSUNLINKMODULE_OPTION_NONE); |
157 | if ( success ) { | 157 | if ( success ) { |
158 | NSDestroyObjectFileImage(img); | 158 | NSDestroyObjectFileImage(img); |
159 | delete desc; | 159 | delete desc; |
160 | pHnd = 0; | 160 | pHnd = 0; |
161 | } | 161 | } |
162 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 162 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
163 | else { | 163 | else { |
164 | qWarning( "Error in NSUnLinkModule(): %d", ret ); | 164 | qWarning( "Error in NSUnLinkModule()" ); |
165 | } | 165 | } |
166 | #endif | 166 | #endif |
167 | return pHnd == 0; | 167 | return pHnd == 0; |
168 | } | 168 | } |
169 | 169 | ||
170 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) | 170 | void* QLibraryPrivate::resolveSymbol( const char* symbol ) |
171 | { | 171 | { |
172 | //qDebug("QLibraryPrivate::resolveSymbol\n"); | 172 | //qDebug("QLibraryPrivate::resolveSymbol\n"); |
173 | //return FALSE; | 173 | //return FALSE; |
174 | if ( !pHnd ) | 174 | if ( !pHnd ) |
175 | return 0; | 175 | return 0; |
176 | 176 | ||
177 | DyldLibDesc* desc = (DyldLibDesc*) pHnd; | 177 | DyldLibDesc* desc = (DyldLibDesc*) pHnd; |
178 | NSSymbol sym = NSLookupSymbolInModule(desc->mod, symbol); | 178 | NSSymbol sym = NSLookupSymbolInModule(desc->mod, symbol); |
179 | void* address = 0; | 179 | void* address = 0; |
180 | if (sym != 0) { | 180 | if (sym != 0) { |
181 | address = NSAddressOfSymbol(sym); | 181 | address = NSAddressOfSymbol(sym); |
182 | } | 182 | } |
183 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 183 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
184 | if ( address == 0 ) | 184 | if ( address == 0 ) |
185 | qWarning( "Cannot find symbol: %s", symbol ); | 185 | qWarning( "Cannot find symbol: %s", symbol ); |
186 | #endif | 186 | #endif |
187 | return address; | 187 | return address; |
188 | } | 188 | } |
189 | 189 | ||
190 | #else | 190 | #else |
191 | // Something else, assuming POSIX | 191 | // Something else, assuming POSIX |
192 | #include <dlfcn.h> | 192 | #include <dlfcn.h> |
193 | 193 | ||
194 | bool QLibraryPrivate::loadLibrary() | 194 | bool QLibraryPrivate::loadLibrary() |
195 | { | 195 | { |
196 | if ( pHnd ) | 196 | if ( pHnd ) |
197 | return TRUE; | 197 | return TRUE; |
198 | 198 | ||
199 | QString filename = library->library(); | 199 | QString filename = library->library(); |
200 | 200 | ||
201 | pHnd = dlopen( filename.latin1() , RTLD_LAZY ); | 201 | pHnd = dlopen( filename.latin1() , RTLD_LAZY ); |
202 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 202 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
203 | if ( !pHnd ) | 203 | if ( !pHnd ) |
204 | qWarning( "%s", dlerror() ); | 204 | qWarning( "%s", dlerror() ); |
205 | #endif | 205 | #endif |
206 | return pHnd != 0; | 206 | return pHnd != 0; |
207 | } | 207 | } |
208 | 208 | ||
209 | bool QLibraryPrivate::freeLibrary() | 209 | bool QLibraryPrivate::freeLibrary() |
210 | { | 210 | { |
211 | if ( !pHnd ) | 211 | if ( !pHnd ) |
212 | return TRUE; | 212 | return TRUE; |
213 | 213 | ||
214 | int ec = dlclose( pHnd ); | 214 | int ec = dlclose( pHnd ); |
215 | if ( !ec ) | 215 | if ( !ec ) |
216 | pHnd = 0; | 216 | pHnd = 0; |
217 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 217 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
218 | else { | 218 | else { |
219 | const char* error = dlerror(); | 219 | const char* error = dlerror(); |
220 | if ( error ) | 220 | if ( error ) |
221 | qWarning( "%s", error ); | 221 | qWarning( "%s", error ); |
222 | } | 222 | } |
223 | #endif | 223 | #endif |
224 | return pHnd == 0; | 224 | return pHnd == 0; |
225 | } | 225 | } |
226 | 226 | ||
227 | void* QLibraryPrivate::resolveSymbol( const char* f ) | 227 | void* QLibraryPrivate::resolveSymbol( const char* f ) |
228 | { | 228 | { |
229 | if ( !pHnd ) | 229 | if ( !pHnd ) |
230 | return 0; | 230 | return 0; |
231 | 231 | ||
232 | void* address = dlsym( pHnd, f ); | 232 | void* address = dlsym( pHnd, f ); |
233 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) | 233 | #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) |
234 | const char* error = dlerror(); | 234 | const char* error = dlerror(); |
235 | if ( error ) | 235 | if ( error ) |
236 | qWarning( "%s", error ); | 236 | qWarning( "%s", error ); |
237 | #endif | 237 | #endif |
238 | return address; | 238 | return address; |
239 | } | 239 | } |
240 | 240 | ||
241 | #endif // POSIX | 241 | #endif // POSIX |
242 | 242 | ||
243 | #endif // QT_NO_COMPONENT | 243 | #endif // QT_NO_COMPONENT |