forked from jserv/full-stack-hello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elf.h
37 lines (25 loc) · 803 Bytes
/
elf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef ELF_H
#define ELF_H
#if __SIZEOF_POINTER__ == __SIZEOF_INT__
#define ELF_HDR_SIZE (0x34)
#else
#define ELF_HDR_SIZE (0x40)
#endif
typedef struct _elf elf;
struct _elf {
char elf_hdr[ELF_HDR_SIZE];
void *prog_hdrs;
void *sec_hdrs;
};
elf *elf_init(void);
void elf_new_prog_hdrs(elf *elf_info, unsigned short count);
void elf_set_prog_hdr(elf *elf_info,
unsigned short idx,
unsigned int mem_size,
unsigned int file_size);
int elf_write_file_hdr(int fd, elf *hdr);
int elf_write_prog_seg(elf *elf_info, int fd, unsigned short idx, void *mem);
elf *elf_read_file_hdr(int fd);
int elf_read_prog_hdrs(elf *e, int fd);
int elf_read_prog_seg(elf *e, int fd, int idx, char **mem, size_t *size);
#endif /* ELF_H */