Example #1
0
/* Make
 */
static
rc_t KSymAddrMake ( KSymAddr **symp,
    const KDylib *lib, const char *name )
{
    if ( lib -> handle )
    {
        void *addr = dlsym ( lib -> handle, name );
        const char *estr = dlerror();
        
        if ( addr != NULL || estr == NULL )
        {
            KSymAddr *sym = malloc ( sizeof * sym );
            if ( sym == NULL )
                return RC ( rcFS, rcDylib, rcConstructing, rcMemory, rcExhausted );

            sym -> lib = KDylibAttach ( lib );
            sym -> addr = addr;
            KRefcountInit ( & sym -> refcount, 1, "KSymAddr", "make", name );
            * symp = sym;
            return 0;
        }
    }
    * symp = NULL;
    return RC ( rcFS, rcDylib, rcSelecting, rcName, rcNotFound );
}
Example #2
0
/* Make
 */
static
rc_t KSymAddrMake ( KSymAddr **symp,
    const KDylib *lib, const char *name )
{
    void *addr = dlsym ( lib -> handle, name );
    const char *estr = dlerror();

    if ( addr == NULL  &&  builtins != NULL )
    {
        String   builtin_name;
        KSymbol *builtin_sym;
        StringInitCString ( & builtin_name, name );
        builtin_sym = KSymTableFind ( builtins, & builtin_name );
        if ( builtin_sym != NULL ) {
            addr = builtin_sym -> u . obj;
        }
    }
    
    if ( addr != NULL || estr == NULL )
    {
        KSymAddr *sym = malloc ( sizeof * sym );
        if ( sym == NULL )
            return RC ( rcFS, rcDylib, rcConstructing, rcMemory, rcExhausted );

        sym -> lib = KDylibAttach ( lib );
        sym -> addr = addr;
        KRefcountInit ( & sym -> refcount, 1, "KSymAddr", "make", name );
        * symp = sym;
        return 0;
    }

    * symp = NULL;
    return RC ( rcFS, rcDylib, rcSelecting, rcName, rcNotFound );
}
Example #3
0
/* Make
 */
static
rc_t KSymAddrMake ( KSymAddr **symp,
    const KDylib *lib, const char *name )
{
    FARPROC addr = GetProcAddress ( lib -> handle, name );
    if ( addr != NULL )
    {
        KSymAddr *sym = malloc ( sizeof * sym );
        if ( sym == NULL )
            return RC ( rcFS, rcDylib, rcConstructing, rcMemory, rcExhausted );

        sym -> lib = KDylibAttach ( lib );
        sym -> addr = (void *)addr;
        KRefcountInit ( & sym -> refcount, 1, "KSymAddr", "make", name );
        * symp = sym;
        return 0;
    }

    * symp = NULL;
    return RC ( rcFS, rcDylib, rcSelecting, rcName, rcNotFound );
}