MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / esp_elf_print_ehdr

Function esp_elf_print_ehdr

Libraries/elf_loader/src/esp_elf.c:554–603  ·  view source on GitHub ↗

* @brief Print header description information of ELF. * * @param pbuf - ELF data buffer * * @return None */

Source from the content-addressed store, hash-verified

552 * @return None
553 */
554void esp_elf_print_ehdr(const uint8_t *pbuf)
555{
556 const char *s_bits, *s_endian;
557 const elf32_hdr_t *hdr = (const elf32_hdr_t *)pbuf;
558
559 switch (hdr->ident[4]) {
560 case 1:
561 s_bits = "32-bit";
562 break;
563 case 2:
564 s_bits = "64-bit";
565 break;
566 default:
567 s_bits = "invalid bits";
568 break;
569 }
570
571 switch (hdr->ident[5]) {
572 case 1:
573 s_endian = "little-endian";
574 break;
575 case 2:
576 s_endian = "big-endian";
577 break;
578 default:
579 s_endian = "invalid endian";
580 break;
581 }
582
583 if (hdr->ident[0] == 0x7f) {
584 ESP_LOGI(TAG, "%-40s %c%c%c", "Class:", hdr->ident[1], hdr->ident[2], hdr->ident[3]);
585 }
586
587 ESP_LOGI(TAG, "%-40s %s, %s", "Format:", s_bits, s_endian);
588 ESP_LOGI(TAG, "%-40s %x", "Version(current):", hdr->ident[6]);
589
590 ESP_LOGI(TAG, "%-40s %d", "Type:", hdr->type);
591 ESP_LOGI(TAG, "%-40s %d", "Machine:", hdr->machine);
592 ESP_LOGI(TAG, "%-40s %x", "Version:", hdr->version);
593 ESP_LOGI(TAG, "%-40s %x", "Entry point address:", hdr->entry);
594 ESP_LOGI(TAG, "%-40s %x", "Start of program headers:", hdr->phoff);
595 ESP_LOGI(TAG, "%-40s %d", "Start of section headers:", hdr->shoff);
596 ESP_LOGI(TAG, "%-40s 0x%x", "Flags:", hdr->flags);
597 ESP_LOGI(TAG, "%-40s %d", "Size of this header(bytes):", hdr->ehsize);
598 ESP_LOGI(TAG, "%-40s %d", "Size of program headers(bytes):", hdr->phentsize);
599 ESP_LOGI(TAG, "%-40s %d", "Number of program headers:", hdr->phnum);
600 ESP_LOGI(TAG, "%-40s %d", "Size of section headers(bytes):", hdr->shentsize);
601 ESP_LOGI(TAG, "%-40s %d", "Number of section headers:", hdr->shnum);
602 ESP_LOGI(TAG, "%-40s %d", "Section header string table i:", hdr->shstrndx);
603}
604
605/**
606 * @brief Print program header description information of ELF.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected