VirtualBox

Changeset 59955 in vbox


Ignore:
Timestamp:
Mar 8, 2016 3:25:33 PM (9 years ago)
Author:
vboxsync
Message:

VBoxBs3ObjConvert.cpp: ELF updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp

    r59954 r59955  
    802802typedef struct ELFDETAILS
    803803{
     804    /** The ELF header. */
    804805    Elf64_Ehdr const   *pEhdr;
     806    /** The section header table.   */
    805807    Elf64_Shdr const   *paShdrs;
     808    /** The string table for the section names. */
    806809    const char         *pchShStrTab;
     810
     811    /** The symbol table section number. UINT16_MAX if not found.   */
    807812    uint16_t            iSymSh;
     813    /** The string table section number. UINT16_MAX if not found. */
    808814    uint16_t            iStrSh;
     815
     816    /** The symbol table.   */
     817    Elf64_Sym const    *paSymbols;
     818    /** The number of symbols in the symbol table. */
     819    uint32_t            cSymbols;
     820
     821    /** Pointer to the (symbol) string table if found. */
     822    const char         *pchStrTab;
     823    /** The string table size. */
     824    size_t              cbStrTab;
     825
    809826} ELFDETAILS;
    810827typedef ELFDETAILS *PELFDETAILS;
     
    920937            }
    921938        }
     939        else if (paShdrs[i].sh_type == SHT_REL)
     940            fRet = error(pszFile, "Section #%u '%s': Unexpected SHT_REL section\n", i, pszShNm);
    922941        else if (paShdrs[i].sh_type == SHT_SYMTAB)
    923942        {
     943            if (paShdrs[i].sh_entsize != sizeof(Elf64_Sym))
     944                fRet = error(pszFile, "Section #%u '%s': Unsupported symbol table entry size in : #%u (expected #%u)\n",
     945                             i, pszShNm, paShdrs[i].sh_entsize, sizeof(Elf64_Sym));
     946            uint32_t cSymbols = paShdrs[i].sh_size / paShdrs[i].sh_entsize;
     947            if ((Elf64_Xword)cSymbols * paShdrs[i].sh_entsize != paShdrs[i].sh_size)
     948                fRet = error(pszFile, "Section #%u '%s': Size not a multiple of entry size: %#" ELF_FMT_X64 " %% %#" ELF_FMT_X64 " = %#" ELF_FMT_X64 "\n",
     949                             i, pszShNm, paShdrs[i].sh_size, paShdrs[i].sh_entsize, paShdrs[i].sh_size % paShdrs[i].sh_entsize);
    924950            if (pElfStuff->iSymSh == UINT16_MAX)
    925951            {
    926                 pElfStuff->iSymSh = (uint16_t)i;
    927                 if (paShdrs[i].sh_entsize == sizeof(Elf64_Sym))
     952                pElfStuff->iSymSh    = (uint16_t)i;
     953                pElfStuff->paSymbols = (Elf64_Sym const *)&pbFile[paShdrs[i].sh_offset];
     954                pElfStuff->cSymbols  = cSymbols;
     955
     956                if (paShdrs[i].sh_link != 0)
    928957                {
    929 
     958                    /* Note! The symbol string table section header may not have been validated yet! */
     959                    Elf64_Shdr const *pStrTabShdr = &paShdrs[paShdrs[i].sh_link];
     960                    pElfStuff->iStrSh    = paShdrs[i].sh_link;
     961                    pElfStuff->pchStrTab = (const char *)&pbFile[pStrTabShdr->sh_offset];
     962                    pElfStuff->cbStrTab  = (size_t)pStrTabShdr->sh_size;
    930963                }
    931964                else
    932                     fRet = error(pszFile, "Unsupported symbol table entry size: #%u (expected #%u)\n",
    933                                  i, pszShNm, paShdrs[i].sh_entsize, sizeof(Elf64_Sym));
     965                    fRet = error(pszFile, "Section #%u '%s': String table link is out of bounds (%#x)\n",
     966                                 i, pszShNm, paShdrs[i].sh_link);
    934967            }
    935968            else
    936                 fRet = error(pszFile, "2nd symbol table found #%u '%s' (previous #u)\n", i, pszShNm, pElfStuff->iSymSh);
    937         }
    938         else if (paShdrs[i].sh_type == SHT_REL)
    939             fRet = error(pszFile, "Did not expect SHT_REL sections (#%u '%s')\n", i, pszShNm);
     969                fRet = error(pszFile, "Section #%u '%s': Found additonal symbol table, previous in #%u\n",
     970                             i, pszShNm, pElfStuff->iSymSh);
     971        }
    940972    }
    941973    return fRet;
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