AcessNative - Little fixes to get it running on 64-bit
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / elf64.h
1 /*
2  * Acess2 Dynamic Linker
3  *
4  * elf64.h
5  */
6
7 #ifndef _ELF64_H_
8 #define _ELF64_H_
9
10 #define ELFCLASS64      2
11
12 #define EM_X86_64       62
13
14 typedef uint16_t        Elf64_Half;
15 typedef uint32_t        Elf64_Word;
16
17 typedef uint64_t        Elf64_Addr;
18 typedef uint64_t        Elf64_Off;
19 typedef uint64_t        Elf64_Xword;
20 typedef  int64_t        Elf64_Sxword;
21
22 typedef struct
23 {
24         unsigned char   e_ident[16];
25         Elf64_Half      e_type;
26         Elf64_Half      e_machine;
27         Elf64_Word      e_version;
28         Elf64_Addr      e_entry;
29         Elf64_Off       e_phoff;
30         Elf64_Off       e_shoff;
31         Elf64_Word      e_flags;
32         Elf64_Half      e_ehsize;
33         Elf64_Half      e_phentsize;
34         Elf64_Half      e_phnum;
35         Elf64_Half      e_shentsize;
36         Elf64_Half      e_shnum;
37         Elf64_Half      e_shstrndx;
38 } __attribute__((packed)) Elf64_Ehdr;
39
40 typedef struct
41 {
42         Elf64_Word      sh_name;
43         Elf64_Word      sh_type;
44         Elf64_Xword     sh_flags;
45         Elf64_Addr      sh_addr;
46         Elf64_Off       sh_offset;
47         Elf64_Xword     sh_size;
48         Elf64_Word      sh_link;
49         Elf64_Word      sh_info;
50         Elf64_Xword     sh_addralign;
51         Elf64_Xword     sh_entsize;
52 } Elf64_Shdr;
53
54 typedef struct
55 {
56         Elf64_Word      p_type;
57         Elf64_Word      p_flags;
58         Elf64_Off       p_offset;
59         Elf64_Addr      p_vaddr;
60         Elf64_Addr      p_paddr;
61         Elf64_Xword     p_filesz;
62         Elf64_Xword     p_memsz;
63         Elf64_Xword     p_align;
64 } Elf64_Phdr;
65
66 typedef struct
67 {
68         Elf64_Sxword    d_tag;
69         union {
70                 Elf64_Xword     d_val;
71                 Elf64_Addr      d_ptr;
72         } d_un;
73 } Elf64_Dyn;
74
75 typedef struct
76 {
77         Elf64_Word      st_name;
78         uint8_t         st_info;
79         uint8_t         st_other;
80         Elf64_Half      st_shndx;
81         Elf64_Addr      st_value;
82         Elf64_Xword     st_size;
83 } Elf64_Sym;
84
85 typedef struct
86 {
87         Elf64_Addr      r_offset;
88         Elf64_Xword     r_info;
89 } Elf64_Rel;
90
91 typedef struct
92 {
93         Elf64_Addr      r_offset;
94         Elf64_Xword     r_info;
95         Elf64_Sxword    r_addend;
96 } Elf64_Rela;
97
98 #define ELF64_R_SYM(info)       ((info) >> 32)
99 #define ELF64_R_TYPE(info)      ((info) & 0xFFFFFFFF)
100
101 enum eElf64_RelocTypes_x86_64
102 {
103         R_X86_64_NONE,
104         R_X86_64_64,    // 64, S + A
105         R_X86_64_PC32,  // 32, S + A - P
106         R_X86_64_GOT32, // 32, G + A
107         R_X86_64_PLT32, // 32, L + A - P
108         R_X86_64_COPY,
109         R_X86_64_GLOB_DAT,      // 64, S
110         R_X86_64_JUMP_SLOT,     // 64, S
111         R_X86_64_RELATIVE,      // 64, B + A
112         // TODO: Rest
113 };
114
115 #endif
116

UCC git Repository :: git.ucc.asn.au