- Timestamp:
- Feb 7, 2007, 8:07:16 AM (19 years ago)
- Location:
- trunk/kLdr
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/Makefile.kmk
r2954 r2955 100 100 kLdrDyldMod.c \ 101 101 kLdrDyldOS.c \ 102 kLdrErr.c \ 102 103 kLdrHlp.c \ 103 104 kLdrHlpHeap.c \ … … 125 126 kLdr_SOURCES.win64 = $(kLdr_SOURCES.win) 126 127 128 kLdrErr.c_DEPS = $(PATH_TARGET)/kldrErrConsts.h 129 kLdrErr.c_INCS = $(PATH_TARGET) 130 127 131 # 128 132 # The OS/2 stub program. … … 190 194 191 195 192 # generate rules.196 # Generate rules. 193 197 include $(PATH_KBUILD)/footer.kmk 194 198 199 200 # 201 # Generate case statements for kLdrErrStr(). 202 # 203 $(PATH_TARGET)/kldrErrConsts.h: kLdr.h Makefile.kmk | $(call DIRDEP,$(PATH_TARGET)) 204 $(RM) -f $@ 205 $(SED) \ 206 -e '/^#define *\(KLDR_ERR_[^ ()]*\) .*$$/!d' \ 207 -e 's/^#define *\(KLDR_ERR_[^ ()]*\) .*$$/ERR_CONST(\1)/' \ 208 -e '/KLDR_ERR_[^_]*_BASE/d' \ 209 kLdr.h > $@ 210 -
trunk/kLdr/kLdr-os2.def
r2884 r2955 107 107 ; _kLdrDlFunc 108 108 109 ; Error APIs: 110 _kLdrErrStr 111 112 -
trunk/kLdr/kLdr-win.def
r2877 r2955 106 106 ; _kLdrDlFunc 107 107 108 ; Error APIs: 109 kLdrErrStr 110 -
trunk/kLdr/kLdr.h
r2954 r2955 1265 1265 /** The sections aren't ordered by segment as expected by the loader. */ 1266 1266 #define KLDR_ERR_MACHO_BAD_SECTION_ORDER (KLDR_ERR_MACHO_BASE + 11) 1267 /** The image is 32-bit and contains 64-bit load commands or vise versa. */ 1268 #define KLDR_ERR_MACHO_BIT_MIX (KLDR_ERR_MACHO_BASE + 12) 1269 /** The bad MH_OBJECT file. */ 1270 #define KLDR_ERR_MACHO_BAD_OBJECT_FILE (KLDR_ERR_MACHO_BASE + 13) 1267 1271 /** @} */ 1268 1272 1269 1273 /** End of the valid kLdr status codes. */ 1270 #define KLDR_ERR_END (KLDR_ERR_MACHO_BASE + 12) 1274 #define KLDR_ERR_END (KLDR_ERR_MACHO_BASE + 14) 1275 1276 const char *kLdrErrStr(int rc); 1271 1277 1272 1278 /** @} */ -
trunk/kLdr/kLdrHlp.h
r2954 r2955 43 43 /** Align a void * value. */ 44 44 #define KLDR_ALIGN_P(pv, align) ( (void *)( ((uintptr_t)(pv) + ((align) - 1)) & ~(uintptr_t)((align) - 1) ) ) 45 /** Align a size_t value. */ 46 #define KLDR_ALIGN_ADDR(val, align) ( ((val) + ((align) - 1)) & ~(KLDRADDR)((align) - 1) ) 45 47 /** Number of elements in an array. */ 46 48 #define KLDR_ELEMENTS(a) ( sizeof(a) / sizeof((a)[0]) ) … … 239 241 #endif 240 242 243 size_t kLdrHlpStrNLen(const char *psz, size_t cchMax); 241 244 int kLdrHlpMemIComp(const void *pv1, const void *pv2, size_t cb); 242 245 int kLdrHlpStrIComp(const char *pv1, const char *pv2); -
trunk/kLdr/kLdrHlpStr.c
r2944 r2955 78 78 79 79 return pszRet; 80 } 81 82 83 size_t kLdrHlpStrNLen(const char *psz, size_t cchMax) 84 { 85 const char * const pszStart = psz; 86 while (*psz && cchMax--) 87 psz++; 88 return psz - pszStart; 80 89 } 81 90 -
trunk/kLdr/kLdrModMachO.c
r2954 r2955 99 99 /** The link address. */ 100 100 KLDRADDR LinkAddress; 101 /** The size of the mapped image. */ 102 KLDRADDR cbImage; 103 /** When set the load commands will be used when mapping / loading the bits. 104 * This is the case when segments are made up of sections that doesn't have 105 * proper ordering and/or aligning in the file alignment. */ 106 int fMapUsingLoadCommands; 101 107 102 108 /** Pointer to the load commands. (endian converted) */ … … 353 359 pModMachO->Hdr.reserved = 0; 354 360 pModMachO->LinkAddress = 0; 361 pModMachO->cbImage = 0; 362 pModMachO->fMapUsingLoadCommands = 0; 355 363 pModMachO->offSymbols = 0; 356 364 pModMachO->cSymbols = 0; … … 408 416 uint32_t cbLeft = pHdr->sizeofcmds; 409 417 uint8_t *pb = pbLoadCommands; 418 int cSegmentCommands = 0; 410 419 int fConvertEndian = pHdr->magic == IMAGE_MACHO32_SIGNATURE_OE 411 420 || pHdr->magic == IMAGE_MACHO64_SIGNATURE_OE; … … 447 456 if (u.pLoadCmd->cmdsize < sizeof(segment_command_32_t)) 448 457 return KLDR_ERR_MACHO_BAD_LOAD_COMMAND; 458 if ( pHdr->magic != IMAGE_MACHO32_SIGNATURE_OE 459 && pHdr->magic != IMAGE_MACHO32_SIGNATURE) 460 return KLDR_ERR_MACHO_BIT_MIX; 449 461 if (fConvertEndian) 450 462 { … … 473 485 if (u.pSeg32->nsects * sizeof(section_32_t) > u.pLoadCmd->cmdsize - sizeof(segment_command_32_t)) 474 486 return KLDR_ERR_MACHO_BAD_LOAD_COMMAND; 487 if ( pHdr->filetype == MH_OBJECT 488 && cSegmentCommands > 0) 489 return KLDR_ERR_MACHO_BAD_OBJECT_FILE; 490 cSegmentCommands++; 475 491 476 492 /* … … 566 582 567 583 /* a new segment? */ 568 if ( pSect == pFirstSect584 if ( !cSegments 569 585 || kLdrHlpStrNComp(pSect->segname, (pSect - 1)->segname, sizeof(pSect->segname))) 570 586 { … … 580 596 /* ok. count it and the string. */ 581 597 cSegments++; 582 cbStringPool += kLdrHlpStr Len(pSect->segname) + 1;598 cbStringPool += kLdrHlpStrNLen(&pSect->segname[0], sizeof(pSect->segname)) + 1; 583 599 } 584 600 break; … … 595 611 } 596 612 597 case LC_SEGMENT_64:598 /* copy 32-bit code */613 /*case LC_SEGMENT_64: 614 copy 32-bit code 599 615 break; 616 */ 600 617 601 618 case LC_SYMTAB: … … 656 673 break; 657 674 675 case LC_SEGMENT_64: 658 676 case LC_LOADFVMLIB: 659 677 case LC_IDFVMLIB: … … 684 702 } 685 703 686 /* be strict (for now). */704 /* be strict. */ 687 705 if (cbLeft) 688 706 return KLDR_ERR_MACHO_BAD_LOAD_COMMAND; 689 707 708 switch (pHdr->filetype) 709 { 710 case MH_OBJECT: 711 if (!cSegments) 712 return KLDR_ERR_MACHO_BAD_OBJECT_FILE; 713 break; 714 } 715 690 716 *pcSegments = cSegments; 691 *pcbStringPool = c Left;717 *pcbStringPool = cbStringPool; 692 718 693 719 return 0; … … 708 734 static int kldrModMachOParseLoadCommands(PKLDRMODMACHO pModMachO, char *pbStringPool, uint32_t cbStringPool) 709 735 { 736 union 737 { 738 const uint8_t *pb; 739 const load_command_t *pLoadCmd; 740 const segment_command_32_t *pSeg32; 741 const segment_command_64_t *pSeg64; 742 const symtab_command_t *pSymTab; 743 } u; 744 uint32_t cLeft = pModMachO->Hdr.ncmds; 745 uint32_t cbLeft = pModMachO->Hdr.sizeofcmds; 746 const uint8_t *pb = pModMachO->pbLoadCommands; 747 int fFirstSegment = 1; 748 PKLDRSEG pSeg = &pModMachO->pMod->aSegments[0]; 749 const uint32_t cSegments = pModMachO->pMod->cSegments; 750 uint32_t i; 751 752 while (cLeft-- > 0) 753 { 754 u.pb = pb; 755 cbLeft -= u.pLoadCmd->cmdsize; 756 pb += u.pLoadCmd->cmdsize; 757 758 /* 759 * Convert endian if needed, parse and validate the command. 760 */ 761 switch (u.pLoadCmd->cmd) 762 { 763 case LC_SEGMENT_32: 764 { 765 section_32_t *pSect; 766 section_32_t *pFirstSect; 767 uint32_t cSectionsLeft; 768 769 pModMachO->LinkAddress = u.pSeg32->vmaddr; 770 771 /* 772 * convert, validate and parse the sections. 773 */ 774 cSectionsLeft = u.pSeg32->nsects; 775 pFirstSect = pSect = (section_32_t *)(u.pSeg32 + 1); 776 while (cSectionsLeft-- > 0) 777 { 778 switch (pModMachO->Hdr.filetype) 779 { 780 case MH_OBJECT: 781 { 782 /* Don't load debug symbols. (test this) */ 783 if (pSect->flags & S_ATTR_DEBUG) 784 break; 785 786 if ( fFirstSegment 787 || kLdrHlpStrNComp(pSect->segname, (pSect - 1)->segname, sizeof(pSect->segname))) 788 { 789 /* new segment. */ 790 pSeg->pvUser = NULL; 791 pSeg->pchName = pbStringPool; 792 pSeg->cchName = (uint32_t)kLdrHlpStrNLen(&pSect->segname[0], sizeof(pSect->sectname)); 793 kLdrHlpMemCopy(pbStringPool, &pSect->segname[0], pSeg->cchName); 794 pbStringPool += pSeg->cchName; 795 *pbStringPool++ = '\0'; 796 pSeg->SelFlat = 0; 797 pSeg->Sel16bit = 0; 798 pSeg->fFlags = 0; 799 pSeg->enmProt = KLDRPROT_EXECUTE_WRITECOPY; /** @todo fixme! */ 800 pSeg->cb = pSect->size; 801 pSeg->Alignment = (1 << pSect->align); 802 pSeg->LinkAddress = pSect->addr; 803 pSeg->offFile = pSect->offset ? pSect->offset : -1; 804 pSeg->cbFile = pSect->offset ? pSect->size : -1; 805 pSeg->RVA = pSect->addr - pModMachO->LinkAddress; 806 pSeg->cbMapped = 0; 807 pSeg->MapAddress = 0; 808 809 pSeg++; 810 fFirstSegment = 0; 811 } 812 else if (!fFirstSegment) 813 { 814 /* update exiting segment */ 815 if (pSeg[-1].Alignment < (1 << pSect->align)) 816 pSeg[-1].Alignment = (1 << pSect->align); 817 if (pSect->addr < pSeg[-1].LinkAddress) 818 return KLDR_ERR_MACHO_BAD_SECTION; /** @todo move up! */ 819 820 if ( pSect->offset 821 && pSeg[-1].cbFile == pSeg[-1].cb) 822 { 823 if ( pSeg[-1].offFile + pSeg[-1].cbFile == pSect->offset 824 && pSeg[-1].cbFile == pSect->addr - pSeg[-1].LinkAddress) 825 pSeg[-1].cbFile = (off_t)(pSect->addr - pSeg[-1].LinkAddress) + pSect->size; 826 else 827 { 828 pSeg[-1].cbFile = pSeg[-1].offFile = -1; 829 pModMachO->fMapUsingLoadCommands = 1; 830 } 831 } 832 pSeg[-1].cb = pSect->addr - pSeg[-1].LinkAddress + pSect->size; 833 834 /** @todo update the protection... */ 835 } 836 break; 837 } 838 839 default: 840 return KLDR_ERR_INVALID_PARAMETER; 841 } 842 843 /* next */ 844 pSect++; 845 } 846 break; 847 } 848 849 default: 850 break; 851 } 852 } 853 854 /* 855 * Adjust mapping addresses calculating the image size. 856 */ 857 pSeg = &pModMachO->pMod->aSegments[0]; 858 switch (pModMachO->Hdr.filetype) 859 { 860 case MH_OBJECT: 861 { 862 KLDRADDR cb1; 863 size_t cb2; 864 865 for (i = 0; i < cSegments - 1; i++) 866 { 867 cb1 = pSeg[i + 1].LinkAddress - pSeg[i].LinkAddress; 868 cb2 = (size_t)cb1; 869 pSeg[i].cbMapped = cb2 == cb1 ? cb2 : ~(size_t)0; 870 } 871 cb1 = KLDR_ALIGN_ADDR(pSeg[i].cb, pSeg[i].Alignment); 872 cb2 = (size_t)cb1; 873 pSeg[i].cbMapped = cb2 == cb1 ? cb2 : ~(size_t)0; 874 875 pModMachO->cbImage = pSeg[i].RVA + cb1; 876 break; 877 } 878 } 879 710 880 return 0; 711 881 } … … 1978 2148 static KLDRADDR kldrModMachOSize(PKLDRMOD pMod) 1979 2149 { 1980 #if 01981 2150 PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData; 1982 return pModMachO->Hdrs.OptionalHeader.SizeOfImage; 1983 #else 1984 return 0; 1985 #endif 2151 return pModMachO->cbImage; 1986 2152 } 1987 2153 -
trunk/kLdr/tstkLdrMod.c
r2899 r2955 116 116 rc = kLdrModGetBits(pMod, pvBits2, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 117 117 if (rc) 118 return Failure("failed to get image bits, rc=%d ( a)", rc);118 return Failure("failed to get image bits, rc=%d (%s) (a)", rc, kLdrErrStr(rc)); 119 119 if (TestMemComp(pvBits2, pvBits, cbImage)) 120 120 return Failure("relocation test failed, mismatching bits (a)"); … … 125 125 rc = kLdrModRelocateBits(pMod, pvBits2, 0x1000, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 126 126 if (rc) 127 return Failure("failed to relocate, rc=%d ( b1)");127 return Failure("failed to relocate, rc=%d (%s) (b1)", rc, kLdrErrStr(rc)); 128 128 rc = kLdrModRelocateBits(pMod, pvBits2, (uintptr_t)pvBits, 0x1000, BasicTestsGetImport, NULL); 129 129 if (rc) 130 return Failure("failed to relocate, rc=%d ( b2)");130 return Failure("failed to relocate, rc=%d (%s) (b2)", rc, kLdrErrStr(rc)); 131 131 if (TestMemComp(pvBits2, pvBits, cbImage)) 132 132 return Failure("relocation test failed, mismatching bits (b)"); … … 138 138 rc = kLdrModRelocateBits(pMod, pvBits, 0x1000000, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 139 139 if (rc) 140 return Failure("failed to relocate, rc=%d ( c1)");140 return Failure("failed to relocate, rc=%d (%s) (c1)", rc, kLdrErrStr(rc)); 141 141 memset(pvBits2, 0xfe, cbImage); 142 142 rc = kLdrModGetBits(pMod, pvBits2, 0x1000000, BasicTestsGetImport, NULL); 143 143 if (rc) 144 return Failure("failed to get image bits, rc=%d ( c1)", rc);144 return Failure("failed to get image bits, rc=%d (%s) (c1)", rc, kLdrErrStr(rc)); 145 145 if (TestMemComp(pvBits2, pvBits, cbImage)) 146 146 return Failure("relocation test failed, mismatching bits (c1)"); … … 149 149 rc = kLdrModRelocateBits(pMod, pvBits, ~(uintptr_t)0x1010000, 0x1000000, BasicTestsGetImport, NULL); 150 150 if (rc) 151 return Failure("failed to relocate, rc=%d ( c2)");151 return Failure("failed to relocate, rc=%d (%s) (c2)", rc, kLdrErrStr(rc)); 152 152 memset(pvBits2, 0xef, cbImage); 153 153 rc = kLdrModGetBits(pMod, pvBits2, ~(uintptr_t)0x1010000, BasicTestsGetImport, NULL); 154 154 if (rc) 155 return Failure("failed to get image bits, rc=%d ( c2)", rc);155 return Failure("failed to get image bits, rc=%d (%s) (c2)", rc, kLdrErrStr(rc)); 156 156 if (TestMemComp(pvBits2, pvBits, cbImage)) 157 157 return Failure("relocation test failed, mismatching bits (c2)"); … … 160 160 rc = kLdrModRelocateBits(pMod, pvBits, MY_BASEADDRESS, ~(uintptr_t)0x1010000, BasicTestsGetImport, NULL); 161 161 if (rc) 162 return Failure("failed to relocate, rc=%d ( c3)");162 return Failure("failed to relocate, rc=%d (%s) (c3)", rc, kLdrErrStr(rc)); 163 163 memset(pvBits2, 0xef, cbImage); 164 164 rc = kLdrModGetBits(pMod, pvBits2, MY_BASEADDRESS, BasicTestsGetImport, NULL); 165 165 if (rc) 166 return Failure("failed to get image bits, rc=%d ( c3)", rc);166 return Failure("failed to get image bits, rc=%d (%s) (c3)", rc, kLdrErrStr(rc)); 167 167 if (TestMemComp(pvBits2, pvBits, cbImage)) 168 168 return Failure("relocation test failed, mismatching bits (c3)"); … … 171 171 rc = kLdrModRelocateBits(pMod, pvBits, ~(uintptr_t)0 / 2 - 0x10000, MY_BASEADDRESS, BasicTestsGetImport, NULL); 172 172 if (rc) 173 return Failure("failed to relocate, rc=%d (c4)");173 return Failure("failed to relocate, rc=%d %(s) (c4)", rc, kLdrErrStr(rc)); 174 174 memset(pvBits2, 0xdc, cbImage); 175 175 rc = kLdrModGetBits(pMod, pvBits2, ~(uintptr_t)0 / 2 - 0x10000, BasicTestsGetImport, NULL); 176 176 if (rc) 177 return Failure("failed to get image bits, rc=%d ( c4)", rc);177 return Failure("failed to get image bits, rc=%d (%s) (c4)", rc, kLdrErrStr(rc)); 178 178 if (TestMemComp(pvBits2, pvBits, cbImage)) 179 179 return Failure("relocation test failed, mismatching bits (c4)"); … … 182 182 rc = kLdrModRelocateBits(pMod, pvBits, (uintptr_t)pvBits, ~(uintptr_t)0 / 2 - 0x10000, BasicTestsGetImport, NULL); 183 183 if (rc) 184 return Failure("failed to relocate, rc=%d ( c5)");184 return Failure("failed to relocate, rc=%d (%s) (c5)", rc, kLdrErrStr(rc)); 185 185 memset(pvBits2, 0xcd, cbImage); 186 186 rc = kLdrModGetBits(pMod, pvBits2, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 187 187 if (rc) 188 return Failure("failed to get image bits, rc=%d ( c5)", rc);188 return Failure("failed to get image bits, rc=%d (%s) (c5)", rc, kLdrErrStr(rc)); 189 189 if (TestMemComp(pvBits2, pvBits, cbImage)) 190 190 return Failure("relocation test failed, mismatching bits (c5)"); … … 216 216 &uValue2, &fKind2); 217 217 if (rc) 218 return Failure("Couldn't find symbol %#x (%.*s) by ordinal. rc=%d ", iSymbol, cchSymbol, pchSymbol, rc);218 return Failure("Couldn't find symbol %#x (%.*s) by ordinal. rc=%d (%s)", iSymbol, cchSymbol, pchSymbol, rc, kLdrErrStr(rc)); 219 219 if (uValue != uValue2) 220 220 return Failure("Symbol %#x (%.*s): Value mismatch %016" PRI_KLDRADDR " != %016" PRI_KLDRADDR " (enum!=query/ord) pvBits=%p", … … 231 231 NULL, NULL, &uValue2, &fKind2); 232 232 if (rc) 233 return Failure("Couldn't find symbol %#x (%.*s) by name. rc=%d ", iSymbol, cchSymbol, pchSymbol, rc);233 return Failure("Couldn't find symbol %#x (%.*s) by name. rc=%d (%s)", iSymbol, cchSymbol, pchSymbol, rc, kLdrErrStr(rc)); 234 234 if (uValue != uValue2) 235 235 return Failure("Symbol %#x (%.*s): Value mismatch %016" PRI_KLDRADDR " != %016" PRI_KLDRADDR " (enum!=query/name) pvBits=%p", … … 292 292 rc = kLdrModGetImport(pMod, pvBits, i, szImportModule, sizeof(szImportModule)); 293 293 if (rc) 294 return Failure("failed to get import module name, rc=%d . (%.260s)", rc, szImportModule);294 return Failure("failed to get import module name, rc=%d (%s). (%.260s)", rc, kLdrErrStr(rc), szImportModule); 295 295 printf("import #%d: '%s'\n", i, szImportModule); 296 296 } … … 305 305 rc = kLdrModGetStackInfo(pMod, pvBits, MY_BASEADDRESS, &StackInfo); 306 306 if (rc) 307 return Failure("kLdrModGetStackInfo failed with rc=%d ", rc);307 return Failure("kLdrModGetStackInfo failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 308 308 printf("Stack: Address=%016" PRI_KLDRADDR " LinkAddress=%016" PRI_KLDRADDR "\n" 309 309 " cbStack=%016" PRI_KLDRSIZE " cbStackThread=%016" PRI_KLDRSIZE "\n", … … 324 324 rc = kLdrModQueryMainEntrypoint(pMod, pvBits, MY_BASEADDRESS, &MainEPAddress); 325 325 if (rc) 326 return Failure("kLdrModQueryMainEntrypoint failed with rc=%d ", rc);326 return Failure("kLdrModQueryMainEntrypoint failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 327 327 printf("Entrypoint: %016" PRI_KLDRADDR "\n", MainEPAddress); 328 328 if (MainEPAddress == ~(KLDRADDR)42) … … 342 342 printf("NO Debugger Information\n"); 343 343 else 344 return Failure("kLdrModHasDbgInfo failed with rc=%d ", rc);344 return Failure("kLdrModHasDbgInfo failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 345 345 rc = kLdrModEnumDbgInfo(pMod, pvBits, BasicTestEnumDbgInfoCallback, NULL); 346 346 if (rc) 347 return Failure("kLdrModEnumDbgInfo failed with rc=%d ", rc);347 return Failure("kLdrModEnumDbgInfo failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 348 348 349 349 … … 381 381 rc = kLdrModEnumSymbols(pMod, pvBits, MY_BASEADDRESS, 0, BasicTestsEnumSymCallback, pvBits); 382 382 if (rc) 383 return Failure("kLdrModEnumSymbols failed with rc=%d ", rc);383 return Failure("kLdrModEnumSymbols failed with rc=%d (%s)", rc, kLdrErrStr(rc)); 384 384 385 385 … … 490 490 rc = kLdrModGetBits(pMod, pvBits, (uintptr_t)pvBits, BasicTestsGetImport, NULL); 491 491 if (rc) 492 return Failure("failed to get image bits, rc=%d ", rc);492 return Failure("failed to get image bits, rc=%d (%s)", rc, kLdrErrStr(rc)); 493 493 494 494 /* … … 525 525 rc = kLdrModFixupMapping(pMod, BasicTestsGetImport, NULL); 526 526 if (rc) 527 return Failure("kLdrModFixupMapping (a) failed, rc=%d ", rc);527 return Failure("kLdrModFixupMapping (a) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 528 528 529 529 rc = kLdrModReload(pMod); 530 530 if (rc) 531 return Failure("kLdrModReload (a) failed, rc=%d ", rc);531 return Failure("kLdrModReload (a) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 532 532 533 533 rc = kLdrModReload(pMod); 534 534 if (rc) 535 return Failure("kLdrModReload (b) failed, rc=%d ", rc);535 return Failure("kLdrModReload (b) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 536 536 537 537 rc = kLdrModFixupMapping(pMod, BasicTestsGetImport, NULL); 538 538 if (rc) 539 return Failure("kLdrModFixupMapping (b) failed, rc=%d ", rc);539 return Failure("kLdrModFixupMapping (b) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 540 540 541 541 rc = kLdrModAllocTLS(pMod); 542 542 if (rc) 543 return Failure("kLdrModAllocTLS (a) failed, rc=%d ", rc);543 return Failure("kLdrModAllocTLS (a) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 544 544 kLdrModFreeTLS(pMod); 545 545 546 546 rc = kLdrModAllocTLS(pMod); 547 547 if (rc) 548 return Failure("kLdrModAllocTLS (b) failed, rc=%d ", rc);548 return Failure("kLdrModAllocTLS (b) failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 549 549 kLdrModFreeTLS(pMod); 550 550 … … 555 555 rc = BasicTestsSub2(pMod, NULL); 556 556 if (rc) 557 return Failure("BasicTestsSub2 in Map2 failed, rc=%d ", rc);557 return Failure("BasicTestsSub2 in Map2 failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 558 558 return 0; 559 559 } … … 570 570 rc = kLdrModMap(pMod); 571 571 if (rc) 572 return Failure("kLdrModMap failed, rc=%d ", rc);572 return Failure("kLdrModMap failed, rc=%d (%s)", rc, kLdrErrStr(rc)); 573 573 rc = BasicTestsSubMap2(pMod); 574 574 rc2 = kLdrModUnmap(pMod); 575 575 if (rc2) 576 576 { 577 Failure("kLdrModUnmap failed, rc=%d ", rc2);577 Failure("kLdrModUnmap failed, rc=%d (%s)", rc2, kLdrErrStr(rc2)); 578 578 rc = rc ? rc : rc2; 579 579 } … … 603 603 rc2 = kLdrModClose(pMod); 604 604 if (rc2) 605 Failure("failed to close '%s', rc=%d ", pszFilename, rc);605 Failure("failed to close '%s', rc=%d (%s)", pszFilename, rc, kLdrErrStr(rc)); 606 606 if (rc2 && !rc) 607 607 rc = rc2; 608 608 } 609 609 else 610 Failure("Failed to open '%s', rc=%d ", pszFilename, rc);610 Failure("Failed to open '%s', rc=%d (%s)", pszFilename, rc, kLdrErrStr(rc)); 611 611 return rc ? 1 : 0; 612 612 }
Note:
See TracChangeset
for help on using the changeset viewer.