1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00
libkernaux/include/kernaux/elf.h

82 lines
2 KiB
C
Raw Normal View History

2021-12-12 15:30:27 -05:00
#ifndef KERNAUX_INCLUDED_ELF
2021-12-20 01:17:53 -05:00
#define KERNAUX_INCLUDED_ELF
2021-12-12 15:30:27 -05:00
#ifdef __cplusplus
extern "C" {
#endif
2021-12-13 15:46:58 -05:00
#include <stdbool.h>
2021-12-12 15:30:27 -05:00
struct KernAux_ELF_Header {
2022-01-23 21:50:16 -05:00
unsigned magic_0x7f : 8;
unsigned magic_E : 8;
unsigned magic_L : 8;
unsigned magic_F : 8;
unsigned bitness : 8;
unsigned endianness : 8;
unsigned header_version : 8;
unsigned os_abi : 8;
unsigned unused1 : 32;
unsigned unused2 : 32;
unsigned obj_type : 16;
unsigned isa : 16;
unsigned elf_version : 32;
unsigned entrypoint : 32;
unsigned prog_table_pos : 32;
unsigned sect_table_pos : 32;
unsigned arch_flags : 32;
unsigned header_size : 16;
unsigned prog_entr_size : 16;
unsigned prog_entr_num : 16;
unsigned sect_entr_size : 16;
unsigned sect_entr_num : 16;
unsigned sect_names_idx : 16;
2021-12-12 15:30:27 -05:00
}
__attribute__((packed));
struct KernAux_ELF_ProgramEntry {
unsigned type : 32;
unsigned offset : 32;
unsigned virt_addr : 32;
unsigned phys_addr : 32;
unsigned file_size : 32;
unsigned mem_size : 32;
unsigned flags : 32;
unsigned align : 32;
2021-12-12 15:30:27 -05:00
}
__attribute__((packed));
struct KernAux_ELF_SectionEntry {
unsigned name : 32;
unsigned type : 32;
unsigned flags : 32;
unsigned vaddr : 32;
unsigned file_offset : 32;
unsigned file_size : 32;
unsigned link : 32;
unsigned info : 32;
unsigned alignment : 32;
unsigned ent_size : 32;
2021-12-12 15:30:27 -05:00
}
__attribute__((packed));
struct KernAux_ELF_RelocationEntry {
unsigned virt_addr : 32;
unsigned info : 32;
2021-12-12 15:30:27 -05:00
}
__attribute__((packed));
typedef struct KernAux_ELF_ProgramEntry KernAux_ELF_ProgramTable[];
typedef struct KernAux_ELF_SectionEntry KernAux_ELF_SectionTable[];
typedef struct KernAux_ELF_RelocationEntry KernAux_ELF_RelocationTable[];
2021-12-13 17:07:00 -05:00
bool KernAux_ELF_Header_is_valid(const struct KernAux_ELF_Header *header);
2021-12-12 15:30:27 -05:00
#ifdef __cplusplus
}
#endif
#endif