儲存庫 vbox 的更動 16437
- 時間撮記:
- 2009-1-31 上午01:49:27 (16 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Runtime/testcase/tstLdr.cpp
r14831 r16437 46 46 *******************************************************************************/ 47 47 /** If set, don't bitch when failing to resolve symbols. */ 48 static bool g_fDontBitchOnResolveFailure = false; 48 static bool g_fDontBitchOnResolveFailure = false; 49 /** Whether it's kernel model code or not.. */ 50 static bool g_fKernel = true; 51 /** Module architectur bit count. */ 52 static uint32_t g_cBits = HC_ARCH_BITS; 53 49 54 50 55 /** … … 61 66 static DECLCALLBACK(int) testGetImport(RTLDRMOD hLdrMod, const char *pszModule, const char *pszSymbol, unsigned uSymbol, RTUINTPTR *pValue, void *pvUser) 62 67 { 63 /* check the name format and only permit certain names */ 64 *pValue = 0xabcdef0f; 68 /* check the name format and only permit certain names... later, right? */ 69 70 if (g_cBits == 32) 71 *pValue = 0xabcdef0f; 72 else 73 { 74 RTUINTPTR BaseAddr = *(PCRTUINTPTR)pvUser; 75 if (g_fKernel) 76 *pValue = BaseAddr & RT_BIT(31) ? -(int32_t)0x76634935 : 0x7f304938; 77 else 78 *pValue = (int32_t)0x76634935 * ((BaseAddr >> 8) & 7); 79 } 65 80 return VINF_SUCCESS; 66 81 } … … 90 105 } aLoads[6] = 91 106 { 92 { NULL, NULL, 0xefefef00, "foo" },93 { NULL, NULL, 0x40404040, "bar" },94 { NULL, NULL, 0xefefef00, "foobar" },95 { NULL, NULL, 0xefefef00, "kLdr-foo" },96 { NULL, NULL, 0x40404040, "kLdr-bar" },97 { NULL, NULL, 0xefefef00, "kLdr-foobar" }107 { NULL, NULL, (int32_t)0xefefef00, "foo" }, 108 { NULL, NULL, (int32_t)0x40404040, "bar" }, 109 { NULL, NULL, (int32_t)0xefefef00, "foobar" }, 110 { NULL, NULL, (int32_t)0xefefef00, "kLdr-foo" }, 111 { NULL, NULL, (int32_t)0x40404040, "kLdr-bar" }, 112 { NULL, NULL, (int32_t)0xefefef00, "kLdr-foobar" } 98 113 }; 99 114 unsigned i; … … 104 119 for (i = 0; i < RT_ELEMENTS(aLoads); i++) 105 120 { 121 /* adjust load address and announce our intentions */ 122 if (g_cBits == 32) 123 aLoads[i].Addr &= UINT32_C(0xffffffff); 124 RTPrintf("tstLdr: Loading image at %RTptr\n", aLoads[i].Addr); 125 126 /* open it */ 106 127 int rc; 107 128 if (!strncmp(aLoads[i].pszName, "kLdr-", sizeof("kLdr-") - 1)) … … 137 158 138 159 /* Get the bits. */ 139 rc = RTLdrGetBits(aLoads[i].hLdrMod, aLoads[i].pvBits, aLoads[i].Addr, testGetImport, NULL);160 rc = RTLdrGetBits(aLoads[i].hLdrMod, aLoads[i].pvBits, aLoads[i].Addr, testGetImport, &aLoads[i].Addr); 140 161 if (RT_FAILURE(rc)) 141 162 { … … 153 174 static RTUINTPTR aRels[] = 154 175 { 155 0xefefef00,/* same. */156 0x40404040,/* the other. */157 0xefefef00,/* back. */158 0x40404040,/* the other. */159 0xefefef00,/* back again. */160 0x77773420,/* somewhere entirely else. */161 0xf0000000,/* somewhere entirely else. */162 0x40404040,/* the other. */163 0xefefef00/* back again. */176 (int32_t)0xefefef00, /* same. */ 177 (int32_t)0x40404040, /* the other. */ 178 (int32_t)0xefefef00, /* back. */ 179 (int32_t)0x40404040, /* the other. */ 180 (int32_t)0xefefef00, /* back again. */ 181 (int32_t)0x77773420, /* somewhere entirely else. */ 182 (int32_t)0xf0000000, /* somewhere entirely else. */ 183 (int32_t)0x40404040, /* the other. */ 184 (int32_t)0xefefef00 /* back again. */ 164 185 }; 165 186 struct Symbols … … 184 205 for (;;) 185 206 { 207 /* adjust load address and announce our intentions */ 208 if (g_cBits == 32) 209 aRels[iRel] &= UINT32_C(0xffffffff); 210 186 211 /* Compare all which are at the same address. */ 187 212 for (i = 0; i < RT_ELEMENTS(aLoads) - 1; i++) … … 194 219 { 195 220 RTPrintf("tstLdr: Mismatch between load %d and %d. ('%s')\n", j, i, pszFilename); 221 #if 1 196 222 const uint8_t *pu8J = (const uint8_t *)aLoads[j].pvBits; 197 223 const uint8_t *pu8I = (const uint8_t *)aLoads[i].pvBits; … … 199 225 if (*pu8J != *pu8I) 200 226 RTPrintf(" %08x %02x != %02x\n", off, *pu8J, *pu8I); 227 #else 228 const uint32_t *pu32J = (const uint32_t *)aLoads[j].pvBits; 229 const uint32_t *pu32I = (const uint32_t *)aLoads[i].pvBits; 230 for (uint32_t off = 0; off < cbImage; off += 4, pu32J++, pu32I++) 231 if (*pu32J != *pu32I) 232 RTPrintf(" %08x %08x != %08x\n", off, *pu32J, *pu32I); 233 #endif 201 234 rcRet++; 235 break; 202 236 } 203 237 } … … 245 279 246 280 /* relocate it stuff. */ 247 int rc = RTLdrRelocate(aLoads[2].hLdrMod, aLoads[2].pvBits, aRels[iRel], aLoads[2].Addr, testGetImport, NULL); 281 RTPrintf("tstLdr: Relocating image 2 from %RTptr to %RTptr\n", aLoads[2].Addr, aRels[iRel]); 282 int rc = RTLdrRelocate(aLoads[2].hLdrMod, aLoads[2].pvBits, aRels[iRel], aLoads[2].Addr, testGetImport, &aRels[iRel]); 248 283 if (RT_FAILURE(rc)) 249 284 { … … 290 325 if (argc <= 1) 291 326 { 292 RTPrintf("usage: %s <module> [moremodules]\n", argv[0]);327 RTPrintf("usage: %s [-32|-64] [-kernel] <module> [more options/modules]\n", argv[0]); 293 328 return 1; 294 329 } … … 299 334 for (int argi = 1; argi < argc; argi++) 300 335 { 301 if ( argv[argi][0] == '-' && argv[argi][1] == 'n')336 if (!strcmp(argv[argi], "-n")) 302 337 g_fDontBitchOnResolveFailure = true; 338 else if (!strcmp(argv[argi], "-32")) 339 g_cBits = 32; 340 else if (!strcmp(argv[argi], "-64")) 341 g_cBits = 64; 342 else if (!strcmp(argv[argi], "-kernel")) 343 g_fKernel = 64; 303 344 else 304 345 {
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器