if (lm) { PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (init)", lm->name)); }
void _PR_InitLinker(void){#if !defined(XP_MAC) && !defined(XP_BEOS)    PRLibrary *lm;#endif#if defined(XP_UNIX)    void *h;#endif    if (!pr_linker_lock) {        pr_linker_lock = PR_NewNamedMonitor("linker-lock");    }    PR_EnterMonitor(pr_linker_lock);#if defined(XP_PC)    lm = PR_NEWZAP(PRLibrary);    lm->name = strdup("Executable");        /*         ** In WIN32, GetProcAddress(...) expects a module handle in order to        ** get exported symbols from the executable...        **        ** However, in WIN16 this is accomplished by passing NULL to         ** GetProcAddress(...)        */#if defined(_WIN32)        lm->dlh = GetModuleHandle(NULL);#else        lm->dlh = (HINSTANCE)NULL;#endif /* ! _WIN32 */    lm->refCount    = 1;    lm->staticTable = NULL;    pr_exe_loadmap  = lm;    pr_loadmap      = lm;#elif defined(XP_UNIX)#ifdef HAVE_DLL#ifdef USE_DLFCN    h = dlopen(0, RTLD_LAZY);    if (!h) {        char *error;                DLLErrorInternal(_MD_ERRNO());        error = (char*)PR_MALLOC(PR_GetErrorTextLength());        (void) PR_GetErrorText(error);        fprintf(stderr, "failed to initialize shared libraries [%s]\n",            error);        PR_DELETE(error);        abort();/* XXX */    }#elif defined(USE_HPSHL)    h = NULL;    /* don't abort with this NULL */#elif defined(USE_MACH_DYLD)    h = NULL; /* XXXX  toshok */#else#error no dll strategy#endif /* USE_DLFCN */    lm = PR_NEWZAP(PRLibrary);    if (lm) {        lm->name = strdup("a.out");        lm->refCount = 1;        lm->dlh = h;        lm->staticTable = NULL;    }    pr_exe_loadmap = lm;    pr_loadmap = lm;#endif /* HAVE_DLL */#endif /* XP_UNIX */#if !defined(XP_MAC) && !defined(XP_BEOS)    PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (init)", lm?lm->name:"NULL"));#endif    PR_ExitMonitor(pr_linker_lock);}