| 414 | } |
| 415 | |
| 416 | uintptr_t |
| 417 | CoreFileExtractor::findExecFn() const |
| 418 | { |
| 419 | LOG(DEBUG) << "Extracting ExecFn information"; |
| 420 | // If we have section headers, look for SHT_NOTE sections. |
| 421 | // In a core file, the program headers may not be reliable. |
| 422 | |
| 423 | Elf* elf = d_analyzer->d_elf.get(); |
| 424 | uintptr_t result = 0; |
| 425 | size_t shnum; |
| 426 | |
| 427 | if (elf_getshdrnum(elf, &shnum) < 0) { |
| 428 | LOG(ERROR) << "Cannot determine the number of sections in the ELF file"; |
| 429 | return (uintptr_t) nullptr; |
| 430 | } |
| 431 | |
| 432 | LOG(DEBUG) << "Found " << shnum << " sections in the ELF file"; |
| 433 | |
| 434 | if (shnum != 0) { |
| 435 | Elf_Scn* scn = nullptr; |
| 436 | while ((scn = elf_nextscn(elf, scn)) != nullptr) { |
| 437 | GElf_Shdr shdr_mem; |
| 438 | GElf_Shdr* shdr = gelf_getshdr(scn, &shdr_mem); |
| 439 | if (shdr == nullptr || shdr->sh_type != SHT_NOTE) { |
| 440 | continue; |
| 441 | } |
| 442 | LOG(DEBUG) << "Valid SHT_NOTE segment found with offset " << std::hex << std::showbase |
| 443 | << shdr->sh_offset << ". Attempting to get ExecDn structure"; |
| 444 | Elf_Data* data = elf_getdata(scn, nullptr); |
| 445 | const NoteData note_data{elf, data, shdr->sh_offset}; |
| 446 | if (parseCoreExecfn(note_data, &result) != StatusCode::ERROR) { |
| 447 | LOG(DEBUG) << "ExecFn structure found"; |
| 448 | return result; |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | LOG(DEBUG) << "Failed to locate the NOTE section via section headers"; |
| 454 | LOG(DEBUG) << "Attempting to get ExecFn from auxiliary vector"; |
| 455 | |
| 456 | for (const auto& note_data : getNoteData(elf, NT_AUXV, ELF_T_AUXV)) { |
| 457 | if (parseCoreExecfn(note_data, &result) != StatusCode::ERROR) { |
| 458 | LOG(DEBUG) << "ExecFn structure found"; |
| 459 | return result; |
| 460 | } |
| 461 | } |
| 462 | LOG(ERROR) << "Failed to extract the ExecFn information from the core file"; |
| 463 | return (uintptr_t) nullptr; |
| 464 | } |
| 465 | std::vector<std::string> |
| 466 | CoreFileExtractor::missingModules() const |
| 467 | { |
nothing calls this directly
no test coverage detected