NASM 2.06rc15
[nasm/avx512.git] / output / elf64.h
blob8df6e6fef15158f657b1ce2d98ad1d3235e48bf6
1 #ifndef OUTPUT_ELF64_H
2 #define OUTPUT_ELF64_H
4 #include "output/elfcommon.h"
6 /* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
7 typedef uint16_t Elf64_Half;
8 typedef int16_t Elf64_SHalf;
9 typedef uint32_t Elf64_Word;
10 typedef int32_t Elf64_Sword;
11 typedef uint64_t Elf64_Xword;
12 typedef int64_t Elf64_Sxword;
14 typedef uint64_t Elf64_Off;
15 typedef uint64_t Elf64_Addr;
16 typedef uint16_t Elf64_Section;
18 /* Dynamic header */
20 typedef struct elf64_dyn {
21 Elf64_Sxword d_tag;
22 union {
23 Elf64_Xword d_val;
24 Elf64_Addr d_ptr;
25 } d_un;
26 } Elf64_Dyn;
28 /* Relocations */
30 #define ELF64_R_SYM(x) ((x) >> 32)
31 #define ELF64_R_TYPE(x) ((x) & 0xffffffff)
33 typedef struct elf64_rel {
34 Elf64_Addr r_offset;
35 Elf64_Xword r_info;
36 } Elf64_Rel;
38 typedef struct elf64_rela {
39 Elf64_Addr r_offset;
40 Elf64_Xword r_info;
41 Elf64_Sxword r_addend;
42 } Elf64_Rela;
44 enum reloc64_type {
45 R_X86_64_NONE = 0, /* No reloc */
46 R_X86_64_64 = 1, /* Direct 64 bit */
47 R_X86_64_PC32 = 2, /* PC relative 32 bit signed */
48 R_X86_64_GOT32 = 3, /* 32 bit GOT entry */
49 R_X86_64_PLT32 = 4, /* 32 bit PLT address */
50 R_X86_64_COPY = 5, /* Copy symbol at runtime */
51 R_X86_64_GLOB_DAT = 6, /* Create GOT entry */
52 R_X86_64_JUMP_SLOT = 7, /* Create PLT entry */
53 R_X86_64_RELATIVE = 8, /* Adjust by program base */
54 R_X86_64_GOTPCREL = 9, /* 32 bit signed PC relative offset to GOT */
55 R_X86_64_32 = 10, /* Direct 32 bit zero extended */
56 R_X86_64_32S = 11, /* Direct 32 bit sign extended */
57 R_X86_64_16 = 12, /* Direct 16 bit zero extended */
58 R_X86_64_PC16 = 13, /* 16 bit sign extended pc relative */
59 R_X86_64_8 = 14, /* Direct 8 bit sign extended */
60 R_X86_64_PC8 = 15, /* 8 bit sign extended pc relative */
61 R_X86_64_DTPMOD64 = 16, /* ID of module containing symbol */
62 R_X86_64_DTPOFF64 = 17, /* Offset in module's TLS block */
63 R_X86_64_TPOFF64 = 18, /* Offset in initial TLS block */
64 R_X86_64_TLSGD = 19, /* 32 bit signed PC relative offset
65 to two GOT entries for GD symbol */
66 R_X86_64_TLSLD = 20, /* 32 bit signed PC relative offset
67 to two GOT entries for LD symbol */
68 R_X86_64_DTPOFF32 = 21, /* Offset in TLS block */
69 R_X86_64_GOTTPOFF = 22, /* 32 bit signed PC relative offset
70 to GOT entry for IE symbol */
71 R_X86_64_TPOFF32 = 23, /* Offset in initial TLS block */
72 R_X86_64_PC64 = 24, /* word64 S + A - P */
73 R_X86_64_GOTOFF64 = 25, /* word64 S + A - GOT */
74 R_X86_64_GOTPC32 = 26, /* word32 GOT + A - P */
75 R_X86_64_GOT64 = 27, /* word64 G + A */
76 R_X86_64_GOTPCREL64 = 28, /* word64 G + GOT - P + A */
77 R_X86_64_GOTPC64 = 29, /* word64 GOT - P + A */
78 R_X86_64_GOTPLT64 = 30, /* word64 G + A */
79 R_X86_64_PLTOFF64 = 31, /* word64 L - GOT + A */
80 R_X86_64_SIZE32 = 32, /* word32 Z + A */
81 R_X86_64_SIZE64 = 33, /* word64 Z + A */
82 R_X86_64_GOTPC32_TLSDESC = 34, /* word32 */
83 R_X86_64_TLSDESC_CALL = 35, /* none */
84 R_X86_64_TLSDESC = 36 /* word64×2 */
87 /* Symbol */
89 typedef struct elf64_sym {
90 Elf64_Word st_name;
91 unsigned char st_info;
92 unsigned char st_other;
93 Elf64_Half st_shndx;
94 Elf64_Addr st_value;
95 Elf64_Xword st_size;
96 } Elf64_Sym;
98 /* Main file header */
100 typedef struct elf64_hdr {
101 unsigned char e_ident[EI_NIDENT];
102 Elf64_Half e_type;
103 Elf64_Half e_machine;
104 Elf64_Word e_version;
105 Elf64_Addr e_entry;
106 Elf64_Off e_phoff;
107 Elf64_Off e_shoff;
108 Elf64_Word e_flags;
109 Elf64_Half e_ehsize;
110 Elf64_Half e_phentsize;
111 Elf64_Half e_phnum;
112 Elf64_Half e_shentsize;
113 Elf64_Half e_shnum;
114 Elf64_Half e_shstrndx;
115 } Elf64_Ehdr;
117 /* Program header */
119 typedef struct elf64_phdr {
120 Elf64_Word p_type;
121 Elf64_Word p_flags;
122 Elf64_Off p_offset;
123 Elf64_Addr p_vaddr;
124 Elf64_Addr p_paddr;
125 Elf64_Xword p_filesz;
126 Elf64_Xword p_memsz;
127 Elf64_Xword p_align;
128 } Elf64_Phdr;
130 /* Section header */
132 typedef struct elf64_shdr {
133 Elf64_Word sh_name;
134 Elf64_Word sh_type;
135 Elf64_Xword sh_flags;
136 Elf64_Addr sh_addr;
137 Elf64_Off sh_offset;
138 Elf64_Xword sh_size;
139 Elf64_Word sh_link;
140 Elf64_Word sh_info;
141 Elf64_Xword sh_addralign;
142 Elf64_Xword sh_entsize;
143 } Elf64_Shdr;
145 /* Note header */
146 typedef struct elf64_note {
147 Elf64_Word n_namesz; /* Name size */
148 Elf64_Word n_descsz; /* Content size */
149 Elf64_Word n_type; /* Content type */
150 } Elf64_Nhdr;
152 /* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
153 #define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
154 #define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
156 #endif /* OUTPUT_ELF64_H */