Changeset 3811 for trunk


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:
trunk/libc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/include/klibc/backend.h

    r3768 r3811  
    725725 * @{ */
    726726
     727/** Special handle that's returned when passing NULL as library name to
     728 * __libc_Back_ldrOpen. */
     729#define __LIBC_BACK_LDR_GLOBAL  ((void *)(intptr_t)-2)
     730
    727731/**
    728732 * Opens a shared library.
  • trunk/libc/src/kNIX/os2/b_ldrClose.c

    r2929 r3811  
    11/* $Id$ */
    22/** @file
    3  *
    43 * kNIX - dlclose, OS/2.
    5  *
    6  * Copyright (c) 2004-2006 knut st. osmundsen <bird-src-spam@anduin.net>
     4 */
     5
     6/*
     7 * Copyright (c) 2004-2014 knut st. osmundsen <bird-src-spam@anduin.net>
    78 *
    89 *
     
    4445{
    4546    LIBCLOG_ENTER("pvModule=%p\n", pvModule);
    46     FS_VAR();
    47     FS_SAVE_LOAD();
    48     int rc = DosFreeModuleEx((HMODULE)pvModule);
    49     FS_RESTORE();
     47    int rc;
     48    if (pvModule == __LIBC_BACK_LDR_GLOBAL)
     49        rc = NO_ERROR;
     50    else
     51    {
     52        FS_VAR();
     53        FS_SAVE_LOAD();
     54        int rc = DosFreeModuleEx((HMODULE)pvModule);
     55        FS_RESTORE();
     56    }
    5057    if (!rc)
    5158        LIBCLOG_RETURN_INT(rc);
  • trunk/libc/src/kNIX/os2/b_ldrOpen.c

    r3684 r3811  
    11/* $Id$ */
    22/** @file
    3  *
    43 * kNIX - dlopen, OS/2.
    5  *
    6  * Copyright (c) 2004-2006 knut st. osmundsen <bird-src-spam@anduin.net>
     4 */
     5
     6/*
     7 * Copyright (c) 2004-2014 knut st. osmundsen <bird-src-spam@anduin.net>
    78 *
    89 *
     
    4849
    4950    /*
     51     * Sepecial case where we're requested to open the global namespace object
     52     * for the process.
     53     */
     54    if (!pszLibrary)
     55    {
     56        *ppvModule = __LIBC_BACK_LDR_GLOBAL;
     57        LIBCLOG_RETURN_INT(0);
     58    }
     59
     60    /*
    5061     * Resolve the path if one is given.  Ignore failures to resolve the file
    5162     * name is it may lack the extension (I think) - DosLoadModule will fail,
  • trunk/libc/src/kNIX/os2/b_ldrSymbol.c

    r2929 r3811  
    11/* $Id$ */
    22/** @file
    3  *
    43 * kNIX - dlsym, OS/2.
    5  *
    6  * Copyright (c) 2004-2006 knut st. osmundsen <bird-src-spam@anduin.net>
     4 */
     5
     6/*
     7 * Copyright (c) 2004-2014 knut st. osmundsen <bird-src-spam@anduin.net>
    78 *
    89 *
     
    4243    LIBCLOG_ENTER("pvHandle=%p pszSymbol=%p:{%s} ppfn=%p\n", pvHandle,
    4344                  (void *)pszSymbol, (uintptr_t)pszSymbol >= 10000 ? pszSymbol : "<ordinal>", (void *)ppfn);
    44     PFN     pfn;
    45     FS_VAR();
    46     FS_SAVE_LOAD();
    4745    int rc;
    48     if ((uintptr_t)pszSymbol < 10000)
    49         rc = DosQueryProcAddr((HMODULE)pvHandle, (uintptr_t)pszSymbol, NULL, &pfn);
     46    if (pvHandle == __LIBC_BACK_LDR_GLOBAL)
     47    {
     48        /* Pretending there aren't anything in the global name space for now.
     49           Later we could probably do a QS_MTE assisted scan of loaded modules
     50           and what not.  */
     51        rc = ERROR_PROC_NOT_FOUND;
     52    }
    5053    else
    51         rc = DosQueryProcAddr((HMODULE)pvHandle, 0, (PCSZ)pszSymbol, &pfn);
    52     FS_RESTORE();
    53     if (!rc)
    5454    {
    55         *ppfn = (void *)pfn;
    56         LIBCLOG_RETURN_MSG(0, "ret 0 *ppfn=%p\n", (void *)pfn);
     55        PFN     pfn;
     56        FS_VAR();
     57        FS_SAVE_LOAD();
     58        if ((uintptr_t)pszSymbol < 10000)
     59            rc = DosQueryProcAddr((HMODULE)pvHandle, (uintptr_t)pszSymbol, NULL, &pfn);
     60        else
     61            rc = DosQueryProcAddr((HMODULE)pvHandle, 0, (PCSZ)pszSymbol, &pfn);
     62        FS_RESTORE();
     63        if (!rc)
     64        {
     65            *ppfn = (void *)pfn;
     66            LIBCLOG_RETURN_MSG(0, "ret 0 *ppfn=%p\n", (void *)pfn);
     67        }
    5768    }
    5869    LIBCLOG_ERROR_RETURN_INT(rc);
Note: See TracChangeset for help on using the changeset viewer.