query: output executable metadata for EXEC tags
This commit is contained in:
47
src/query.c
47
src/query.c
@@ -12,6 +12,7 @@
|
|||||||
#include <blue/term.h>
|
#include <blue/term.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -131,6 +132,52 @@ static void print_tag_info(struct ec3_image_ioctx *image)
|
|||||||
printf(" %-8s: %llu bytes\n",
|
printf(" %-8s: %llu bytes\n",
|
||||||
"size",
|
"size",
|
||||||
tags[i].tag_total_length);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
src/tag.h
27
src/tag.h
@@ -14,18 +14,42 @@ struct b_file;
|
|||||||
enum ec3_tag_ioctx_mode {
|
enum ec3_tag_ioctx_mode {
|
||||||
EC3_TAG_IO_READ = 0x01u,
|
EC3_TAG_IO_READ = 0x01u,
|
||||||
EC3_TAG_IO_WRITE = 0x02u,
|
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_SEQUENTIAL = 0x04u,
|
||||||
EC3_TAG_IO_CLOSED = 0x10u,
|
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 {
|
struct ec3_tag_info {
|
||||||
unsigned long tag_type;
|
unsigned long tag_type;
|
||||||
unsigned long tag_flags;
|
unsigned long tag_flags;
|
||||||
unsigned long tag_checksum;
|
unsigned long tag_checksum;
|
||||||
unsigned long long tag_ident;
|
unsigned long long tag_ident;
|
||||||
unsigned long long tag_total_length;
|
unsigned long long tag_total_length;
|
||||||
|
|
||||||
|
union {
|
||||||
|
struct ec3_tag_executable_info tag_exe;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ec3_tag_ioctx {
|
struct ec3_tag_ioctx {
|
||||||
@@ -37,7 +61,6 @@ struct ec3_tag_ioctx {
|
|||||||
/* temp buffer of cluster size, used for pipeline operations */
|
/* temp buffer of cluster size, used for pipeline operations */
|
||||||
void *io_cluster_buf;
|
void *io_cluster_buf;
|
||||||
|
|
||||||
/* this points to memory belonging to ec3_image_ioctx */
|
|
||||||
struct ec3_tag_info io_tag_info;
|
struct ec3_tag_info io_tag_info;
|
||||||
|
|
||||||
/* io_f_rotag is a reference to the main image file. a data and cluster
|
/* io_f_rotag is a reference to the main image file. a data and cluster
|
||||||
|
|||||||
Reference in New Issue
Block a user