VirtualBox

Changeset 41510 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
May 30, 2012 8:05:54 PM (13 years ago)
Author:
vboxsync
Message:

IPRT/Elf: Working on loading watcom dwarf symbol files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h

    r39083 r41510  
    141141    {
    142142        const uint8_t *pu8 = (const uint8_t *)pModElf->pvBits;
    143         pModElf->paSyms = (const Elf_Sym *)(pu8 + pModElf->paShdrs[pModElf->iSymSh].sh_offset);
    144         pModElf->pStr   =    (const char *)(pu8 + pModElf->paShdrs[pModElf->iStrSh].sh_offset);
     143        if (pModElf->iSymSh != ~0U)
     144            pModElf->paSyms = (const Elf_Sym *)(pu8 + pModElf->paShdrs[pModElf->iSymSh].sh_offset);
     145        if (pModElf->iStrSh != ~0U)
     146            pModElf->pStr   =    (const char *)(pu8 + pModElf->paShdrs[pModElf->iStrSh].sh_offset);
    145147    }
    146148    return rc;
     
    513515static DECLCALLBACK(int) RTLDRELF_NAME(GetBits)(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR BaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser)
    514516{
    515     PRTLDRMODELF pModElf = (PRTLDRMODELF)pMod;
     517    PRTLDRMODELF    pModElf = (PRTLDRMODELF)pMod;
     518
     519    /*
     520     * This operation is currently only available on relocatable images.
     521     */
     522    switch (pModElf->Ehdr.e_type)
     523    {
     524        case ET_REL:
     525            break;
     526        case ET_EXEC:
     527            Log(("RTLdrELF: %s: Executable images are not supported yet!\n", pModElf->pReader->pfnLogName(pModElf->pReader)));
     528            return VERR_LDRELF_EXEC;
     529        case ET_DYN:
     530            Log(("RTLdrELF: %s: Dynamic images are not supported yet!\n", pModElf->pReader->pfnLogName(pModElf->pReader)));
     531            return VERR_LDRELF_DYN;
     532        default: AssertFailedReturn(VERR_BAD_EXE_FORMAT);
     533    }
    516534
    517535    /*
     
    558576                                                 RTUINTPTR OldBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser)
    559577{
    560     PRTLDRMODELF pModElf = (PRTLDRMODELF)pMod;
     578    PRTLDRMODELF    pModElf = (PRTLDRMODELF)pMod;
     579#ifdef LOG_ENABLED
     580    const char     *pszLogName = pModElf->pReader->pfnLogName(pModElf->pReader);
     581#endif
    561582    NOREF(OldBaseAddress);
     583
     584    /*
     585     * This operation is currently only available on relocatable images.
     586     */
     587    switch (pModElf->Ehdr.e_type)
     588    {
     589        case ET_REL:
     590            break;
     591        case ET_EXEC:
     592            Log(("RTLdrELF: %s: Executable images are not supported yet!\n", pszLogName));
     593            return VERR_LDRELF_EXEC;
     594        case ET_DYN:
     595            Log(("RTLdrELF: %s: Dynamic images are not supported yet!\n", pszLogName));
     596            return VERR_LDRELF_DYN;
     597        default: AssertFailedReturn(VERR_BAD_EXE_FORMAT);
     598    }
    562599
    563600    /*
     
    580617     */
    581618    const Elf_Shdr *paShdrs = pModElf->paShdrs;
    582 #ifdef LOG_ENABLED
    583     const char     *pszLogName = pModElf->pReader->pfnLogName(pModElf->pReader);
    584619    Log2(("rtLdrElf: %s: Fixing up image\n", pszLogName));
    585 #endif
    586620    for (unsigned iShdr = 0; iShdr < pModElf->Ehdr.e_shnum; iShdr++)
    587621    {
     
    648682     */
    649683    const char         *pStr  = pModElf->pStr;
    650     const Elf_Sym    *paSyms = pModElf->paSyms;
     684    const Elf_Sym     *paSyms = pModElf->paSyms;
    651685    unsigned            cSyms = pModElf->cSyms;
    652686    for (unsigned iSym = 1; iSym < cSyms; iSym++)
     
    859893    {
    860894        case ET_REL:
     895        case ET_EXEC:
     896        case ET_DYN:
    861897            break;
    862         case ET_EXEC:
    863             Log(("RTLdrELF: %s: Executable images are not supported yet!\n", pszLogName));
    864             return VERR_LDRELF_EXEC;
    865         case ET_DYN:
    866             Log(("RTLdrELF: %s: Dynamic images are not supported yet!\n", pszLogName));
    867             return VERR_LDRELF_DYN;
    868898        default:
    869899            Log(("RTLdrELF: %s: image type %#x is not supported!\n", pszLogName, pEhdr->e_type));
     
    11611191                Log2(("RTLdrElf: iSymSh=%u cSyms=%u iStrSh=%u cbStr=%u rc=%Rrc cbImage=%#zx\n",
    11621192                      pModElf->iSymSh, pModElf->cSyms, pModElf->iStrSh, pModElf->cbStr, rc, pModElf->cbImage));
    1163 
     1193#if 0
    11641194                /*
    11651195                 * Are the section headers fine?
     
    11691199                    ||  pModElf->iStrSh == ~0U)
    11701200                    rc = VERR_LDRELF_NO_SYMBOL_OR_NO_STRING_TABS;
     1201#endif
    11711202                if (RT_SUCCESS(rc))
    11721203                {
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