2 * Copyright 2008, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * Minimal ELF header declaration / constants. Only Elf32* values are
36 * handled, and constants are defined only for fields that are actualy
37 * used. (Unused constants for used fields are include only for
38 * "completeness", though of course in many cases there are more
39 * values in use, e.g., the EM_* values for e_machine.)
41 * (Re)Created from the ELF specification at
42 * http://x86.ddj.com/ftp/manuals/tools/elf.pdf which is referenced
43 * from wikipedia article
44 * http://en.wikipedia.org/wki/Executable_and_Linkable_Format
47 #ifndef NATIVE_CLIENT_INCLUDE_ELF_H_
48 #define NATIVE_CLIENT_INCLUDE_ELF_H_
50 #include "native_client/include/nacl_base.h"
55 * Note that we must compile on windows, where stdint.h may be unavailable.
58 /* assumes 32-bit int, 16-bit short, 8-bit char */
60 typedef unsigned int Elf32_Addr
; /* alignment 4 */
61 typedef unsigned short Elf32_Half
; /* alignment 2 */
62 typedef unsigned int Elf32_Off
; /* alignment 4 */
63 typedef int Elf32_Sword
; /* alignment 4 */
64 typedef unsigned int Elf32_Word
; /* alignment 4 */
65 /* unsigned char, size 1, alignment 1 */
67 #define EI_NIDENT 16 /* fwd, see rest of EI_* below */
70 unsigned char e_ident
[EI_NIDENT
];
79 Elf32_Half e_phentsize
;
81 Elf32_Half e_shentsize
;
83 Elf32_Half e_shstrndx
;
86 #define ET_NONE 0 /* no file type */
87 #define ET_REL 1 /* relocatable file */
88 #define ET_EXEC 2 /* executable file */
89 #define ET_DYN 3 /* shared object file */
90 #define ET_CORE 4 /* core file */
91 #define ET_LOPROC 0xff00 /* processor-specific */
92 #define ET_HIPROC 0xffff /* processor-specific */
94 #define EM_NONE 0 /* no machine */
95 #define EM_M32 1 /* at&t we 32100 */
96 #define EM_SPARC 2 /* sparc */
97 #define EM_386 3 /* intel architecture */
98 #define EM_68K 4 /* motorola 68000 */
99 #define EM_88K 5 /* motorola 88000 */
100 #define EM_860 7 /* intel 80860 */
101 #define EM_MIPS 9 /* mips rs3000 big-endian */
102 #define EM_MIPS_RS4_BE 10 /* mips rs4000 big-endian */
103 #define EM_LORESERVED 11
104 #define EM_HIRESERVED 16
106 #define EV_NONE 0 /* invalid version */
107 #define EV_CURRENT 1 /* current version */
109 #define EI_MAG0 0 /* file identification */
110 #define EI_MAG1 1 /* file identification */
111 #define EI_MAG2 2 /* file identification */
112 #define EI_MAG3 3 /* file identification */
113 #define EI_CLASS 4 /* file class */
114 #define EI_DATA 5 /* data encoding */
115 #define EI_VERSION 6 /* file version */
117 * EI_PAD deviates from the pdf specification, where its value is 7, since
118 * EI_OSABI and EI_ABIVERSION have been introduced. EI_OSABI and
119 * EI_OSABIVERSION are from linux elf.h for code usage compatibility.
121 #define EI_PAD 9 /* start of padding bytes */
124 #define EI_ABIVERSION 8
127 * ELFMAG and SELFMAG are names/values from linux elf.h, for code usage
130 #define ELFMAG "\177ELF"
133 /* EI_CLASS values */
134 #define ELFCLASSNONE 0
139 #define ELFDATANONE 0
140 #define ELFDATA2LSB 1
141 #define ELFDATA2MSB 2
161 #define PT_LOPROC 0x70000000
162 #define PT_HIPROC 0x7fffffff
164 * PT_TLS and PT_GNU_STACK are from linux elf.h, for code usage
168 #define PT_GNU_STACK 0x6474e551
174 * PF_MASKOS is from linux elf.h, for code usage compatibility
176 #define PF_MASKOS 0x0ff00000 /* os specific */
179 * ncfileutil wants section headers, even though service runtime does
192 Elf32_Word sh_addralign
;
193 Elf32_Word sh_entsize
;
196 #define SHF_WRITE 0x1
197 #define SHF_ALLOC 0x2
198 #define SHF_EXECINSTR 0x4
199 #define SHF_MASKPROC 0xf0000000
203 #endif /* NATIVE_CLIENT_INCLUDE_ELF_H_ */