- Timestamp:
- May 10, 2013 12:36:39 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 85636
- Location:
- trunk/src/VBox/Runtime/common/ldr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrELF.cpp
r44528 r45982 49 49 * Defined Constants And Macros * 50 50 *******************************************************************************/ 51 /** Finds an ELF s tring. */51 /** Finds an ELF symbol table string. */ 52 52 #define ELF_STR(pHdrs, iStr) ((pHdrs)->pStr + (iStr)) 53 /** Finds an ELF section header string. */ 54 #define ELF_SH_STR(pHdrs, iStr) ((pHdrs)->pShStr + (iStr)) 53 55 54 56 -
trunk/src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h
r45981 r45982 124 124 /** Pointer to string table within RTLDRMODELF::pvBits. */ 125 125 const char *pStr; 126 127 /** Size of the section header string table. */ 128 unsigned cbShStr; 129 /** Pointer to section header string table within RTLDRMODELF::pvBits. */ 130 const char *pShStr; 126 131 } RTLDRMODELF, *PRTLDRMODELF; 127 132 … … 148 153 if (pModElf->iStrSh != ~0U) 149 154 pModElf->pStr = (const char *)(pu8 + pModElf->paShdrs[pModElf->iStrSh].sh_offset); 155 pModElf->pShStr = (const char *)(pu8 + pModElf->paShdrs[pModElf->Ehdr.e_shstrndx].sh_offset); 150 156 } 151 157 return rc; … … 644 650 */ 645 651 Log2(("rtldrELF: %s: Relocation records for #%d [%s] (sh_info=%d sh_link=%d) found in #%d [%s] (sh_info=%d sh_link=%d)\n", 646 pszLogName, (int)pShdrRel->sh_info, ELF_S TR(pModElf, pShdr->sh_name), (int)pShdr->sh_info, (int)pShdr->sh_link,647 iShdr, ELF_S TR(pModElf, pShdrRel->sh_name), (int)pShdrRel->sh_info, (int)pShdrRel->sh_link));652 pszLogName, (int)pShdrRel->sh_info, ELF_SH_STR(pModElf, pShdr->sh_name), (int)pShdr->sh_info, (int)pShdr->sh_link, 653 iShdr, ELF_SH_STR(pModElf, pShdrRel->sh_name), (int)pShdrRel->sh_info, (int)pShdrRel->sh_link)); 648 654 649 655 /** @todo Make RelocateSection a function pointer so we can select the one corresponding to the machine when opening the image. */ … … 754 760 continue; 755 761 756 const char *pszSectName = ELF_S TR(pModElf, paShdrs[iShdr].sh_name);762 const char *pszSectName = ELF_SH_STR(pModElf, paShdrs[iShdr].sh_name); 757 763 if ( !strncmp(pszSectName, RT_STR_TUPLE(".debug_")) 758 764 || !strcmp(pszSectName, ".WATCOM_references") ) … … 830 836 { 831 837 RTLDRSEG Seg; 832 Seg.pchName = ELF_S TR(pModElf, paShdrs[iShdr].sh_name);838 Seg.pchName = ELF_SH_STR(pModElf, paShdrs[iShdr].sh_name); 833 839 Seg.cchName = (uint32_t)strlen(Seg.pchName); 834 840 Seg.SelFlat = 0; … … 1147 1153 } 1148 1154 1155 if (pEhdr->e_shstrndx == 0 || pEhdr->e_shstrndx > pEhdr->e_shnum) 1156 { 1157 Log(("RTLdrELF: %s: The section headers string table is out of bounds! e_shstrndx=" FMT_ELF_HALF " e_shnum=" FMT_ELF_HALF "\n", 1158 pszLogName, pEhdr->e_shstrndx, pEhdr->e_shnum)); 1159 return VERR_BAD_EXE_FORMAT; 1160 } 1161 1149 1162 return VINF_SUCCESS; 1150 1163 } … … 1232 1245 } 1233 1246 1247 if (pShdr->sh_name >= pModElf->cbShStr) 1248 { 1249 Log(("RTLdrELF: %s: Shdr #%d: sh_name (%d) is beyond the end of the section header string table (%d)!\n", 1250 pszLogName, iShdr, pShdr->sh_name, pModElf->cbShStr)); NOREF(pszLogName); 1251 return VERR_BAD_EXE_FORMAT; 1252 } 1253 1234 1254 if (pShdr->sh_link >= pModElf->Ehdr.e_shnum) 1235 1255 { … … 1330 1350 //pModElf->paSyms = NULL; 1331 1351 pModElf->iSymSh = ~0U; 1332 pModElf->cSyms = 0;1352 //pModElf->cSyms = 0; 1333 1353 pModElf->iStrSh = ~0U; 1334 pModElf->cbStr = 0;1335 pModElf->cbImage = 0;1354 //pModElf->cbStr = 0; 1355 //pModElf->cbImage = 0; 1336 1356 //pModElf->pStr = NULL; 1357 //pModElf->cbShStr = 0; 1358 //pModElf->pShStr = NULL; 1337 1359 1338 1360 /* … … 1367 1389 memcpy(&paShdrs[pModElf->Ehdr.e_shnum], paShdrs, cbShdrs); 1368 1390 pModElf->paOrgShdrs = &paShdrs[pModElf->Ehdr.e_shnum]; 1391 1392 pModElf->cbShStr = paShdrs[pModElf->Ehdr.e_shstrndx].sh_size; 1369 1393 1370 1394 /* … … 1407 1431 AssertReturn(pModElf->cbStr == paShdrs[pModElf->iStrSh].sh_size, VERR_IMAGE_TOO_BIG); 1408 1432 } 1409 else if (paShdrs[i].sh_type == SHT_STRTAB && pModElf->iStrSh == ~0U) 1433 1434 /* Special checks for the section string table. */ 1435 if (i == pModElf->Ehdr.e_shstrndx) 1410 1436 { 1411 pModElf->iStrSh = i; 1412 pModElf->cbStr = (unsigned)paShdrs[i].sh_size; 1413 AssertReturn(pModElf->cbStr == paShdrs[i].sh_size, VERR_IMAGE_TOO_BIG); 1437 if (paShdrs[i].sh_type != SHT_STRTAB) 1438 { 1439 Log(("RTLdrElf: Section header string table is not a SHT_STRTAB: %#x\n", paShdrs[i].sh_type)); 1440 rc = VERR_BAD_EXE_FORMAT; 1441 break; 1442 } 1443 if (paShdrs[i].sh_size == 0) 1444 { 1445 Log(("RTLdrElf: Section header string table is empty\n")); 1446 rc = VERR_BAD_EXE_FORMAT; 1447 break; 1448 } 1414 1449 } 1415 1450 … … 1418 1453 Log2(("RTLdrElf: iSymSh=%u cSyms=%u iStrSh=%u cbStr=%u rc=%Rrc cbImage=%#zx\n", 1419 1454 pModElf->iSymSh, pModElf->cSyms, pModElf->iStrSh, pModElf->cbStr, rc, pModElf->cbImage)); 1420 #if 01421 /*1422 * Are the section headers fine?1423 * We require there to be symbol & string tables (at least for the time being).1424 */1425 if ( pModElf->iSymSh == ~0U1426 || pModElf->iStrSh == ~0U)1427 rc = VERR_LDRELF_NO_SYMBOL_OR_NO_STRING_TABS;1428 #endif1429 1455 if (RT_SUCCESS(rc)) 1430 1456 {
Note:
See TracChangeset
for help on using the changeset viewer.