diff --git a/src/query.c b/src/query.c index c38cf14..28050bd 100644 --- a/src/query.c +++ b/src/query.c @@ -12,6 +12,7 @@ #include #include #include +#include #include enum { @@ -131,6 +132,52 @@ static void print_tag_info(struct ec3_image_ioctx *image) printf(" %-8s: %llu bytes\n", "size", tags[i].tag_total_length); + + if (tags[i].tag_type != EC3_TAG_EXEC) { + continue; + } + + printf(" %-8s: ", "exec"); + + const struct ec3_tag_executable_info *exec = &tags[i].tag_exe; + + switch (exec->exe_format) { + case EC3_EXEC_ELF: + printf("ELF\n"); + printf(" entry = [%06" PRIx64 "]\n", + exec->exe_elf.elf_entry); + printf(" text = [0x%06" PRIx32 + "-0x%06" PRIx32 "]->[0x%016" PRIx64 + "-0x%016" PRIx64 + "] " + "(align=0x%" PRIx32 ")\n", + exec->exe_elf.elf_text_offset, + exec->exe_elf.elf_text_offset + + exec->exe_elf.elf_text_filesz, + exec->exe_elf.elf_text_vaddr, + exec->exe_elf.elf_text_vaddr + + exec->exe_elf.elf_text_memsz, + exec->exe_elf.elf_text_align); + printf(" data = [0x%06" PRIx32 + "-0x%06" PRIx32 "]->[0x%016" PRIx64 + "-0x%016" PRIx64 + "] " + "(align=0x%" PRIx32 ")\n", + exec->exe_elf.elf_data_offset, + exec->exe_elf.elf_data_offset + + exec->exe_elf.elf_data_filesz, + exec->exe_elf.elf_data_vaddr, + exec->exe_elf.elf_data_vaddr + + exec->exe_elf.elf_data_memsz, + exec->exe_elf.elf_data_align); + break; + case EC3_EXEC_OTHER: + printf("OTHER\n"); + break; + case EC3_EXEC_NONE: + printf("NONE\n"); + break; + } } } diff --git a/src/tag.h b/src/tag.h index f9be46a..c755afa 100644 --- a/src/tag.h +++ b/src/tag.h @@ -14,18 +14,42 @@ struct b_file; enum ec3_tag_ioctx_mode { EC3_TAG_IO_READ = 0x01u, EC3_TAG_IO_WRITE = 0x02u, - EC3_TAG_IO_READWRITE = 0x03u, + EC3_TAG_IO_READWRITE = EC3_TAG_IO_READ | EC3_TAG_IO_WRITE, EC3_TAG_IO_SEQUENTIAL = 0x04u, EC3_TAG_IO_CLOSED = 0x10u, }; +struct ec3_tag_executable_info { + unsigned int exe_format; + + union { + struct { + uint32_t elf_data_offset; + uint32_t elf_data_filesz, elf_data_memsz; + + uint32_t elf_text_offset; + uint32_t elf_text_filesz, elf_text_memsz; + + uint32_t elf_data_align, elf_text_align; + + uint64_t elf_data_vaddr; + uint64_t elf_text_vaddr; + uint64_t elf_entry; + } exe_elf; + }; +}; + struct ec3_tag_info { unsigned long tag_type; unsigned long tag_flags; unsigned long tag_checksum; unsigned long long tag_ident; unsigned long long tag_total_length; + + union { + struct ec3_tag_executable_info tag_exe; + }; }; struct ec3_tag_ioctx { @@ -37,7 +61,6 @@ struct ec3_tag_ioctx { /* temp buffer of cluster size, used for pipeline operations */ void *io_cluster_buf; - /* this points to memory belonging to ec3_image_ioctx */ struct ec3_tag_info io_tag_info; /* io_f_rotag is a reference to the main image file. a data and cluster