Changeset 86305 in vbox
- Timestamp:
- Sep 26, 2020 12:10:23 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/darwin/dbgkrnlinfo-r0drv-darwin.cpp
r86290 r86305 314 314 315 315 316 /* 317 * Determine the load displacement (10.8 kernels are PIE). 318 * 319 * Starting with 11.0 (BigSur) all segments can have different load displacements 320 * so determine the displacements from known symbols. 321 * 322 * @returns IPRT status code 323 * @param pThis The internal scratch data. 324 */ 325 static int rtR0DbgKrnlDarwinInitLoadDisplacements(RTDBGKRNLINFOINT *pThis) 326 { 327 static struct 328 { 329 const char *pszName; 330 uintptr_t uAddr; 331 } const s_aStandardSyms[] = 332 { 333 #ifdef IN_RING0 334 # define KNOWN_ENTRY(a_Sym) { #a_Sym, (uintptr_t)&a_Sym } 335 #else 336 # define KNOWN_ENTRY(a_Sym) { #a_Sym, 0 } 337 #endif 338 KNOWN_ENTRY(vm_map_unwire), /* __TEXT */ 339 KNOWN_ENTRY(kernel_map), /* __HIB */ 340 KNOWN_ENTRY(gIOServicePlane) /* __DATA */ 341 #undef KNOWN_ENTRY 342 }; 343 344 for (unsigned i = 0; i < RT_ELEMENTS(s_aStandardSyms); i++) 345 { 346 MY_NLIST const *pSym = rtR0DbgKrnlDarwinLookupSym(pThis, s_aStandardSyms[i].pszName); 347 if (RT_UNLIKELY(!pSym)) 348 return VERR_INTERNAL_ERROR_2; 349 350 uint8_t idxSeg = pThis->auSections2Segment[pSym->n_sect]; 351 #ifdef IN_RING0 352 /* 353 * The segment should either not have the load displacement determined or it should 354 * be the same for all symbols in the same segment. 355 */ 356 if ( pThis->aoffLoadSegments[idxSeg] != UINTPTR_MAX 357 && pThis->aoffLoadSegments[idxSeg] != s_aStandardSyms[i].uAddr - pSym->n_value) 358 return VERR_INTERNAL_ERROR_2; 359 360 pThis->aoffLoadSegments[idxSeg] = s_aStandardSyms[i].uAddr - pSym->n_value; 361 #elif defined(IN_RING3) 362 pThis->aoffLoadSegments[idxSeg] = 0; 363 #else 364 # error "Either IN_RING0 or IN_RING3 msut be defined" 365 #endif 366 } 367 368 return VINF_SUCCESS; 369 } 370 371 316 372 /** 317 373 * Check the symbol table against symbols we known symbols. … … 444 500 KNOWN_ENTRY(kernel_map), 445 501 KNOWN_ENTRY(kernel_pmap), 502 #undef KNOWN_ENTRY 446 503 }; 447 504 … … 1150 1207 if (RT_SUCCESS(rc)) 1151 1208 { 1152 #ifdef IN_RING0 1153 /* 1154 * Determine the load displacement (10.8 kernels are PIE). 1155 * 1156 * Starting with 11.0 (BigSur) all segments can have different load displacements 1157 * so determine the displacements from known symbols. 1158 */ 1159 /* __TEXT */ 1160 MY_NLIST const *pSym = rtR0DbgKrnlDarwinLookupSym(pThis, "vm_map_unwire"); 1161 if (pSym) 1162 { 1163 uint8_t idxSeg = pThis->auSections2Segment[pSym->n_sect]; 1164 pThis->aoffLoadSegments[idxSeg] = (uintptr_t)&vm_map_unwire - pSym->n_value; 1165 } 1166 1167 /* __HIB */ 1168 pSym = rtR0DbgKrnlDarwinLookupSym(pThis, "kernel_map"); 1169 if (pSym) 1170 { 1171 uint8_t idxSeg = pThis->auSections2Segment[pSym->n_sect]; 1172 pThis->aoffLoadSegments[idxSeg] = (uintptr_t)&kernel_map - pSym->n_value; 1173 } 1174 1175 /* __DATA */ 1176 pSym = rtR0DbgKrnlDarwinLookupSym(pThis, "gIOServicePlane"); 1177 if (pSym) 1178 { 1179 uint8_t idxSeg = pThis->auSections2Segment[pSym->n_sect]; 1180 pThis->aoffLoadSegments[idxSeg] = (uintptr_t)&gIOServicePlane - pSym->n_value; 1181 } 1182 #endif 1183 rc = rtR0DbgKrnlDarwinCheckStandardSymbols(pThis, pszKernelFile); 1209 rc = rtR0DbgKrnlDarwinInitLoadDisplacements(pThis); 1210 if (RT_SUCCESS(rc)) 1211 rc = rtR0DbgKrnlDarwinCheckStandardSymbols(pThis, pszKernelFile); 1184 1212 } 1185 1213 … … 1354 1382 if (RT_SUCCESS(rc)) 1355 1383 { 1356 /* 1357 * Finally check the standard candles. 1358 */ 1359 rc = rtR0DbgKrnlDarwinCheckStandardSymbols(pThis, "in-memory"); 1360 rtR0DbgKrnlDarwinLoadDone(pThis); 1384 rc = rtR0DbgKrnlDarwinInitLoadDisplacements(pThis); 1361 1385 if (RT_SUCCESS(rc)) 1362 return rtR0DbgKrnlDarwinSuccess(phKrnlInfo, pThis, "in-memory"); 1386 { 1387 /* 1388 * Finally check the standard candles. 1389 */ 1390 rc = rtR0DbgKrnlDarwinCheckStandardSymbols(pThis, "in-memory"); 1391 rtR0DbgKrnlDarwinLoadDone(pThis); 1392 if (RT_SUCCESS(rc)) 1393 return rtR0DbgKrnlDarwinSuccess(phKrnlInfo, pThis, "in-memory"); 1394 } 1363 1395 } 1364 1396 }
Note:
See TracChangeset
for help on using the changeset viewer.