Model to ELF (writing) support, copy functionality
[centaur.git] / include / libelfu / model.h
1 #ifndef __LIBELFU_MODEL_H__
2 #define __LIBELFU_MODEL_H__
3
4 #include <sys/queue.h>
5
6 #include <elf.h>
7 #include <gelf.h>
8
9
10 typedef struct ElfuData {
11   Elf_Data data;
12
13   CIRCLEQ_ENTRY(ElfuData) elem;
14 } ElfuData;
15
16
17 typedef struct ElfuScn {
18   GElf_Shdr shdr;
19
20   CIRCLEQ_HEAD(DataList, ElfuData) dataList;
21
22   CIRCLEQ_ENTRY(ElfuScn) elem;
23 } ElfuScn;
24
25
26 typedef struct ElfuPhdr {
27   GElf_Phdr phdr;
28
29   CIRCLEQ_ENTRY(ElfuPhdr) elem;
30 } ElfuPhdr;
31
32
33 typedef struct {
34   int elfclass;
35   GElf_Ehdr ehdr;
36
37   CIRCLEQ_HEAD(ScnList, ElfuScn) scnList;
38   CIRCLEQ_HEAD(PhdrList, ElfuPhdr) phdrList;
39
40   ElfuPhdr *entryBase;
41   GElf_Addr *entryOffs;
42 } ElfuElf;
43
44
45
46 ElfuPhdr* elfu_modelFromPhdr(GElf_Phdr *phdr);
47 ElfuScn* elfu_modelFromSection(Elf_Scn *scn);
48 ElfuElf* elfu_modelFromElf(Elf *e);
49
50 void elfu_modelToElf(ElfuElf *me, Elf *e);
51
52 #endif