Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/ianos/elfload/elf.h
1476 views
1
/* $OpenBSD: exec_elf.h,v 1.53 2014/01/03 03:00:39 guenther Exp $ */
2
/*
3
* Copyright (c) 1995, 1996 Erik Theisen. All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. The name of the author may not be used to endorse or promote products
14
* derived from this software without specific prior written permission
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
/* imported sys/exec_elf.h from OpenBSD */
29
30
#ifndef ELF_H
31
#define ELF_H
32
33
#include <utils/types.h>
34
35
typedef u8 Elf_Byte;
36
37
typedef u32 Elf32_Addr; /* Unsigned program address */
38
typedef u32 Elf32_Off; /* Unsigned file offset */
39
typedef s32 Elf32_Sword; /* Signed large integer */
40
typedef u32 Elf32_Word; /* Unsigned large integer */
41
typedef u16 Elf32_Half; /* Unsigned medium integer */
42
43
typedef u64 Elf64_Addr;
44
typedef u64 Elf64_Off;
45
typedef s32 Elf64_Shalf;
46
47
#ifdef __alpha__
48
typedef s64 Elf64_Sword;
49
typedef u64 Elf64_Word;
50
#else
51
typedef s32 Elf64_Sword;
52
typedef u32 Elf64_Word;
53
#endif
54
55
typedef s64 Elf64_Sxword;
56
typedef u64 Elf64_Xword;
57
58
typedef u32 Elf64_Half;
59
typedef u16 Elf64_Quarter;
60
61
/*
62
* e_ident[] identification indexes
63
* See http://www.sco.com/developers/gabi/latest/ch4.eheader.html
64
*/
65
#define EI_MAG0 0 /* file ID */
66
#define EI_MAG1 1 /* file ID */
67
#define EI_MAG2 2 /* file ID */
68
#define EI_MAG3 3 /* file ID */
69
#define EI_CLASS 4 /* file class */
70
#define EI_DATA 5 /* data encoding */
71
#define EI_VERSION 6 /* ELF header version */
72
#define EI_OSABI 7 /* OS/ABI ID */
73
#define EI_ABIVERSION 8 /* ABI version */
74
#define EI_PAD 9 /* start of pad bytes */
75
#define EI_NIDENT 16 /* Size of e_ident[] */
76
77
/* e_ident[] magic number */
78
#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
79
#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
80
#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
81
#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
82
#define ELFMAG "\177ELF" /* magic */
83
#define SELFMAG 4 /* size of magic */
84
85
/* e_ident[] file class */
86
#define ELFCLASSNONE 0 /* invalid */
87
#define ELFCLASS32 1 /* 32-bit objs */
88
#define ELFCLASS64 2 /* 64-bit objs */
89
#define ELFCLASSNUM 3 /* number of classes */
90
91
/* e_ident[] data encoding */
92
#define ELFDATANONE 0 /* invalid */
93
#define ELFDATA2LSB 1 /* Little-Endian */
94
#define ELFDATA2MSB 2 /* Big-Endian */
95
#define ELFDATANUM 3 /* number of data encode defines */
96
97
/* e_ident[] Operating System/ABI */
98
#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
99
#define ELFOSABI_HPUX 1 /* HP-UX operating system */
100
#define ELFOSABI_NETBSD 2 /* NetBSD */
101
#define ELFOSABI_LINUX 3 /* GNU/Linux */
102
#define ELFOSABI_HURD 4 /* GNU/Hurd */
103
#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */
104
#define ELFOSABI_SOLARIS 6 /* Solaris */
105
#define ELFOSABI_MONTEREY 7 /* Monterey */
106
#define ELFOSABI_IRIX 8 /* IRIX */
107
#define ELFOSABI_FREEBSD 9 /* FreeBSD */
108
#define ELFOSABI_TRU64 10 /* TRU64 UNIX */
109
#define ELFOSABI_MODESTO 11 /* Novell Modesto */
110
#define ELFOSABI_OPENBSD 12 /* OpenBSD */
111
#define ELFOSABI_ARM 97 /* ARM */
112
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
113
114
/* e_ident */
115
#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
116
(ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
117
(ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
118
(ehdr).e_ident[EI_MAG3] == ELFMAG3)
119
120
/* ELF Header */
121
typedef struct
122
{
123
unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
124
Elf32_Half e_type; /* object file type */
125
Elf32_Half e_machine; /* machine */
126
Elf32_Word e_version; /* object file version */
127
Elf32_Addr e_entry; /* virtual entry point */
128
Elf32_Off e_phoff; /* program header table offset */
129
Elf32_Off e_shoff; /* section header table offset */
130
Elf32_Word e_flags; /* processor-specific flags */
131
Elf32_Half e_ehsize; /* ELF header size */
132
Elf32_Half e_phentsize; /* program header entry size */
133
Elf32_Half e_phnum; /* number of program header entries */
134
Elf32_Half e_shentsize; /* section header entry size */
135
Elf32_Half e_shnum; /* number of section header entries */
136
Elf32_Half e_shstrndx; /* section header table's "section
137
header string table" entry offset */
138
} Elf32_Ehdr;
139
140
typedef struct
141
{
142
unsigned char e_ident[EI_NIDENT]; /* Id bytes */
143
Elf64_Quarter e_type; /* file type */
144
Elf64_Quarter e_machine; /* machine type */
145
Elf64_Half e_version; /* version number */
146
Elf64_Addr e_entry; /* entry point */
147
Elf64_Off e_phoff; /* Program hdr offset */
148
Elf64_Off e_shoff; /* Section hdr offset */
149
Elf64_Half e_flags; /* Processor flags */
150
Elf64_Quarter e_ehsize; /* sizeof ehdr */
151
Elf64_Quarter e_phentsize; /* Program header entry size */
152
Elf64_Quarter e_phnum; /* Number of program headers */
153
Elf64_Quarter e_shentsize; /* Section header entry size */
154
Elf64_Quarter e_shnum; /* Number of section headers */
155
Elf64_Quarter e_shstrndx; /* String table index */
156
} Elf64_Ehdr;
157
158
/* e_type */
159
#define ET_NONE 0 /* No file type */
160
#define ET_REL 1 /* relocatable file */
161
#define ET_EXEC 2 /* executable file */
162
#define ET_DYN 3 /* shared object file */
163
#define ET_CORE 4 /* core file */
164
#define ET_NUM 5 /* number of types */
165
#define ET_LOPROC 0xff00 /* reserved range for processor */
166
#define ET_HIPROC 0xffff /* specific e_type */
167
168
/* e_machine */
169
#define EM_NONE 0 /* No Machine */
170
#define EM_M32 1 /* AT&T WE 32100 */
171
#define EM_SPARC 2 /* SPARC */
172
#define EM_386 3 /* Intel 80386 */
173
#define EM_68K 4 /* Motorola 68000 */
174
#define EM_88K 5 /* Motorola 88000 */
175
#define EM_486 6 /* Intel 80486 - unused? */
176
#define EM_860 7 /* Intel 80860 */
177
#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
178
/*
179
* Don't know if EM_MIPS_RS4_BE,
180
* EM_SPARC64, EM_PARISC,
181
* or EM_PPC are ABI compliant
182
*/
183
#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
184
#define EM_SPARC64 11 /* SPARC v9 64-bit unofficial */
185
#define EM_PARISC 15 /* HPPA */
186
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
187
#define EM_PPC 20 /* PowerPC */
188
#define EM_ARM 40 /* ARM AArch32 */
189
#define EM_ALPHA 41 /* DEC ALPHA */
190
#define EM_SH 42 /* Hitachi/Renesas Super-H */
191
#define EM_SPARCV9 43 /* SPARC version 9 */
192
#define EM_IA_64 50 /* Intel IA-64 Processor */
193
#define EM_AMD64 62 /* AMD64 architecture */
194
#define EM_VAX 75 /* DEC VAX */
195
#define EM_AARCH64 183 /* ARM AArch64 */
196
197
/* Non-standard */
198
#define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */
199
200
/* Version */
201
#define EV_NONE 0 /* Invalid */
202
#define EV_CURRENT 1 /* Current */
203
#define EV_NUM 2 /* number of versions */
204
205
/* Section Header */
206
typedef struct
207
{
208
Elf32_Word sh_name; /* name - index into section header
209
* string table section */
210
Elf32_Word sh_type; /* type */
211
Elf32_Word sh_flags; /* flags */
212
Elf32_Addr sh_addr; /* address */
213
Elf32_Off sh_offset; /* file offset */
214
Elf32_Word sh_size; /* section size */
215
Elf32_Word sh_link; /* section header table index link */
216
Elf32_Word sh_info; /* extra information */
217
Elf32_Word sh_addralign; /* address alignment */
218
Elf32_Word sh_entsize; /* section entry size */
219
} Elf32_Shdr;
220
221
typedef struct
222
{
223
Elf64_Half sh_name; /* section name */
224
Elf64_Half sh_type; /* section type */
225
Elf64_Xword sh_flags; /* section flags */
226
Elf64_Addr sh_addr; /* virtual address */
227
Elf64_Off sh_offset; /* file offset */
228
Elf64_Xword sh_size; /* section size */
229
Elf64_Half sh_link; /* link to another */
230
Elf64_Half sh_info; /* misc info */
231
Elf64_Xword sh_addralign; /* memory alignment */
232
Elf64_Xword sh_entsize; /* table entry size */
233
} Elf64_Shdr;
234
235
/* Special Section Indexes */
236
#define SHN_UNDEF 0 /* undefined */
237
#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
238
#define SHN_LOPROC 0xff00 /* reserved range for processor */
239
#define SHN_HIPROC 0xff1f /* specific section indexes */
240
#define SHN_ABS 0xfff1 /* absolute value */
241
#define SHN_COMMON 0xfff2 /* common symbol */
242
#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
243
244
/* sh_type */
245
#define SHT_NULL 0 /* inactive */
246
#define SHT_PROGBITS 1 /* program defined information */
247
#define SHT_SYMTAB 2 /* symbol table section */
248
#define SHT_STRTAB 3 /* string table section */
249
#define SHT_RELA 4 /* relocation section with addends*/
250
#define SHT_HASH 5 /* symbol hash table section */
251
#define SHT_DYNAMIC 6 /* dynamic section */
252
#define SHT_NOTE 7 /* note section */
253
#define SHT_NOBITS 8 /* no space section */
254
#define SHT_REL 9 /* relation section without addends */
255
#define SHT_SHLIB 10 /* reserved - purpose unknown */
256
#define SHT_DYNSYM 11 /* dynamic symbol table section */
257
#define SHT_NUM 12 /* number of section types */
258
#define SHT_LOPROC 0x70000000 /* reserved range for processor */
259
#define SHT_HIPROC 0x7fffffff /* specific section header types */
260
#define SHT_LOUSER 0x80000000 /* reserved range for application */
261
#define SHT_HIUSER 0xffffffff /* specific indexes */
262
263
/* Section names */
264
#define ELF_BSS ".bss" /* uninitialized data */
265
#define ELF_DATA ".data" /* initialized data */
266
#define ELF_DEBUG ".debug" /* debug */
267
#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
268
#define ELF_DYNSTR ".dynstr" /* dynamic string table */
269
#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
270
#define ELF_FINI ".fini" /* termination code */
271
#define ELF_GOT ".got" /* global offset table */
272
#define ELF_HASH ".hash" /* symbol hash table */
273
#define ELF_INIT ".init" /* initialization code */
274
#define ELF_REL_DATA ".rel.data" /* relocation data */
275
#define ELF_REL_FINI ".rel.fini" /* relocation termination code */
276
#define ELF_REL_INIT ".rel.init" /* relocation initialization code */
277
#define ELF_REL_DYN ".rel.dyn" /* relocation dynamic link info */
278
#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
279
#define ELF_REL_TEXT ".rel.text" /* relocation code */
280
#define ELF_RODATA ".rodata" /* read-only data */
281
#define ELF_SHSTRTAB ".shstrtab" /* section header string table */
282
#define ELF_STRTAB ".strtab" /* string table */
283
#define ELF_SYMTAB ".symtab" /* symbol table */
284
#define ELF_TEXT ".text" /* code */
285
286
/* Section Attribute Flags - sh_flags */
287
#define SHF_WRITE 0x1 /* Writable */
288
#define SHF_ALLOC 0x2 /* occupies memory */
289
#define SHF_EXECINSTR 0x4 /* executable */
290
#define SHF_TLS 0x400 /* thread local storage */
291
#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor \
292
* specific section attributes */
293
294
/* Symbol Table Entry */
295
typedef struct elf32_sym
296
{
297
Elf32_Word st_name; /* name - index into string table */
298
Elf32_Addr st_value; /* symbol value */
299
Elf32_Word st_size; /* symbol size */
300
unsigned char st_info; /* type and binding */
301
unsigned char st_other; /* 0 - no defined meaning */
302
Elf32_Half st_shndx; /* section header index */
303
} Elf32_Sym;
304
305
typedef struct
306
{
307
Elf64_Half st_name; /* Symbol name index in str table */
308
Elf_Byte st_info; /* type / binding attrs */
309
Elf_Byte st_other; /* unused */
310
Elf64_Quarter st_shndx; /* section index of symbol */
311
Elf64_Xword st_value; /* value of symbol */
312
Elf64_Xword st_size; /* size of symbol */
313
} Elf64_Sym;
314
315
/* Symbol table index */
316
#define STN_UNDEF 0 /* undefined */
317
318
/* Extract symbol info - st_info */
319
#define ELF32_ST_BIND(x) ((x) >> 4)
320
#define ELF32_ST_TYPE(x) (((unsigned int)x) & 0xf)
321
#define ELF32_ST_INFO(b, t) (((b) << 4) + ((t)&0xf))
322
323
#define ELF64_ST_BIND(x) ((x) >> 4)
324
#define ELF64_ST_TYPE(x) (((unsigned int)x) & 0xf)
325
#define ELF64_ST_INFO(b, t) (((b) << 4) + ((t)&0xf))
326
327
/* Symbol Binding - ELF32_ST_BIND - st_info */
328
#define STB_LOCAL 0 /* Local symbol */
329
#define STB_GLOBAL 1 /* Global symbol */
330
#define STB_WEAK 2 /* like global - lower precedence */
331
#define STB_NUM 3 /* number of symbol bindings */
332
#define STB_LOPROC 13 /* reserved range for processor */
333
#define STB_HIPROC 15 /* specific symbol bindings */
334
335
/* Symbol type - ELF32_ST_TYPE - st_info */
336
#define STT_NOTYPE 0 /* not specified */
337
#define STT_OBJECT 1 /* data object */
338
#define STT_FUNC 2 /* function */
339
#define STT_SECTION 3 /* section */
340
#define STT_FILE 4 /* file */
341
#define STT_TLS 6 /* thread local storage */
342
#define STT_LOPROC 13 /* reserved range for processor */
343
#define STT_HIPROC 15 /* specific symbol types */
344
345
/* Relocation entry with implicit addend */
346
typedef struct
347
{
348
Elf32_Addr r_offset; /* offset of relocation */
349
Elf32_Word r_info; /* symbol table index and type */
350
} Elf32_Rel;
351
352
/* Relocation entry with explicit addend */
353
typedef struct
354
{
355
Elf32_Addr r_offset; /* offset of relocation */
356
Elf32_Word r_info; /* symbol table index and type */
357
Elf32_Sword r_addend;
358
} Elf32_Rela;
359
360
/* Extract relocation info - r_info */
361
#define ELF32_R_SYM(i) ((i) >> 8)
362
#define ELF32_R_TYPE(i) ((unsigned char)(i))
363
#define ELF32_R_INFO(s, t) (((s) << 8) + (unsigned char)(t))
364
365
typedef struct
366
{
367
Elf64_Xword r_offset; /* where to do it */
368
Elf64_Xword r_info; /* index & type of relocation */
369
} Elf64_Rel;
370
371
typedef struct
372
{
373
Elf64_Xword r_offset; /* where to do it */
374
Elf64_Xword r_info; /* index & type of relocation */
375
Elf64_Sxword r_addend; /* adjustment value */
376
} Elf64_Rela;
377
378
#define ELF64_R_SYM(info) ((info) >> 32)
379
#define ELF64_R_TYPE(info) ((info)&0xFFFFFFFF)
380
#define ELF64_R_INFO(s, t) (((s) << 32) + (u32)(t))
381
382
#if defined(__mips64__) && defined(__MIPSEL__)
383
/*
384
* The 64-bit MIPS ELF ABI uses a slightly different relocation format
385
* than the regular ELF ABI: the r_info field is split into several
386
* pieces (see gnu/usr.bin/binutils/include/elf/mips.h for details).
387
*/
388
#undef ELF64_R_SYM
389
#undef ELF64_R_TYPE
390
#undef ELF64_R_INFO
391
#define ELF64_R_TYPE(info) (swap32((info) >> 32))
392
#define ELF64_R_SYM(info) ((info)&0xFFFFFFFF)
393
#define ELF64_R_INFO(s, t) (((u64)swap32(t) << 32) + (u32)(s))
394
#endif /* __mips64__ && __MIPSEL__ */
395
396
/* Program Header */
397
typedef struct
398
{
399
Elf32_Word p_type; /* segment type */
400
Elf32_Off p_offset; /* segment offset */
401
Elf32_Addr p_vaddr; /* virtual address of segment */
402
Elf32_Addr p_paddr; /* physical address - ignored? */
403
Elf32_Word p_filesz; /* number of bytes in file for seg. */
404
Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
405
Elf32_Word p_flags; /* flags */
406
Elf32_Word p_align; /* memory alignment */
407
} Elf32_Phdr;
408
409
typedef struct
410
{
411
Elf64_Half p_type; /* entry type */
412
Elf64_Half p_flags; /* flags */
413
Elf64_Off p_offset; /* offset */
414
Elf64_Addr p_vaddr; /* virtual address */
415
Elf64_Addr p_paddr; /* physical address */
416
Elf64_Xword p_filesz; /* file size */
417
Elf64_Xword p_memsz; /* memory size */
418
Elf64_Xword p_align; /* memory & file alignment */
419
} Elf64_Phdr;
420
421
/* Segment types - p_type */
422
#define PT_NULL 0 /* unused */
423
#define PT_LOAD 1 /* loadable segment */
424
#define PT_DYNAMIC 2 /* dynamic linking section */
425
#define PT_INTERP 3 /* the RTLD */
426
#define PT_NOTE 4 /* auxiliary information */
427
#define PT_SHLIB 5 /* reserved - purpose undefined */
428
#define PT_PHDR 6 /* program header */
429
#define PT_TLS 7 /* thread local storage */
430
#define PT_LOOS 0x60000000 /* reserved range for OS */
431
#define PT_HIOS 0x6fffffff /* specific segment types */
432
#define PT_LOPROC 0x70000000 /* reserved range for processor */
433
#define PT_HIPROC 0x7fffffff /* specific segment types */
434
435
#define PT_OPENBSD_RANDOMIZE 0x65a3dbe6 /* fill with random data */
436
#define PT_GANDR_KERNEL 0x67646b6c /* gdkl */
437
438
/* Segment flags - p_flags */
439
#define PF_X 0x1 /* Executable */
440
#define PF_W 0x2 /* Writable */
441
#define PF_R 0x4 /* Readable */
442
#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
443
/* specific segment flags */
444
445
/* Dynamic structure */
446
typedef struct
447
{
448
Elf32_Word d_tag; /* controls meaning of d_val */
449
union {
450
Elf32_Word d_val; /* Multiple meanings - see d_tag */
451
Elf32_Addr d_ptr; /* program virtual address */
452
} d_un;
453
} Elf32_Dyn;
454
455
typedef struct
456
{
457
Elf64_Xword d_tag; /* controls meaning of d_val */
458
union {
459
Elf64_Addr d_ptr;
460
Elf64_Xword d_val;
461
} d_un;
462
} Elf64_Dyn;
463
464
/* Dynamic Array Tags - d_tag */
465
#define DT_NULL 0 /* marks end of _DYNAMIC array */
466
#define DT_NEEDED 1 /* string table offset of needed lib */
467
#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
468
#define DT_PLTGOT 3 /* address PLT/GOT */
469
#define DT_HASH 4 /* address of symbol hash table */
470
#define DT_STRTAB 5 /* address of string table */
471
#define DT_SYMTAB 6 /* address of symbol table */
472
#define DT_RELA 7 /* address of relocation table */
473
#define DT_RELASZ 8 /* size of relocation table */
474
#define DT_RELAENT 9 /* size of relocation entry */
475
#define DT_STRSZ 10 /* size of string table */
476
#define DT_SYMENT 11 /* size of symbol table entry */
477
#define DT_INIT 12 /* address of initialization func. */
478
#define DT_FINI 13 /* address of termination function */
479
#define DT_SONAME 14 /* string table offset of shared obj */
480
#define DT_RPATH 15 /* string table offset of library \
481
* search path */
482
#define DT_SYMBOLIC 16 /* start sym search in shared obj. */
483
#define DT_REL 17 /* address of rel. tbl. w addends */
484
#define DT_RELSZ 18 /* size of DT_REL relocation table */
485
#define DT_RELENT 19 /* size of DT_REL relocation entry */
486
#define DT_PLTREL 20 /* PLT referenced relocation entry */
487
#define DT_DEBUG 21 /* bugger */
488
#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
489
#define DT_JMPREL 23 /* add. of PLT's relocation entries */
490
#define DT_BIND_NOW 24 /* Bind now regardless of env setting */
491
#define DT_LOOS 0x6000000d /* reserved range for OS */
492
#define DT_HIOS 0x6ffff000 /* specific dynamic array tags */
493
#define DT_LOPROC 0x70000000 /* reserved range for processor */
494
#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
495
496
/* some other useful tags */
497
#define DT_RELACOUNT 0x6ffffff9 /* if present, number of RELATIVE */
498
#define DT_RELCOUNT 0x6ffffffa /* relocs, which must come first */
499
#define DT_FLAGS_1 0x6ffffffb
500
501
/* Dynamic Flags - DT_FLAGS_1 .dynamic entry */
502
#define DF_1_NOW 0x00000001
503
#define DF_1_GLOBAL 0x00000002
504
#define DF_1_GROUP 0x00000004
505
#define DF_1_NODELETE 0x00000008
506
#define DF_1_LOADFLTR 0x00000010
507
#define DF_1_INITFIRST 0x00000020
508
#define DF_1_NOOPEN 0x00000040
509
#define DF_1_ORIGIN 0x00000080
510
#define DF_1_DIRECT 0x00000100
511
#define DF_1_TRANS 0x00000200
512
#define DF_1_INTERPOSE 0x00000400
513
#define DF_1_NODEFLIB 0x00000800
514
#define DF_1_NODUMP 0x00001000
515
#define DF_1_CONLFAT 0x00002000
516
517
/* ld.so: number of low tags that are used saved internally (0 .. DT_NUM-1) */
518
#define DT_NUM (DT_JMPREL + 1)
519
520
/*
521
* Note Definitions
522
*/
523
typedef struct
524
{
525
Elf32_Word namesz;
526
Elf32_Word descsz;
527
Elf32_Word type;
528
} Elf32_Note;
529
530
typedef struct
531
{
532
Elf64_Half namesz;
533
Elf64_Half descsz;
534
Elf64_Half type;
535
} Elf64_Note;
536
537
#if defined(ELFSIZE) && (ELFSIZE == 32)
538
#define Elf_Ehdr Elf32_Ehdr
539
#define Elf_Phdr Elf32_Phdr
540
#define Elf_Shdr Elf32_Shdr
541
#define Elf_Sym Elf32_Sym
542
#define Elf_Rel Elf32_Rel
543
#define Elf_RelA Elf32_Rela
544
#define Elf_Dyn Elf32_Dyn
545
#define Elf_Half Elf32_Half
546
#define Elf_Word Elf32_Word
547
#define Elf_Sword Elf32_Sword
548
#define Elf_Addr Elf32_Addr
549
#define Elf_Off Elf32_Off
550
#define Elf_Nhdr Elf32_Nhdr
551
#define Elf_Note Elf32_Note
552
553
#define ELF_R_SYM ELF32_R_SYM
554
#define ELF_R_TYPE ELF32_R_TYPE
555
#define ELF_R_INFO ELF32_R_INFO
556
#define ELFCLASS ELFCLASS32
557
558
#define ELF_ST_BIND ELF32_ST_BIND
559
#define ELF_ST_TYPE ELF32_ST_TYPE
560
#define ELF_ST_INFO ELF32_ST_INFO
561
562
#elif defined(ELFSIZE) && (ELFSIZE == 64)
563
564
#define Elf_Ehdr Elf64_Ehdr
565
#define Elf_Phdr Elf64_Phdr
566
#define Elf_Shdr Elf64_Shdr
567
#define Elf_Sym Elf64_Sym
568
#define Elf_Rel Elf64_Rel
569
#define Elf_RelA Elf64_Rela
570
#define Elf_Dyn Elf64_Dyn
571
#define Elf_Half Elf64_Half
572
#define Elf_Word Elf64_Word
573
#define Elf_Sword Elf64_Sword
574
#define Elf_Addr Elf64_Addr
575
#define Elf_Off Elf64_Off
576
#define Elf_Nhdr Elf64_Nhdr
577
#define Elf_Note Elf64_Note
578
579
#define ELF_R_SYM ELF64_R_SYM
580
#define ELF_R_TYPE ELF64_R_TYPE
581
#define ELF_R_INFO ELF64_R_INFO
582
#define ELFCLASS ELFCLASS64
583
584
#define ELF_ST_BIND ELF64_ST_BIND
585
#define ELF_ST_TYPE ELF64_ST_TYPE
586
#define ELF_ST_INFO ELF64_ST_INFO
587
588
#endif
589
590
#endif
591
592