asm: implement object file reader

This commit is contained in:
2025-05-12 15:51:03 +01:00
parent 2e4d1e53f3
commit 8d9ae5f36a
3 changed files with 245 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
#ifndef IVY_ASM_READER_H_
#define IVY_ASM_READER_H_
#include <ivy/misc.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
struct ivy_asm_object_info {
uint32_t obj_magic;
size_t obj_table_offset;
size_t obj_nr_sections;
};
struct ivy_asm_section_info {
uint32_t s_type;
size_t s_offset;
size_t s_length;
};
struct ivy_asm_reader;
struct ivy_asm_section_reader;
IVY_API enum ivy_status ivy_asm_reader_open(FILE *in, struct ivy_asm_reader **out);
IVY_API enum ivy_status ivy_asm_reader_close(struct ivy_asm_reader *reader);
IVY_API const struct ivy_asm_object_info *ivy_asm_reader_get_info(
struct ivy_asm_reader *reader);
IVY_API const struct ivy_asm_section_info *ivy_asm_reader_get_sections(
struct ivy_asm_reader *reader);
IVY_API enum ivy_status ivy_asm_reader_open_section(
struct ivy_asm_reader *reader, size_t index,
struct ivy_asm_section_reader **out);
IVY_API const struct ivy_asm_section_info *ivy_asm_section_reader_get_info(
struct ivy_asm_section_reader *reader);
IVY_API enum ivy_status ivy_asm_section_reader_close(
struct ivy_asm_section_reader *reader);
IVY_API enum ivy_status ivy_asm_section_reader_read(
struct ivy_asm_section_reader *reader, size_t offset, size_t count,
void *p, size_t *nr_read);
IVY_API bool ivy_asm_section_type_to_string(uint32_t in, char out[5]);
#endif