MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / dlsymIntern

Function dlsymIntern

tests/licensedcode/data/perf/udll.cxx:246–287  ·  view source on GitHub ↗

dlsymIntern is used by dlsym to find the symbol */

Source from the content-addressed store, hash-verified

244
245/* dlsymIntern is used by dlsym to find the symbol */
246static void *dlsymIntern(void *handle, const char *symbol)
247{
248 NSSymbol *nssym = 0;
249 /* If the handle is -1, if is the app global context */
250 if (handle == (void *)-1)
251 {
252 /* Global context, use NSLookupAndBindSymbol */
253 if (NSIsSymbolNameDefined(symbol))
254 {
255 nssym = NSLookupAndBindSymbol(symbol);
256 }
257
258 }
259 /* Now see if the handle is a struch mach_header* or not, use NSLookupSymbol in image
260 for libraries, and NSLookupSymbolInModule for bundles */
261 else
262 {
263 /* Check for both possible magic numbers depending on x86/ppc byte order */
264 if ((((struct mach_header *)handle)->magic == MH_MAGIC) ||
265 (((struct mach_header *)handle)->magic == MH_CIGAM))
266 {
267 if (NSIsSymbolNameDefinedInImage((struct mach_header *)handle, symbol))
268 {
269 nssym = NSLookupSymbolInImage((struct mach_header *)handle,
270 symbol,
271 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
272 | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
273 }
274
275 }
276 else
277 {
278 nssym = NSLookupSymbolInModule(handle, symbol);
279 }
280 }
281 if (!nssym)
282 {
283 error(0, "Symbol \"%s\" Not found", symbol);
284 return NULL;
285 }
286 return NSAddressOfSymbol(nssym);
287}
288
289static const char *dlerror(void)
290{

Callers 1

dlsymFunction · 0.85

Calls 1

errorFunction · 0.70

Tested by

no test coverage detected