4 #include <lunaix/types.h>
6 typedef unsigned int elf32_ptr_t;
7 typedef unsigned short elf32_hlf_t;
8 typedef unsigned int elf32_off_t;
9 typedef unsigned int elf32_swd_t;
10 typedef unsigned int elf32_wrd_t;
27 // [0x7f, 'E', 'L', 'F']
28 #define ELFMAGIC 0x464c457fU
41 elf32_hlf_t e_machine;
42 elf32_wrd_t e_version;
48 elf32_hlf_t e_phentsize;
50 elf32_hlf_t e_shentsize;
52 elf32_hlf_t e_shstrndx;
70 struct elf32_ehdr eheader;
71 struct elf32_phdr* pheaders;
74 #define declare_elf32(elf, elf_vfile) \
75 struct elf32 elf = { .elf_file = elf_vfile, .pheaders = (void*)0 }
78 elf32_open(struct elf32* elf, const char* path);
81 elf32_openat(struct elf32* elf, void* elf_vfile);
84 elf32_static_linked(const struct elf32* elf);
87 elf32_close(struct elf32* elf);
90 * @brief Try to find the PT_INTERP section. If found, copy it's content to
93 * @param elf Opened elf32 descriptor
95 * @param len size of path_out buffer
99 elf32_find_loader(const struct elf32* elf, char* path_out, size_t len);
102 elf32_read_ehdr(struct elf32* elf);
105 elf32_read_phdr(struct elf32* elf);
108 * @brief Estimate how much memeory will be acquired if we load all loadable
115 elf32_loadable_memsz(const struct elf32* elf);
118 elf32_load(struct load_context* ldctx, const struct elf32* elf);
120 #define SIZE_EHDR sizeof(struct elf32_ehdr)
121 #define SIZE_PHDR sizeof(struct elf32_phdr)
123 #endif /* __LUNAIX_ELF_H */