| 550 | #if XH_ELF_DEBUG |
| 551 | |
| 552 | static void xh_elf_dump_elfheader(xh_elf_t *self) |
| 553 | { |
| 554 | static char alpha_tab[17] = "0123456789ABCDEF"; |
| 555 | int i; |
| 556 | uint8_t ch; |
| 557 | char buff[EI_NIDENT * 3 + 1]; |
| 558 | |
| 559 | for(i = 0; i < EI_NIDENT; i++) |
| 560 | { |
| 561 | ch = self->ehdr->e_ident[i]; |
| 562 | buff[i * 3 + 0] = alpha_tab[(int)((ch >> 4) & 0x0F)]; |
| 563 | buff[i * 3 + 1] = alpha_tab[(int)(ch & 0x0F)]; |
| 564 | buff[i * 3 + 2] = ' '; |
| 565 | } |
| 566 | buff[EI_NIDENT * 3] = '\0'; |
| 567 | |
| 568 | XH_LOG_DEBUG("Elf Header:\n"); |
| 569 | XH_LOG_DEBUG(" Magic: %s\n", buff); |
| 570 | XH_LOG_DEBUG(" Class: %#x\n", self->ehdr->e_ident[EI_CLASS]); |
| 571 | XH_LOG_DEBUG(" Data: %#x\n", self->ehdr->e_ident[EI_DATA]); |
| 572 | XH_LOG_DEBUG(" Version: %#x\n", self->ehdr->e_ident[EI_VERSION]); |
| 573 | XH_LOG_DEBUG(" OS/ABI: %#x\n", self->ehdr->e_ident[EI_OSABI]); |
| 574 | XH_LOG_DEBUG(" ABI Version: %#x\n", self->ehdr->e_ident[EI_ABIVERSION]); |
| 575 | XH_LOG_DEBUG(" Type: %#x\n", self->ehdr->e_type); |
| 576 | XH_LOG_DEBUG(" Machine: %#x\n", self->ehdr->e_machine); |
| 577 | XH_LOG_DEBUG(" Version: %#x\n", self->ehdr->e_version); |
| 578 | XH_LOG_DEBUG(" Entry point address: %"XH_UTIL_FMT_X"\n", self->ehdr->e_entry); |
| 579 | XH_LOG_DEBUG(" Start of program headers: %"XH_UTIL_FMT_X" (bytes into file)\n", self->ehdr->e_phoff); |
| 580 | XH_LOG_DEBUG(" Start of section headers: %"XH_UTIL_FMT_X" (bytes into file)\n", self->ehdr->e_shoff); |
| 581 | XH_LOG_DEBUG(" Flags: %#x\n", self->ehdr->e_flags); |
| 582 | XH_LOG_DEBUG(" Size of this header: %u (bytes)\n", self->ehdr->e_ehsize); |
| 583 | XH_LOG_DEBUG(" Size of program headers: %u (bytes)\n", self->ehdr->e_phentsize); |
| 584 | XH_LOG_DEBUG(" Number of program headers: %u\n", self->ehdr->e_phnum); |
| 585 | XH_LOG_DEBUG(" Size of section headers: %u (bytes)\n", self->ehdr->e_shentsize); |
| 586 | XH_LOG_DEBUG(" Number of section headers: %u\n", self->ehdr->e_shnum); |
| 587 | XH_LOG_DEBUG(" Section header string table index: %u\n", self->ehdr->e_shstrndx); |
| 588 | } |
| 589 | |
| 590 | static void xh_elf_dump_programheader(xh_elf_t *self) |
| 591 | { |