parser.c: fix stylistic nitpick
[nasm.git] / output / elf32.h
blobe9589b0a8b0d813d6d01964c72753dc63725c0fe
1 #ifndef OUTPUT_ELF32_H
2 #define OUTPUT_ELF32_H
4 #include "output/elfcommon.h"
6 /* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
7 typedef uint16_t Elf32_Half;
8 typedef int16_t Elf32_SHalf;
9 typedef uint32_t Elf32_Word;
10 typedef int32_t Elf32_Sword;
11 typedef uint64_t Elf32_Xword;
12 typedef int64_t Elf32_Sxword;
14 typedef uint32_t Elf32_Off;
15 typedef uint32_t Elf32_Addr;
16 typedef uint16_t Elf32_Section;
18 /* Dynamic header */
20 typedef struct elf32_dyn {
21 Elf32_Sword d_tag;
22 union {
23 Elf32_Sword d_val;
24 Elf32_Addr d_ptr;
25 } d_un;
26 } Elf32_Dyn;
28 /* Relocations */
30 #define ELF32_R_SYM(x) ((x) >> 8)
31 #define ELF32_R_TYPE(x) ((x) & 0xff)
33 typedef struct elf32_rel {
34 Elf32_Addr r_offset;
35 Elf32_Word r_info;
36 } Elf32_Rel;
38 typedef struct elf32_rela {
39 Elf32_Addr r_offset;
40 Elf32_Word r_info;
41 Elf32_Sword r_addend;
42 } Elf32_Rela;
44 enum reloc32_type {
45 R_386_32 = 1, /* ordinary absolute relocation */
46 R_386_PC32 = 2, /* PC-relative relocation */
47 R_386_GOT32 = 3, /* an offset into GOT */
48 R_386_PLT32 = 4, /* a PC-relative offset into PLT */
49 R_386_COPY = 5, /* ??? */
50 R_386_GLOB_DAT = 6, /* ??? */
51 R_386_JUMP_SLOT = 7, /* ??? */
52 R_386_RELATIVE = 8, /* ??? */
53 R_386_GOTOFF = 9, /* an offset from GOT base */
54 R_386_GOTPC = 10, /* a PC-relative offset _to_ GOT */
55 R_386_TLS_TPOFF = 14, /* Offset in static TLS block */
56 R_386_TLS_IE = 15, /* Address of GOT entry for static TLS
57 block offset */
58 /* These are GNU extensions, but useful */
59 R_386_16 = 20, /* A 16-bit absolute relocation */
60 R_386_PC16 = 21, /* A 16-bit PC-relative relocation */
61 R_386_8 = 22, /* An 8-bit absolute relocation */
62 R_386_PC8 = 23 /* An 8-bit PC-relative relocation */
65 /* Symbol */
67 typedef struct elf32_sym {
68 Elf32_Word st_name;
69 Elf32_Addr st_value;
70 Elf32_Word st_size;
71 unsigned char st_info;
72 unsigned char st_other;
73 Elf32_Half st_shndx;
74 } Elf32_Sym;
76 /* Main file header */
78 typedef struct elf32_hdr {
79 unsigned char e_ident[EI_NIDENT];
80 Elf32_Half e_type;
81 Elf32_Half e_machine;
82 Elf32_Word e_version;
83 Elf32_Addr e_entry;
84 Elf32_Off e_phoff;
85 Elf32_Off e_shoff;
86 Elf32_Word e_flags;
87 Elf32_Half e_ehsize;
88 Elf32_Half e_phentsize;
89 Elf32_Half e_phnum;
90 Elf32_Half e_shentsize;
91 Elf32_Half e_shnum;
92 Elf32_Half e_shstrndx;
93 } Elf32_Ehdr;
95 /* Program header */
97 typedef struct elf32_phdr {
98 Elf32_Word p_type;
99 Elf32_Off p_offset;
100 Elf32_Addr p_vaddr;
101 Elf32_Addr p_paddr;
102 Elf32_Word p_filesz;
103 Elf32_Word p_memsz;
104 Elf32_Word p_flags;
105 Elf32_Word p_align;
106 } Elf32_Phdr;
108 /* Section header */
110 typedef struct elf32_shdr {
111 Elf32_Word sh_name;
112 Elf32_Word sh_type;
113 Elf32_Word sh_flags;
114 Elf32_Addr sh_addr;
115 Elf32_Off sh_offset;
116 Elf32_Word sh_size;
117 Elf32_Word sh_link;
118 Elf32_Word sh_info;
119 Elf32_Word sh_addralign;
120 Elf32_Word sh_entsize;
121 } Elf32_Shdr;
123 /* Note header */
124 typedef struct elf32_note {
125 Elf32_Word n_namesz; /* Name size */
126 Elf32_Word n_descsz; /* Content size */
127 Elf32_Word n_type; /* Content type */
128 } Elf32_Nhdr;
130 /* How to extract and insert information held in the st_info field. */
131 #define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
132 #define ELF32_ST_TYPE(val) ((val) & 0xf)
134 #endif /* OUTPUT_ELF32_H */