| 387 | const symbol_t* symbol_ptr { nullptr }; |
| 388 | |
| 389 | void dump(std::ostream& sstr, const std::vector<section_t>& sections, const std::vector<symbol_t>& symbols) const { |
| 390 | sstr << "reloc: symbol "; |
| 391 | if (reloc_ptr->symbol_index < symbols.size()) { |
| 392 | sstr << symbols[reloc_ptr->symbol_index].name; |
| 393 | if (reloc_ptr->symbol_index == 0) { |
| 394 | sstr << "(NULL)"; |
| 395 | } |
| 396 | } else { |
| 397 | sstr << "<invalid-symbol-idx>"; |
| 398 | } |
| 399 | sstr << ", type: " << (std::underlying_type_t<ELF_RELOCATION_TYPE_X86_64>)reloc_ptr->type_x86_64; |
| 400 | sstr << ", add: " << reloc_ptr->addend; |
| 401 | bool found_section = false; |
| 402 | for (const auto& section : sections) { |
| 403 | if (reloc_ptr->offset >= section.header_ptr->offset && |
| 404 | reloc_ptr->offset < (section.header_ptr->offset + section.header_ptr->size)) { |
| 405 | sstr << ", section: " << section.name; |
| 406 | found_section = true; |
| 407 | break; |
| 408 | } |
| 409 | } |
| 410 | if (!found_section) { |
| 411 | sstr << ", section: <unknown>"; |
| 412 | } |
| 413 | sstr << ", offset: " << reloc_ptr->offset; |
| 414 | sstr << "\n"; |
| 415 | } |
| 416 | }; |
| 417 | |
| 418 | struct elf_binary::elf_info_t { |