VirtualBox

Changeset 37573 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 21, 2011 11:40:11 AM (14 years ago)
Author:
vboxsync
Message:

iprt: More kernel symbol resolving on darwin.

Location:
trunk/src/VBox/Runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/mach_kernel-r0drv-darwin.cpp

    r37569 r37573  
    3838RT_C_DECLS_END
    3939#endif
    40 #include "../../include/internal/iprt.h"
     40
     41#include "internal/iprt.h"
     42#include <iprt/darwin/machkernel.h>
    4143
    4244#ifdef IN_RING0  /* till RTFILE is changed in types.h */
     
    5759#include <iprt/mem.h>
    5860#include <iprt/string.h>
    59 #include "../../include/internal/ldrMach-O.h"
     61#include "internal/ldrMach-O.h"
    6062
    6163/** @def MY_CPU_TYPE
     
    122124 * and successfully resolving their addresses.
    123125 */
    124 typedef struct RTR0DARWINKERNEL
     126typedef struct RTR0MACHKERNELINT
    125127{
    126128    /** @name Result.
     
    162164    /** Buffer space. */
    163165    char                abBuf[_4K];
    164 } RTR0DARWINKERNEL;
    165 typedef RTR0DARWINKERNEL *PRTR0DARWINKERNEL;
     166} RTR0MACHKERNELINT;
    166167
    167168
     
    170171*******************************************************************************/
    171172#ifdef DEBUG
    172 static bool g_fBreakpointOnError = true;
     173static bool g_fBreakpointOnError = false;
    173174#endif
    174175
     
    315316
    316317/**
    317  * Frees up the internal scratch data when done looking up symbols.
    318  *
    319  * @param   pKernel             The internal scratch data.
    320  */
    321 static void rtR0DarwinMachKernelClose(PRTR0DARWINKERNEL pKernel)
    322 {
    323     RTMemFree(pKernel->pachStrTab);
    324     pKernel->pachStrTab = NULL;
    325 
    326     RTMemFree(pKernel->paSyms);
    327     pKernel->paSyms = NULL;
    328 
    329     RTMemFree(pKernel);
    330 }
    331 
    332 
    333 /**
    334318 * Close and free up resources we no longer needs.
    335319 *
    336  * @param   pKernel             The internal scratch data.
     320 * @param   pThis               The internal scratch data.
    337321 */
    338 static void rtR0DarwinMachKernelLoadDone(PRTR0DARWINKERNEL pKernel)
    339 {
    340     RTFileClose(pKernel->hFile);
    341     pKernel->hFile = NIL_RTFILE;
    342 
    343     RTMemFree(pKernel->pLoadCmds);
    344     pKernel->pLoadCmds = NULL;
    345     memset((void *)&pKernel->apSections[0], 0, sizeof(pKernel->apSections[0]) * MACHO_MAX_SECT);
     322static void rtR0MachKernelLoadDone(RTR0MACHKERNELINT *pThis)
     323{
     324    RTFileClose(pThis->hFile);
     325    pThis->hFile = NIL_RTFILE;
     326
     327    RTMemFree(pThis->pLoadCmds);
     328    pThis->pLoadCmds = NULL;
     329    memset((void *)&pThis->apSections[0], 0, sizeof(pThis->apSections[0]) * MACHO_MAX_SECT);
    346330}
    347331
     
    352336 *
    353337 * @returns The symbol address on success, 0 on failure.
    354  * @param   pKernel             The internal scratch data.
     338 * @param   pThis               The internal scratch data.
    355339 * @param   pszSymbol           The symbol to resolve.  Automatically prefixed
    356340 *                              with an underscore.
    357341 */
    358 static uintptr_t rtR0DarwinMachKernelLookup(PRTR0DARWINKERNEL pKernel, const char *pszSymbol)
    359 {
    360     uint32_t const  cSyms = pKernel->cSyms;
    361     MY_NLIST const *pSym = pKernel->paSyms;
     342static uintptr_t rtR0MachKernelLookup(RTR0MACHKERNELINT *pThis, const char *pszSymbol)
     343{
     344    uint32_t const  cSyms = pThis->cSyms;
     345    MY_NLIST const *pSym = pThis->paSyms;
    362346
    363347#if 1
     
    368352            continue;
    369353
    370         const char *pszTabName= &pKernel->pachStrTab[(uint32_t)pSym->n_un.n_strx];
     354        const char *pszTabName= &pThis->pachStrTab[(uint32_t)pSym->n_un.n_strx];
    371355        if (   *pszTabName == '_'
    372356            && strcmp(pszTabName + 1, pszSymbol) == 0)
     
    398382 *
    399383 * @returns IPRT status code.
    400  * @param   pKernel             The internal scratch data.
     384 * @param   pThis               The internal scratch data.
    401385 */
    402 static int rtR0DarwinMachKernelCheckStandardSymbols(PRTR0DARWINKERNEL pKernel)
     386static int rtR0MachKernelCheckStandardSymbols(RTR0MACHKERNELINT *pThis)
    403387{
    404388    static struct
     
    516500    for (unsigned i = 0; i < RT_ELEMENTS(s_aStandardCandles); i++)
    517501    {
    518         uintptr_t uAddr = rtR0DarwinMachKernelLookup(pKernel, s_aStandardCandles[i].pszName);
     502        uintptr_t uAddr = rtR0MachKernelLookup(pThis, s_aStandardCandles[i].pszName);
    519503#ifdef IN_RING0
    520504        if (uAddr != s_aStandardCandles[i].uAddr)
     
    535519 *
    536520 * @returns IPRT status code.
    537  * @param   pKernel             The internal scratch data.
     521 * @param   pThis               The internal scratch data.
    538522 */
    539 static int rtR0DarwinMachKernelLoadSymTab(PRTR0DARWINKERNEL pKernel)
     523static int rtR0MachKernelLoadSymTab(RTR0MACHKERNELINT *pThis)
    540524{
    541525    /*
    542526     * Load the tables.
    543527     */
    544     pKernel->paSyms = (MY_NLIST *)RTMemAllocZ(pKernel->cSyms * sizeof(MY_NLIST));
    545     if (!pKernel->paSyms)
     528    pThis->paSyms = (MY_NLIST *)RTMemAllocZ(pThis->cSyms * sizeof(MY_NLIST));
     529    if (!pThis->paSyms)
    546530        return VERR_NO_MEMORY;
    547531
    548     int rc = RTFileReadAt(pKernel->hFile, pKernel->offArch + pKernel->offSyms,
    549                           pKernel->paSyms, pKernel->cSyms * sizeof(MY_NLIST), NULL);
     532    int rc = RTFileReadAt(pThis->hFile, pThis->offArch + pThis->offSyms,
     533                          pThis->paSyms, pThis->cSyms * sizeof(MY_NLIST), NULL);
    550534    if (RT_FAILURE(rc))
    551535        return rc;
    552536
    553     pKernel->pachStrTab = (char *)RTMemAllocZ(pKernel->cbStrTab + 1);
    554     if (!pKernel->pachStrTab)
     537    pThis->pachStrTab = (char *)RTMemAllocZ(pThis->cbStrTab + 1);
     538    if (!pThis->pachStrTab)
    555539        return VERR_NO_MEMORY;
    556540
    557     rc = RTFileReadAt(pKernel->hFile, pKernel->offArch + pKernel->offStrTab,
    558                       pKernel->pachStrTab, pKernel->cbStrTab, NULL);
     541    rc = RTFileReadAt(pThis->hFile, pThis->offArch + pThis->offStrTab,
     542                      pThis->pachStrTab, pThis->cbStrTab, NULL);
    559543    if (RT_FAILURE(rc))
    560544        return rc;
     
    563547     * The first string table symbol must be a zero length name.
    564548     */
    565     if (pKernel->pachStrTab[0] != '\0')
     549    if (pThis->pachStrTab[0] != '\0')
    566550        RETURN_VERR_BAD_EXE_FORMAT;
    567551
     
    570554     */
    571555    const char     *pszPrev = "";
    572     uint32_t const  cSyms   = pKernel->cSyms;
    573     MY_NLIST const  *pSym   = pKernel->paSyms;
     556    uint32_t const  cSyms   = pThis->cSyms;
     557    MY_NLIST const  *pSym   = pThis->paSyms;
    574558    for (uint32_t iSym = 0; iSym < cSyms; iSym++, pSym++)
    575559    {
    576         if ((uint32_t)pSym->n_un.n_strx >= pKernel->cbStrTab)
     560        if ((uint32_t)pSym->n_un.n_strx >= pThis->cbStrTab)
    577561            RETURN_VERR_BAD_EXE_FORMAT;
    578         const char *pszSym = &pKernel->pachStrTab[(uint32_t)pSym->n_un.n_strx];
     562        const char *pszSym = &pThis->pachStrTab[(uint32_t)pSym->n_un.n_strx];
    579563#ifdef IN_RING3
    580564        RTAssertMsg2("%05i: %02x:%08x %02x %04x %s\n", iSym, pSym->n_sect, pSym->n_value, pSym->n_type, pSym->n_desc, pszSym);
     
    591575                    if (pSym->n_sect == MACHO_NO_SECT)
    592576                        RETURN_VERR_BAD_EXE_FORMAT;
    593                     if (pSym->n_sect > pKernel->cSections)
     577                    if (pSym->n_sect > pThis->cSections)
    594578                        RETURN_VERR_BAD_EXE_FORMAT;
    595579                    if (pSym->n_desc & ~(REFERENCED_DYNAMICALLY))
    596580                        RETURN_VERR_BAD_EXE_FORMAT;
    597                     if (pSym->n_value < pKernel->apSections[pSym->n_sect - 1]->addr)
    598                         RETURN_VERR_BAD_EXE_FORMAT;
    599                     if (   pSym->n_value - pKernel->apSections[pSym->n_sect - 1]->addr
    600                         > pKernel->apSections[pSym->n_sect - 1]->size)
     581                    if (pSym->n_value < pThis->apSections[pSym->n_sect - 1]->addr)
     582                        RETURN_VERR_BAD_EXE_FORMAT;
     583                    if (   pSym->n_value - pThis->apSections[pSym->n_sect - 1]->addr
     584                        > pThis->apSections[pSym->n_sect - 1]->size)
    601585                        RETURN_VERR_BAD_EXE_FORMAT;
    602586                    break;
     
    606590                    if (pSym->n_sect != MACHO_NO_SECT)
    607591#else
    608                     if (pSym->n_sect > pKernel->cSections)
     592                    if (pSym->n_sect > pThis->cSections)
    609593#endif
    610594                        RETURN_VERR_BAD_EXE_FORMAT;
     
    640624 *
    641625 * @returns IPRT status code.
    642  * @param   pKernel             The internal scratch data.
     626 * @param   pThis               The internal scratch data.
    643627 */
    644 static int rtR0DarwinMachKernelLoadCommands(PRTR0DARWINKERNEL pKernel)
    645 {
    646     pKernel->offStrTab = 0;
    647     pKernel->cbStrTab  = 0;
    648     pKernel->offSyms   = 0;
    649     pKernel->cSyms     = 0;
    650     pKernel->cSections = 0;
    651 
    652     pKernel->pLoadCmds = (load_command_t *)RTMemAlloc(pKernel->cbLoadCmds);
    653     if (!pKernel->pLoadCmds)
     628static int rtR0MachKernelLoadCommands(RTR0MACHKERNELINT *pThis)
     629{
     630    pThis->offStrTab = 0;
     631    pThis->cbStrTab  = 0;
     632    pThis->offSyms   = 0;
     633    pThis->cSyms     = 0;
     634    pThis->cSections = 0;
     635
     636    pThis->pLoadCmds = (load_command_t *)RTMemAlloc(pThis->cbLoadCmds);
     637    if (!pThis->pLoadCmds)
    654638        return VERR_NO_MEMORY;
    655639
    656     int rc = RTFileReadAt(pKernel->hFile, pKernel->offArch + sizeof(MY_MACHO_HEADER),
    657                           pKernel->pLoadCmds, pKernel->cbLoadCmds, NULL);
     640    int rc = RTFileReadAt(pThis->hFile, pThis->offArch + sizeof(MY_MACHO_HEADER),
     641                          pThis->pLoadCmds, pThis->cbLoadCmds, NULL);
    658642    if (RT_FAILURE(rc))
    659643        return rc;
     
    663647     * table location.
    664648     */
    665     load_command_t const   *pCmd = pKernel->pLoadCmds;
     649    load_command_t const   *pCmd = pThis->pLoadCmds;
    666650    for (uint32_t iCmd = 0; ; iCmd++)
    667651    {
    668652        /* cmd index & offset. */
    669         uintptr_t offCmd = (uintptr_t)pCmd - (uintptr_t)pKernel->pLoadCmds;
    670         if (offCmd == pKernel->cbLoadCmds && iCmd == pKernel->cLoadCmds)
     653        uintptr_t offCmd = (uintptr_t)pCmd - (uintptr_t)pThis->pLoadCmds;
     654        if (offCmd == pThis->cbLoadCmds && iCmd == pThis->cLoadCmds)
    671655            break;
    672         if (offCmd + sizeof(*pCmd) > pKernel->cbLoadCmds)
     656        if (offCmd + sizeof(*pCmd) > pThis->cbLoadCmds)
    673657            RETURN_VERR_BAD_EXE_FORMAT;
    674         if (iCmd >= pKernel->cLoadCmds)
     658        if (iCmd >= pThis->cLoadCmds)
    675659            RETURN_VERR_BAD_EXE_FORMAT;
    676660
     
    678662        if (pCmd->cmdsize < sizeof(*pCmd))
    679663            RETURN_VERR_BAD_EXE_FORMAT;
    680         if (pCmd->cmdsize > pKernel->cbLoadCmds)
     664        if (pCmd->cmdsize > pThis->cbLoadCmds)
    681665            RETURN_VERR_BAD_EXE_FORMAT;
    682666        if (RT_ALIGN_32(pCmd->cmdsize, 4) != pCmd->cmdsize)
     
    697681                    RETURN_VERR_BAD_EXE_FORMAT;
    698682
    699                 pKernel->offStrTab = pSymTab->stroff;
    700                 pKernel->cbStrTab  = pSymTab->strsize;
    701                 pKernel->offSyms   = pSymTab->symoff;
    702                 pKernel->cSyms     = pSymTab->nsyms;
     683                pThis->offStrTab = pSymTab->stroff;
     684                pThis->cbStrTab  = pSymTab->strsize;
     685                pThis->offSyms   = pSymTab->symoff;
     686                pThis->cSyms     = pSymTab->nsyms;
    703687                break;
    704688            }
     
    796780
    797781                    /* Add to the section table. */
    798                     if (pKernel->cSections == MACHO_MAX_SECT)
    799                         RETURN_VERR_BAD_EXE_FORMAT;
    800                     pKernel->apSections[pKernel->cSections++] = &paSects[i];
     782                    if (pThis->cSections == MACHO_MAX_SECT)
     783                        RETURN_VERR_BAD_EXE_FORMAT;
     784                    pThis->apSections[pThis->cSections++] = &paSects[i];
    801785                }
    802786
     
    866850 *
    867851 * @returns IPRT status code.
    868  * @param   pKernel             The internal scratch data.
     852 * @param   pThis               The internal scratch data.
    869853 */
    870 static int rtR0DarwinMachKernelLoadFileHeaders(PRTR0DARWINKERNEL pKernel)
     854static int rtR0MachKernelLoadFileHeaders(RTR0MACHKERNELINT *pThis)
    871855{
    872856    uint32_t i;
    873857
    874     pKernel->offArch = 0;
    875     pKernel->cbArch  = 0;
     858    pThis->offArch = 0;
     859    pThis->cbArch  = 0;
    876860
    877861    /*
    878862     * Read the first bit of the file, parse the FAT if found there.
    879863     */
    880     int rc = RTFileReadAt(pKernel->hFile, 0, pKernel->abBuf, sizeof(fat_header_t) + sizeof(fat_arch_t) * 16, NULL);
     864    int rc = RTFileReadAt(pThis->hFile, 0, pThis->abBuf, sizeof(fat_header_t) + sizeof(fat_arch_t) * 16, NULL);
    881865    if (RT_FAILURE(rc))
    882866        return rc;
    883867
    884     fat_header_t   *pFat        = (fat_header *)pKernel->abBuf;
     868    fat_header_t   *pFat        = (fat_header *)pThis->abBuf;
    885869    fat_arch_t     *paFatArches = (fat_arch_t *)(pFat + 1);
    886870
     
    912896                && paFatArches[i].cpusubtype == MY_CPU_SUBTYPE_ALL)
    913897            {
    914                 pKernel->offArch = paFatArches[i].offset;
    915                 pKernel->cbArch  = paFatArches[i].size;
    916                 if (!pKernel->cbArch)
    917                     RETURN_VERR_BAD_EXE_FORMAT;
    918                 if (pKernel->offArch < sizeof(fat_header_t) + sizeof(fat_arch_t) * pFat->nfat_arch)
    919                     RETURN_VERR_BAD_EXE_FORMAT;
    920                 if (pKernel->offArch + pKernel->cbArch <= pKernel->offArch)
     898                pThis->offArch = paFatArches[i].offset;
     899                pThis->cbArch  = paFatArches[i].size;
     900                if (!pThis->cbArch)
     901                    RETURN_VERR_BAD_EXE_FORMAT;
     902                if (pThis->offArch < sizeof(fat_header_t) + sizeof(fat_arch_t) * pFat->nfat_arch)
     903                    RETURN_VERR_BAD_EXE_FORMAT;
     904                if (pThis->offArch + pThis->cbArch <= pThis->offArch)
    921905                    RETURN_VERR_LDR_ARCH_MISMATCH;
    922906                break;
     
    930914     * Read the Mach-O header and validate it.
    931915     */
    932     rc = RTFileReadAt(pKernel->hFile, pKernel->offArch, pKernel->abBuf, sizeof(MY_MACHO_HEADER), NULL);
     916    rc = RTFileReadAt(pThis->hFile, pThis->offArch, pThis->abBuf, sizeof(MY_MACHO_HEADER), NULL);
    933917    if (RT_FAILURE(rc))
    934918        return rc;
    935     MY_MACHO_HEADER const *pHdr = (MY_MACHO_HEADER const *)pKernel->abBuf;
     919    MY_MACHO_HEADER const *pHdr = (MY_MACHO_HEADER const *)pThis->abBuf;
    936920    if (pHdr->magic != MY_MACHO_MAGIC)
    937921    {
     
    961945        RETURN_VERR_LDR_UNEXPECTED;
    962946
    963     pKernel->cLoadCmds  = pHdr->ncmds;
    964     pKernel->cbLoadCmds = pHdr->sizeofcmds;
     947    pThis->cLoadCmds  = pHdr->ncmds;
     948    pThis->cbLoadCmds = pHdr->sizeofcmds;
    965949    return VINF_SUCCESS;
    966950}
    967951
    968952
    969 /**
    970  * Opens symbol table of the mach_kernel.
    971  *
    972  * @returns IPRT status code.
    973  * @param   pszMachKernel   The path to the mach_kernel image.
    974  * @param   ppHandle        Where to return a handle on success.
    975  *                          Call rtR0DarwinMachKernelClose on it
    976  *                          when done.
    977  */
    978 static int rtR0DarwinMachKernelOpen(const char *pszMachKernel, PRTR0DARWINKERNEL *ppHandle)
    979 {
    980     *ppHandle = NULL;
    981     PRTR0DARWINKERNEL pKernel = (PRTR0DARWINKERNEL)RTMemAllocZ(sizeof(*pKernel));
    982     if (!pKernel)
     953RTDECL(int) RTR0MachKernelOpen(const char *pszMachKernel, PRTR0MACHKERNEL phKernel)
     954{
     955    *phKernel = NIL_RTR0MACHKERNEL;
     956
     957    RTR0MACHKERNELINT *pThis = (RTR0MACHKERNELINT *)RTMemAllocZ(sizeof(*pThis));
     958    if (!pThis)
    983959        return VERR_NO_MEMORY;
    984     pKernel->hFile = NIL_RTFILE;
    985 
    986     int rc = RTFileOpen(&pKernel->hFile, pszMachKernel, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     960    pThis->hFile = NIL_RTFILE;
     961
     962    int rc = RTFileOpen(&pThis->hFile, pszMachKernel, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    987963    if (RT_SUCCESS(rc))
    988         rc = rtR0DarwinMachKernelLoadFileHeaders(pKernel);
     964        rc = rtR0MachKernelLoadFileHeaders(pThis);
    989965    if (RT_SUCCESS(rc))
    990         rc = rtR0DarwinMachKernelLoadCommands(pKernel);
     966        rc = rtR0MachKernelLoadCommands(pThis);
    991967    if (RT_SUCCESS(rc))
    992         rc = rtR0DarwinMachKernelLoadSymTab(pKernel);
     968        rc = rtR0MachKernelLoadSymTab(pThis);
    993969    if (RT_SUCCESS(rc))
    994         rc = rtR0DarwinMachKernelCheckStandardSymbols(pKernel);
    995 
    996     rtR0DarwinMachKernelLoadDone(pKernel);
     970        rc = rtR0MachKernelCheckStandardSymbols(pThis);
     971
     972    rtR0MachKernelLoadDone(pThis);
    997973    if (RT_SUCCESS(rc))
    998         *ppHandle = pKernel;
     974        *phKernel = pThis;
    999975    else
    1000         rtR0DarwinMachKernelClose(pKernel);
     976        RTR0MachKernelClose(pThis);
    1001977    return rc;
    1002978}
    1003979
     980
     981RTR0DECL(int) RTR0MachKernelGetSymbol(RTR0MACHKERNEL hKernel, const char *pszSymbol, void **ppvValue)
     982{
     983    RTR0MACHKERNELINT *pThis = hKernel;
     984    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     985
     986    uintptr_t uValue = rtR0MachKernelLookup(pThis, pszSymbol);
     987    if (ppvValue)
     988        *ppvValue = (void *)uValue;
     989    if (!uValue)
     990        return VERR_SYMBOL_NOT_FOUND;
     991    return VINF_SUCCESS;
     992}
     993
     994
     995RTR0DECL(int) RTR0MachKernelClose(RTR0MACHKERNEL hKernel)
     996{
     997    if (hKernel == NIL_RTR0MACHKERNEL)
     998        return VINF_SUCCESS;
     999
     1000    RTR0MACHKERNELINT *pThis = hKernel;
     1001    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     1002
     1003    RTMemFree(pThis->pachStrTab);
     1004    pThis->pachStrTab = NULL;
     1005
     1006    RTMemFree(pThis->paSyms);
     1007    pThis->paSyms = NULL;
     1008
     1009    RTMemFree(pThis);
     1010    return VINF_SUCCESS;
     1011}
     1012
  • trunk/src/VBox/Runtime/testcase/Makefile.kmk

    r37560 r37573  
    578578
    579579tstRTDarwinMachKernel_TEMPLATE = VBOXR3TSTEXE
    580 tstRTDarwinMachKernel_SOURCES  = tstRTDarwinMachKernel.cpp
     580tstRTDarwinMachKernel_INCS     = ../include
     581tstRTDarwinMachKernel_SOURCES  = \
     582        tstRTDarwinMachKernel.cpp \
     583        ../r0drv/darwin/mach_kernel-r0drv-darwin.cpp
    581584
    582585ntGetTimerResolution_SOURCES = ntGetTimerResolution.cpp
  • trunk/src/VBox/Runtime/testcase/tstRTDarwinMachKernel.cpp

    r37566 r37573  
    2525 */
    2626
     27
    2728/*******************************************************************************
    2829*   Header Files                                                               *
    2930*******************************************************************************/
     31#include <iprt/darwin/machkernel.h>
    3032#include <iprt/err.h>
    3133#include <iprt/string.h>
    3234#include <iprt/test.h>
    3335
    34 #include "../r0drv/darwin/mach_kernel-r0drv-darwin.cpp"
    3536
    3637
    3738static void dotest(const char *pszMachKernel)
    3839{
    39     PRTR0DARWINKERNEL pKernel;
    40     RTTESTI_CHECK_RC_RETV(rtR0DarwinMachKernelOpen(pszMachKernel, &pKernel), VINF_SUCCESS);
     40    RTR0MACHKERNEL hKernel;
     41    RTTESTI_CHECK_RC_RETV(RTR0MachKernelOpen(pszMachKernel, &hKernel), VINF_SUCCESS);
    4142    static const char * const s_apszSyms[] =
    4243    {
    4344        "ast_pending",
    44         "i386_signal_cpu",
    45         "i386_cpu_IPI",
     45        "cpu_interrupt",
    4646        "dtrace_register",
    4747        "dtrace_suspend",
     
    4949    for (unsigned i = 0; i < RT_ELEMENTS(s_apszSyms); i++)
    5050    {
    51         uintptr_t uPtr = rtR0DarwinMachKernelLookup(pKernel, s_apszSyms[i]);
    52         RTTestIPrintf(RTTESTLVL_ALWAYS, "%p %s\n", uPtr, s_apszSyms[i]);
    53         RTTESTI_CHECK(uPtr != 0);
     51        void *pvValue = NULL;
     52        int rc = RTR0MachKernelGetSymbol(hKernel, s_apszSyms[i], &pvValue);
     53        RTTestIPrintf(RTTESTLVL_ALWAYS, "%Rrc %p %s\n", rc, pvValue, s_apszSyms[i]);
     54        RTTESTI_CHECK_RC(rc, VINF_SUCCESS);
     55        if (RT_SUCCESS(rc))
     56            RTTESTI_CHECK_RC(RTR0MachKernelGetSymbol(hKernel, s_apszSyms[i], NULL), VINF_SUCCESS);
    5457    }
    55     rtR0DarwinMachKernelClose(pKernel);
     58
     59    RTTESTI_CHECK_RC(RTR0MachKernelGetSymbol(hKernel, "no_such_symbol_name_really", NULL), VERR_SYMBOL_NOT_FOUND);
     60    RTTESTI_CHECK_RC(RTR0MachKernelClose(hKernel), VINF_SUCCESS);
     61    RTTESTI_CHECK_RC(RTR0MachKernelClose(NIL_RTR0MACHKERNEL), VINF_SUCCESS);
    5662}
    5763
     
    6066{
    6167    RTTEST hTest;
    62     RTEXITCODE rcExit = RTTestInitAndCreate("tstRTDarwinMachKernel", &hTest);
     68    RTEXITCODE rcExit = RTTestInitAndCreate("tstRTMachKernel", &hTest);
    6369    if (rcExit != RTEXITCODE_SUCCESS)
    6470        return rcExit;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette