Upx_Doxygen
https://github.com/upx/upx
p_elf_enum.h
1 /* p_elf_enum.h --
2 
3  This file is part of the UPX executable compressor.
4 
5  Copyright (C) 1996-2016 Markus Franz Xaver Johannes Oberhumer
6  Copyright (C) 1996-2016 Laszlo Molnar
7  All Rights Reserved.
8 
9  UPX and the UCL library are free software; you can redistribute them
10  and/or modify them under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of
12  the License, or (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; see the file COPYING.
21  If not, write to the Free Software Foundation, Inc.,
22  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24  Markus F.X.J. Oberhumer Laszlo Molnar
25  <markus@oberhumer.com> <ezerotven+github@gmail.com>
26  */
27 
28 
29 /*************************************************************************
30 // Use the preprocessor to work around
31 // - that the types embedding these enums have to be PODs, and
32 // deriving from an empty base class (which is the usual C++ way
33 // of "importing" enums) does not yield a POD any more
34 // - that older compilers do not correctly perform EBCO
35 **************************************************************************/
36 
37 #ifdef WANT_EHDR_ENUM
38 #undef WANT_EHDR_ENUM
39  enum { // e_ident[]
40  EI_CLASS = 4,
41  EI_DATA = 5, /* Data encoding */
42  EI_VERSION = 6,
43  EI_OSABI = 7,
44  EI_ABIVERSION = 8
45  };
46  enum { // e_ident[EI_CLASS]
47  ELFCLASS32 = 1, /* 32-bit objects */
48  ELFCLASS64 = 2 /* 64-bit objects */
49  };
50  enum { // e_ident[EI_DATA]
51  ELFDATA2LSB = 1, /* 2's complement, little endian */
52  ELFDATA2MSB = 2 /* 2's complement, big endian */
53  };
54  enum { // e_ident[EI_OSABI]
55  ELFOSABI_NONE = 0, // == ELFOSABI_SYSV
56  ELFOSABI_NETBSD = 2,
57  ELFOSABI_LINUX = 3,
58  ELFOSABI_FREEBSD = 9,
59  ELFOSABI_OPENBSD = 12,
60  ELFOSABI_ARM = 97
61  };
62  enum { // e_type
63  ET_NONE = 0, /* No file type */
64  ET_REL = 1, /* Relocatable file */
65  ET_EXEC = 2, /* Executable file */
66  ET_DYN = 3, /* Shared object file */
67  ET_CORE = 4 /* Core file */
68  };
69  enum { // e_machine
70  EM_386 = 3,
71  EM_MIPS = 8,
72  EM_MIPS_RS3_LE = 10, /* MIPS R3000 little-endian */
73  EM_PPC = 20,
74  EM_PPC64 = 21,
75  EM_ARM = 40,
76  EM_X86_64 = 62
77 
78  };
79  enum { // e_version
80  EV_CURRENT = 1
81  };
82 #endif
83 
84 
85 #ifdef WANT_PHDR_ENUM
86 #undef WANT_PHDR_ENUM
87  enum { // p_type
88  PT_LOAD = 1, /* Loadable program segment */
89  PT_DYNAMIC = 2, /* Dynamic linking information */
90  PT_INTERP = 3, /* Name of program interpreter */
91  PT_NOTE = 4, /* Auxiliary information (esp. OpenBSD) */
92  PT_PHDR = 6 /* Entry for header table itself */
93  };
94 
95  enum { // p_flags
96  PF_X = 1, /* Segment is executable */
97  PF_W = 2, /* Segment is writable */
98  PF_R = 4 /* Segment is readable */
99  };
100 #endif
101 
102 
103 #ifdef WANT_SHDR_ENUM
104 #undef WANT_SHDR_ENUM
105  enum { // sh_type
106  SHT_NULL = 0, /* Section header table entry unused */
107  SHT_PROGBITS = 1, /* Program data */
108  SHT_SYMTAB = 2, /* Symbol table */
109  SHT_STRTAB = 3, /* String table */
110  SHT_RELA = 4, /* Relocation entries with addends */
111  SHT_HASH = 5, /* Symbol hash table */
112  SHT_DYNAMIC = 6, /* Dynamic linking information */
113  SHT_NOTE = 7, /* Notes */
114  SHT_NOBITS = 8, /* Program space with no data (bss) */
115  SHT_REL = 9, /* Relocation entries, no addends */
116  SHT_SHLIB = 10, /* Reserved */
117  SHT_DYNSYM = 11, /* Dynamic linker symbol table */
118  /* 12, 13 hole */
119  SHT_INIT_ARRAY = 14, /* Array of constructors */
120  SHT_FINI_ARRAY = 15, /* Array of destructors */
121  SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
122  SHT_GROUP = 17, /* Section group */
123  SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */
124  SHT_GNU_LIBLIST = 0x6ffffff7 /* Prelink library list */
125  };
126 
127  enum { // sh_flags
128  SHF_WRITE = (1 << 0), /* Writable */
129  SHF_ALLOC = (1 << 1), /* Occupies memory during execution */
130  SHF_EXECINSTR = (1 << 2), /* Executable */
131  SHF_MERGE = (1 << 4), /* Might be merged */
132  SHF_STRINGS = (1 << 5), /* Contains nul-terminated strings */
133  SHF_INFO_LINK = (1 << 6), /* 'sh_info' contains SHT index */
134  SHF_LINK_ORDER = (1 << 7) /* Preserve order after combining */
135  };
136 #endif
137 
138 
139 #ifdef WANT_DYN_ENUM
140 #undef WANT_DYN_ENUM
141  enum { // d_tag
142  DT_NULL = 0, /* End flag */
143  DT_NEEDED = 1, /* Name of needed library */
144  DT_PLTRELSZ = 2, /* Size in bytes of PLT relocs */
145  DT_HASH = 4, /* Hash table of symbol names */
146  DT_STRTAB = 5, /* String table */
147  DT_SYMTAB = 6, /* Symbol table */
148  DT_RELA = 7, /* Relocations which do contain an addend */
149  DT_RELASZ = 8, /* Total size of Rela relocs */
150  DT_RELAENT = 9, /* Size of one RELA relocation */
151  DT_INIT = 12, /* Address of init function */
152  DT_REL = 17, /* Relocations which contain no addend */
153  DT_RELENT = 19, /* Size of one Rel relocation */
154  DT_STRSZ = 10, /* Sizeof string table */
155  DT_PLTREL = 20, /* Type of reloc in PLT */
156  DT_TEXTREL = 22, /* Reloc might modify .text */
157  DT_JMPREL = 23, /* Address of PLT relocs */
158  DT_CHECKSUM = 0x6ffffdf8, /* Only for prelink? */
159  DT_GNU_HASH = 0x6ffffef5, /* GNU-style hash table */
160  DT_VERSYM = 0x6ffffff0, /* version[] for each symbol */
161  DT_VERDEF = 0x6ffffffc, /* version definitions[] */
162  DT_VERNEEDED= 0x6ffffffe /* version[] needed */
163  };
164 #endif
165 
166 
167 #ifdef WANT_SYM_ENUM
168 #undef WANT_SYM_ENUM
169  enum { // st_bind (high 4 bits of st_info)
170  STB_LOCAL = 0, /* Local symbol */
171  STB_GLOBAL = 1, /* Global symbol */
172  STB_WEAK = 2 /* Weak symbol */
173  };
174 
175  enum { // st_type (low 4 bits of st_info)
176  STT_NOTYPE = 0, /* Symbol type is unspecified */
177  STT_OBJECT = 1, /* Symbol is a data object */
178  STT_FUNC = 2, /* Symbol is a code object */
179  STT_SECTION = 3, /* Symbol associated with a section */
180  STT_FILE = 4, /* Symbol's name is file name */
181  STT_COMMON = 5, /* Symbol is a common data object */
182  STT_TLS = 6 /* Symbol is thread-local data object*/
183  };
184 
185  enum { // st_other (visibility)
186  STV_DEFAULT = 0, /* Default symbol visibility rules */
187  STV_INTERNAL = 1, /* Processor specific hidden class */
188  STV_HIDDEN = 2, /* Sym unavailable in other modules */
189  STV_PROTECTED= 3 /* Not preemptible, not exported */
190  };
191 
192  enum { // st_shndx
193  SHN_UNDEF = 0, /* Undefined section */
194  SHN_ABS = 0xfff1, /* Associated symbol is absolute */
195  SHN_COMMON = 0xfff2 /* Associated symbol is common */
196  };
197 #endif
198 
199 
200 #ifdef WANT_NHDR_ENUM
201 #undef WANT_NHDR_ENUM
202  enum { // ELF PT_NOTE types
203 #define ELF_NOTE_GNU_NAME "GNU\0"
204  NT_GNU_ABI_TAG = 1,
205  NT_GNU_HWCAP = 2,
206  NT_GNU_BUILD_ID = 3,
207 
208 #define ELF_NOTE_OPENBSD_NAME "OpenBSD\0"
209  NHDR_OPENBSD_TAG = 1,
210 
211 #define ELF_NOTE_NETBSD_NAME "NetBSD\0"
212  NHDR_NETBSD_TAG = 1,
213  NHDR_CHECKSUM_TAG = 2,
214  NHDR_PAX_TAG = 3
215  };
216 
217  enum { // descsz descriptor sizes
218  GNU_ABI_DESCSZ = 16, // int GNU_OS, major, minor, subminor;
219  NETBSD_DESCSZ = 4, // major_ver * (10**8) + minor
220  OPENBSD_DESCSZ = 4, // 32-bit zero
221  // CHECKSUM_DESCSZ is 2*sizeof(short) + sizeof(checksum)
222  PAX_DESCSZ = 4 // 32-bit mask
223  };
224 
225  enum { // GNU OS/version
226  GNU_OS_LINUX = 0,
227  GNU_OS_HURD = 1,
228  GNU_OS_SOLARIS = 2
229  };
230 
231  enum { // NetBSD checksum methods
232  CHECKSUM_CRC32 = 1,
233  CHECKSUM_MD5 = 2,
234  CHECKSUM_SHA1 = 3,
235  CHECKSUM_SHA256 = 4
236  };
237 
238 #define ELF_NOTE_PAX_NAME "PaX\0"
239  enum { // NetBSD PaX bit values
240  PAX_MPROTECT = (1<<0), /* force enable Mprotect */
241  PAX_NOMPROTECT = (1<<1), /* force disable Mprotect */
242  PAX_GUARD = (1<<2), /* force enable SEGVguard */
243  PAX_NOGUARD = (1<<3), /* force disable SEGVguard */
244  PAX_ASLR = (1<<4), /* force enable ASLR */
245  PAX_NOASLR = (1<<5) /* force disable ASLR */
246  };
247 #endif
248 
249 /* vim:set ts=4 sw=4 et: */