Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / native_client / src / include / elf_constants.h
1 /*
2  * Copyright (c) 2013 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7
8 /* @file
9  *
10  * Defines common constants used in ELF files, used by elf32.h, elf64.h
11  * and elf.h
12  *
13  * (Re)Created from the ELF specification at
14  * http://x86.ddj.com/ftp/manuals/tools/elf.pdf which is referenced
15  * from wikipedia article
16  * http://en.wikipedia.org/wki/Executable_and_Linkable_Format
17  */
18
19 #ifndef NATIVE_CLIENT_SRC_INCLUDE_ELF_CONSTANTS_H_
20 #define NATIVE_CLIENT_SRC_INCLUDE_ELF_CONSTANTS_H_
21
22 #include "native_client/src/include/nacl_base.h"
23
24 EXTERN_C_BEGIN
25
26 #define EI_NIDENT       16   /* fwd, see rest of EI_* below */
27
28 #define ET_NONE         0   /* no file type */
29 #define ET_REL          1   /* relocatable file */
30 #define ET_EXEC         2   /* executable file */
31 #define ET_DYN          3   /* shared object file */
32 #define ET_CORE         4   /* core file */
33 /* TODO(karl) figure out effect of adding ET_LOOS through ET_HIOS */
34 #define ET_LOOS    0xfe00   /* Environment-specific */
35 #define ET_HIOS    0xfeff   /* Environment-specific */
36 #define ET_LOPROC  0xff00   /* processor-specific */
37 #define ET_HIPROC  0xffff   /* processor-specific */
38
39 #define EM_NONE         0   /* no machine */
40 #define EM_M32          1   /* at&t we 32100 */
41 #define EM_SPARC        2   /* sparc */
42 #define EM_386          3   /* intel architecture */
43 #define EM_68K          4   /* motorola 68000 */
44 #define EM_88K          5   /* motorola 88000 */
45 #define EM_860          7   /* intel 80860 */
46 #define EM_MIPS         8   /* mips rs3000 */
47 #define EM_MIPS_RS4_BE  10  /* mips rs4000 big-endian */
48 #define EM_LORESERVED   11
49 #define EM_HIRESERVED   16
50 #define EM_ARM          40  /* arm */
51 #define EM_X86_64       62  /* x86-64 */
52
53 #define EV_NONE         0   /* invalid version */
54 #define EV_CURRENT      1   /* current version */
55
56 #define EI_MAG0         0   /* file identification */
57 #define EI_MAG1         1   /* file identification */
58 #define EI_MAG2         2   /* file identification */
59 #define EI_MAG3         3   /* file identification */
60 #define EI_CLASS        4   /* file class */
61 #define EI_DATA         5   /* data encoding */
62 #define EI_VERSION      6   /* file version */
63 /*
64  * EI_PAD deviates from the pdf specification, where its value is 7, since
65  * EI_OSABI and EI_ABIVERSION have been introduced.  EI_OSABI and
66  * EI_OSABIVERSION are from linux elf.h for code usage compatibility.
67  * Also, for Elf 64, the value for EI_PAD is also 9.
68  */
69 #define EI_PAD          9   /* start of padding bytes */
70
71 #define EI_OSABI        7
72 #define EI_ABIVERSION   8
73
74 /*
75  * ELFMAG and SELFMAG are names/values from linux elf.h, for code usage
76  * compatibility.
77  */
78 #define ELFMAG          "\177ELF"
79 #define SELFMAG         4
80
81 /* EI_CLASS values */
82 #define ELFCLASSNONE    0
83 #define ELFCLASS32      1
84 #define ELFCLASS64      2
85
86 /* EI_DATA values */
87 #define ELFDATANONE     0
88 #define ELFDATA2LSB     1
89 #define ELFDATA2MSB     2
90
91 #define PT_NULL       0           /* Unused entry */
92 #define PT_LOAD       1           /* Loadable segment */
93 #define PT_DYNAMIC    2           /* Dynamic linking tables */
94 #define PT_INTERP     3           /* Program interpreter path name */
95 #define PT_NOTE       4           /* Note section */
96 #define PT_SHLIB      5           /* Reserved */
97 #define PT_PHDR       6           /* Program header table */
98 #define PT_LOOS       0x60000000  /* Environment-specific low */
99 #define PT_HIOS       0x6fffffff  /* Environment-specific high */
100 #define PT_LOPROC     0x70000000  /* Processor-specific low */
101 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm
102 #define PT_ARM_EXIDX  0x70000001  /* Exception unwind tables */
103 #endif
104 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_mips
105 #define PT_MIPS_REGINFO  0x70000000 /* Register usage, MIPS only, unused */
106 #endif
107 #define PT_HIPROC     0x7fffffff  /* Processor-specific high */
108 /*
109  * These are from linux elf.h, for code usage
110  * compatibility.
111  */
112 #define PT_TLS        7
113 #define PT_GNU_STACK  0x6474e551
114 #define PT_GNU_EH_FRAME 0x6474e550      /* GCC .eh_frame_hdr segment */
115 #define PT_GNU_RELRO    0x6474e552      /* Read-only after relocation */
116
117
118 #define PF_X          1
119 #define PF_W          2
120 #define PF_R          4
121 /*
122  * PF_MASKOS is from linux elf.h, for code usage compatibility
123  */
124 #define PF_MASKOS     0x0ff00000  /* os specific */
125
126 #define SHF_WRITE       0x1         /* Has writable data */
127 #define SHF_ALLOC       0x2         /* Allocated in memory image of program */
128 #define SHF_EXECINSTR   0x4         /* Contains executable instructions */
129 #define SHF_MASKOS      0x0f000000  /* Environment-specific use */
130 #define SHF_MASKPROC    0xf0000000  /* Processor-specific use */
131
132 #define DT_NULL         0
133 #define DT_REL          17
134 #define DT_RELSZ        18
135
136 #define ELF_NOTE_GNU    "GNU"
137
138 /* n_type value for build ID notes generated by "ld --build-id". */
139 #define NT_GNU_BUILD_ID 3
140
141 #define R_386_RELATIVE  8
142 #define R_ARM_RELATIVE  23
143
144 EXTERN_C_END
145
146 #endif  /* NATIVE_CLIENT_SRC_INCLUDE_ELF_CONSTANTS_H_ */