Changeset 3811 for branches/libc-0.6/src


Ignore:
Timestamp:
Feb 16, 2014, 11:56:50 PM (11 years ago)
Author:
bird
Message:

libc_Back_ldr*: Allow opening of the NULL module that represents the global name space, though don't (yet) resolve any symbols within it. The special loader handle LIBC_BACK_LDR_GLOBAL (-2) represents this fake module. Fixes #264.

Location:
branches/libc-0.6/src/emx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/include/InnoTekLIBC/backend.h

    r3771 r3811  
    542542/** @defgroup __libc_Back_ldr   LIBC Backend - Loader
    543543 * @{ */
     544
     545/** Special handle that's returned when passing NULL as library name to
     546 * __libc_Back_ldrOpen. */
     547#define __LIBC_BACK_LDR_GLOBAL  ((void *)(intptr_t)-2)
    544548
    545549/**
  • branches/libc-0.6/src/emx/src/lib/sys/b_ldrClose.c

    r2254 r3811  
    44 * LIBC SYS Backend - dlclose.
    55 *
    6  * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>
     6 * Copyright (c) 2004-2014 knut st. osmundsen <bird@innotek.de>
    77 *
    88 *
     
    4949{
    5050    LIBCLOG_ENTER("pvModule=%p\n", pvModule);
    51     FS_VAR();
    52     FS_SAVE_LOAD();
    53     int rc = DosFreeModuleEx((HMODULE)pvModule);
    54     FS_RESTORE();
     51    int rc;
     52    if (pvModule == __LIBC_BACK_LDR_GLOBAL)
     53        rc = NO_ERROR;
     54    else
     55    {
     56        FS_VAR();
     57        FS_SAVE_LOAD();
     58        int rc = DosFreeModuleEx((HMODULE)pvModule);
     59        FS_RESTORE();
     60    }
    5561    if (!rc)
    5662        LIBCLOG_RETURN_INT(rc);
  • branches/libc-0.6/src/emx/src/lib/sys/b_ldrOpen.c

    r3692 r3811  
    44 * LIBC SYS Backend - dlopen.
    55 *
    6  * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>
     6 * Copyright (c) 2004-2014 knut st. osmundsen <bird@innotek.de>
    77 *
    88 *
     
    6161
    6262    /*
     63     * Sepecial case where we're requested to open the global namespace object
     64     * for the process.
     65     */
     66    if (!pszLibrary)
     67    {
     68        *ppvModule = __LIBC_BACK_LDR_GLOBAL;
     69        LIBCLOG_RETURN_INT(0);
     70    }
     71
     72    /*
    6373     * Resolve the path if one is given.  Ignore failures to resolve the file
    6474     * name is it may lack the extension (I think) - DosLoadModule will fail,
  • branches/libc-0.6/src/emx/src/lib/sys/b_ldrSymbol.c

    r2254 r3811  
    44 * LIBC SYS Backend - dlsym.
    55 *
    6  * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>
     6 * Copyright (c) 2004-2014 knut st. osmundsen <bird@innotek.de>
    77 *
    88 *
     
    5151    LIBCLOG_ENTER("pvHandle=%p pszSymbol=%p:{%s} ppfn=%p\n", pvHandle,
    5252                  (void *)pszSymbol, (uintptr_t)pszSymbol >= 10000 ? pszSymbol : "<ordinal>", (void *)ppfn);
    53     PFN     pfn;
    54     FS_VAR();
    55     FS_SAVE_LOAD();
    5653    int rc;
    57     if ((uintptr_t)pszSymbol < 10000)
    58         rc = DosQueryProcAddr((HMODULE)pvHandle, (uintptr_t)pszSymbol, NULL, &pfn);
     54    if (pvHandle == __LIBC_BACK_LDR_GLOBAL)
     55    {
     56        /* Pretending there aren't anything in the global name space for now.
     57           Later we could probably do a QS_MTE assisted scan of loaded modules
     58           and what not.  */
     59        rc = ERROR_PROC_NOT_FOUND;
     60    }
    5961    else
    60         rc = DosQueryProcAddr((HMODULE)pvHandle, 0, (PCSZ)pszSymbol, &pfn);
    61     FS_RESTORE();
    62     if (!rc)
    6362    {
    64         *ppfn = (void *)pfn;
    65         LIBCLOG_RETURN_MSG(0, "ret 0 *ppfn=%p\n", (void *)pfn);
     63        PFN     pfn;
     64        FS_VAR();
     65        FS_SAVE_LOAD();
     66        if ((uintptr_t)pszSymbol < 10000)
     67            rc = DosQueryProcAddr((HMODULE)pvHandle, (uintptr_t)pszSymbol, NULL, &pfn);
     68        else
     69            rc = DosQueryProcAddr((HMODULE)pvHandle, 0, (PCSZ)pszSymbol, &pfn);
     70        FS_RESTORE();
     71        if (!rc)
     72        {
     73            *ppfn = (void *)pfn;
     74            LIBCLOG_RETURN_MSG(0, "ret 0 *ppfn=%p\n", (void *)pfn);
     75        }
    6676    }
    6777    LIBCLOG_ERROR_RETURN_INT(rc);
Note: See TracChangeset for help on using the changeset viewer.