llvm.org GIT mirror llvm / 19ca2b0
Move Object format code to lib/BinaryFormat. This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304864 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 2 years ago
258 changed file(s) with 8553 addition(s) and 8420 deletion(s). Raw diff Collapse all Expand all
4848 //===----------------------------------------------------------------------===//
4949
5050 #include "llvm/ADT/STLExtras.h"
51 #include "llvm/IR/Verifier.h"
51 #include "llvm/BinaryFormat/Dwarf.h"
5252 #include "llvm/ExecutionEngine/MCJIT.h"
5353 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
5454 #include "llvm/IR/DataLayout.h"
5858 #include "llvm/IR/LLVMContext.h"
5959 #include "llvm/IR/LegacyPassManager.h"
6060 #include "llvm/IR/Module.h"
61 #include "llvm/Support/Dwarf.h"
61 #include "llvm/IR/Verifier.h"
6262 #include "llvm/Support/TargetSelect.h"
6363 #include "llvm/Target/TargetOptions.h"
6464 #include "llvm/Transforms/Scalar.h"
0 //===-- llvm/BinaryFormat/COFF.h --------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains an definitions used in Windows COFF Files.
10 //
11 // Structures and enums defined within this file where created using
12 // information from Microsoft's publicly available PE/COFF format document:
13 //
14 // Microsoft Portable Executable and Common Object File Format Specification
15 // Revision 8.1 - February 15, 2008
16 //
17 // As of 5/2/2010, hosted by Microsoft at:
18 // http://www.microsoft.com/whdc/system/platform/firmware/pecoff.mspx
19 //
20 //===----------------------------------------------------------------------===//
21
22 #ifndef LLVM_BINARYFORMAT_COFF_H
23 #define LLVM_BINARYFORMAT_COFF_H
24
25 #include "llvm/Support/DataTypes.h"
26 #include
27 #include
28
29 namespace llvm {
30 namespace COFF {
31
32 // The maximum number of sections that a COFF object can have (inclusive).
33 const int32_t MaxNumberOfSections16 = 65279;
34
35 // The PE signature bytes that follows the DOS stub header.
36 static const char PEMagic[] = {'P', 'E', '\0', '\0'};
37
38 static const char BigObjMagic[] = {
39 '\xc7', '\xa1', '\xba', '\xd1', '\xee', '\xba', '\xa9', '\x4b',
40 '\xaf', '\x20', '\xfa', '\xf6', '\x6a', '\xa4', '\xdc', '\xb8',
41 };
42
43 static const char ClGlObjMagic[] = {
44 '\x38', '\xfe', '\xb3', '\x0c', '\xa5', '\xd9', '\xab', '\x4d',
45 '\xac', '\x9b', '\xd6', '\xb6', '\x22', '\x26', '\x53', '\xc2',
46 };
47
48 // Sizes in bytes of various things in the COFF format.
49 enum {
50 Header16Size = 20,
51 Header32Size = 56,
52 NameSize = 8,
53 Symbol16Size = 18,
54 Symbol32Size = 20,
55 SectionSize = 40,
56 RelocationSize = 10
57 };
58
59 struct header {
60 uint16_t Machine;
61 int32_t NumberOfSections;
62 uint32_t TimeDateStamp;
63 uint32_t PointerToSymbolTable;
64 uint32_t NumberOfSymbols;
65 uint16_t SizeOfOptionalHeader;
66 uint16_t Characteristics;
67 };
68
69 struct BigObjHeader {
70 enum : uint16_t { MinBigObjectVersion = 2 };
71
72 uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0).
73 uint16_t Sig2; ///< Must be 0xFFFF.
74 uint16_t Version;
75 uint16_t Machine;
76 uint32_t TimeDateStamp;
77 uint8_t UUID[16];
78 uint32_t unused1;
79 uint32_t unused2;
80 uint32_t unused3;
81 uint32_t unused4;
82 uint32_t NumberOfSections;
83 uint32_t PointerToSymbolTable;
84 uint32_t NumberOfSymbols;
85 };
86
87 enum MachineTypes {
88 MT_Invalid = 0xffff,
89
90 IMAGE_FILE_MACHINE_UNKNOWN = 0x0,
91 IMAGE_FILE_MACHINE_AM33 = 0x13,
92 IMAGE_FILE_MACHINE_AMD64 = 0x8664,
93 IMAGE_FILE_MACHINE_ARM = 0x1C0,
94 IMAGE_FILE_MACHINE_ARMNT = 0x1C4,
95 IMAGE_FILE_MACHINE_ARM64 = 0xAA64,
96 IMAGE_FILE_MACHINE_EBC = 0xEBC,
97 IMAGE_FILE_MACHINE_I386 = 0x14C,
98 IMAGE_FILE_MACHINE_IA64 = 0x200,
99 IMAGE_FILE_MACHINE_M32R = 0x9041,
100 IMAGE_FILE_MACHINE_MIPS16 = 0x266,
101 IMAGE_FILE_MACHINE_MIPSFPU = 0x366,
102 IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466,
103 IMAGE_FILE_MACHINE_POWERPC = 0x1F0,
104 IMAGE_FILE_MACHINE_POWERPCFP = 0x1F1,
105 IMAGE_FILE_MACHINE_R4000 = 0x166,
106 IMAGE_FILE_MACHINE_SH3 = 0x1A2,
107 IMAGE_FILE_MACHINE_SH3DSP = 0x1A3,
108 IMAGE_FILE_MACHINE_SH4 = 0x1A6,
109 IMAGE_FILE_MACHINE_SH5 = 0x1A8,
110 IMAGE_FILE_MACHINE_THUMB = 0x1C2,
111 IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169
112 };
113
114 enum Characteristics {
115 C_Invalid = 0,
116
117 /// The file does not contain base relocations and must be loaded at its
118 /// preferred base. If this cannot be done, the loader will error.
119 IMAGE_FILE_RELOCS_STRIPPED = 0x0001,
120 /// The file is valid and can be run.
121 IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002,
122 /// COFF line numbers have been stripped. This is deprecated and should be
123 /// 0.
124 IMAGE_FILE_LINE_NUMS_STRIPPED = 0x0004,
125 /// COFF symbol table entries for local symbols have been removed. This is
126 /// deprecated and should be 0.
127 IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x0008,
128 /// Aggressively trim working set. This is deprecated and must be 0.
129 IMAGE_FILE_AGGRESSIVE_WS_TRIM = 0x0010,
130 /// Image can handle > 2GiB addresses.
131 IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020,
132 /// Little endian: the LSB precedes the MSB in memory. This is deprecated
133 /// and should be 0.
134 IMAGE_FILE_BYTES_REVERSED_LO = 0x0080,
135 /// Machine is based on a 32bit word architecture.
136 IMAGE_FILE_32BIT_MACHINE = 0x0100,
137 /// Debugging info has been removed.
138 IMAGE_FILE_DEBUG_STRIPPED = 0x0200,
139 /// If the image is on removable media, fully load it and copy it to swap.
140 IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400,
141 /// If the image is on network media, fully load it and copy it to swap.
142 IMAGE_FILE_NET_RUN_FROM_SWAP = 0x0800,
143 /// The image file is a system file, not a user program.
144 IMAGE_FILE_SYSTEM = 0x1000,
145 /// The image file is a DLL.
146 IMAGE_FILE_DLL = 0x2000,
147 /// This file should only be run on a uniprocessor machine.
148 IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000,
149 /// Big endian: the MSB precedes the LSB in memory. This is deprecated
150 /// and should be 0.
151 IMAGE_FILE_BYTES_REVERSED_HI = 0x8000
152 };
153
154 enum ResourceTypeID {
155 RID_Cursor = 1,
156 RID_Bitmap = 2,
157 RID_Icon = 3,
158 RID_Menu = 4,
159 RID_Dialog = 5,
160 RID_String = 6,
161 RID_FontDir = 7,
162 RID_Font = 8,
163 RID_Accelerator = 9,
164 RID_RCData = 10,
165 RID_MessageTable = 11,
166 RID_Group_Cursor = 12,
167 RID_Group_Icon = 14,
168 RID_Version = 16,
169 RID_DLGInclude = 17,
170 RID_PlugPlay = 19,
171 RID_VXD = 20,
172 RID_AniCursor = 21,
173 RID_AniIcon = 22,
174 RID_HTML = 23,
175 RID_Manifest = 24,
176 };
177
178 struct symbol {
179 char Name[NameSize];
180 uint32_t Value;
181 int32_t SectionNumber;
182 uint16_t Type;
183 uint8_t StorageClass;
184 uint8_t NumberOfAuxSymbols;
185 };
186
187 enum SymbolSectionNumber : int32_t {
188 IMAGE_SYM_DEBUG = -2,
189 IMAGE_SYM_ABSOLUTE = -1,
190 IMAGE_SYM_UNDEFINED = 0
191 };
192
193 /// Storage class tells where and what the symbol represents
194 enum SymbolStorageClass {
195 SSC_Invalid = 0xff,
196
197 IMAGE_SYM_CLASS_END_OF_FUNCTION = -1, ///< Physical end of function
198 IMAGE_SYM_CLASS_NULL = 0, ///< No symbol
199 IMAGE_SYM_CLASS_AUTOMATIC = 1, ///< Stack variable
200 IMAGE_SYM_CLASS_EXTERNAL = 2, ///< External symbol
201 IMAGE_SYM_CLASS_STATIC = 3, ///< Static
202 IMAGE_SYM_CLASS_REGISTER = 4, ///< Register variable
203 IMAGE_SYM_CLASS_EXTERNAL_DEF = 5, ///< External definition
204 IMAGE_SYM_CLASS_LABEL = 6, ///< Label
205 IMAGE_SYM_CLASS_UNDEFINED_LABEL = 7, ///< Undefined label
206 IMAGE_SYM_CLASS_MEMBER_OF_STRUCT = 8, ///< Member of structure
207 IMAGE_SYM_CLASS_ARGUMENT = 9, ///< Function argument
208 IMAGE_SYM_CLASS_STRUCT_TAG = 10, ///< Structure tag
209 IMAGE_SYM_CLASS_MEMBER_OF_UNION = 11, ///< Member of union
210 IMAGE_SYM_CLASS_UNION_TAG = 12, ///< Union tag
211 IMAGE_SYM_CLASS_TYPE_DEFINITION = 13, ///< Type definition
212 IMAGE_SYM_CLASS_UNDEFINED_STATIC = 14, ///< Undefined static
213 IMAGE_SYM_CLASS_ENUM_TAG = 15, ///< Enumeration tag
214 IMAGE_SYM_CLASS_MEMBER_OF_ENUM = 16, ///< Member of enumeration
215 IMAGE_SYM_CLASS_REGISTER_PARAM = 17, ///< Register parameter
216 IMAGE_SYM_CLASS_BIT_FIELD = 18, ///< Bit field
217 /// ".bb" or ".eb" - beginning or end of block
218 IMAGE_SYM_CLASS_BLOCK = 100,
219 /// ".bf" or ".ef" - beginning or end of function
220 IMAGE_SYM_CLASS_FUNCTION = 101,
221 IMAGE_SYM_CLASS_END_OF_STRUCT = 102, ///< End of structure
222 IMAGE_SYM_CLASS_FILE = 103, ///< File name
223 /// Line number, reformatted as symbol
224 IMAGE_SYM_CLASS_SECTION = 104,
225 IMAGE_SYM_CLASS_WEAK_EXTERNAL = 105, ///< Duplicate tag
226 /// External symbol in dmert public lib
227 IMAGE_SYM_CLASS_CLR_TOKEN = 107
228 };
229
230 enum SymbolBaseType {
231 IMAGE_SYM_TYPE_NULL = 0, ///< No type information or unknown base type.
232 IMAGE_SYM_TYPE_VOID = 1, ///< Used with void pointers and functions.
233 IMAGE_SYM_TYPE_CHAR = 2, ///< A character (signed byte).
234 IMAGE_SYM_TYPE_SHORT = 3, ///< A 2-byte signed integer.
235 IMAGE_SYM_TYPE_INT = 4, ///< A natural integer type on the target.
236 IMAGE_SYM_TYPE_LONG = 5, ///< A 4-byte signed integer.
237 IMAGE_SYM_TYPE_FLOAT = 6, ///< A 4-byte floating-point number.
238 IMAGE_SYM_TYPE_DOUBLE = 7, ///< An 8-byte floating-point number.
239 IMAGE_SYM_TYPE_STRUCT = 8, ///< A structure.
240 IMAGE_SYM_TYPE_UNION = 9, ///< An union.
241 IMAGE_SYM_TYPE_ENUM = 10, ///< An enumerated type.
242 IMAGE_SYM_TYPE_MOE = 11, ///< A member of enumeration (a specific value).
243 IMAGE_SYM_TYPE_BYTE = 12, ///< A byte; unsigned 1-byte integer.
244 IMAGE_SYM_TYPE_WORD = 13, ///< A word; unsigned 2-byte integer.
245 IMAGE_SYM_TYPE_UINT = 14, ///< An unsigned integer of natural size.
246 IMAGE_SYM_TYPE_DWORD = 15 ///< An unsigned 4-byte integer.
247 };
248
249 enum SymbolComplexType {
250 IMAGE_SYM_DTYPE_NULL = 0, ///< No complex type; simple scalar variable.
251 IMAGE_SYM_DTYPE_POINTER = 1, ///< A pointer to base type.
252 IMAGE_SYM_DTYPE_FUNCTION = 2, ///< A function that returns a base type.
253 IMAGE_SYM_DTYPE_ARRAY = 3, ///< An array of base type.
254
255 /// Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
256 SCT_COMPLEX_TYPE_SHIFT = 4
257 };
258
259 enum AuxSymbolType { IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1 };
260
261 struct section {
262 char Name[NameSize];
263 uint32_t VirtualSize;
264 uint32_t VirtualAddress;
265 uint32_t SizeOfRawData;
266 uint32_t PointerToRawData;
267 uint32_t PointerToRelocations;
268 uint32_t PointerToLineNumbers;
269 uint16_t NumberOfRelocations;
270 uint16_t NumberOfLineNumbers;
271 uint32_t Characteristics;
272 };
273
274 enum SectionCharacteristics : uint32_t {
275 SC_Invalid = 0xffffffff,
276
277 IMAGE_SCN_TYPE_NOLOAD = 0x00000002,
278 IMAGE_SCN_TYPE_NO_PAD = 0x00000008,
279 IMAGE_SCN_CNT_CODE = 0x00000020,
280 IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040,
281 IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080,
282 IMAGE_SCN_LNK_OTHER = 0x00000100,
283 IMAGE_SCN_LNK_INFO = 0x00000200,
284 IMAGE_SCN_LNK_REMOVE = 0x00000800,
285 IMAGE_SCN_LNK_COMDAT = 0x00001000,
286 IMAGE_SCN_GPREL = 0x00008000,
287 IMAGE_SCN_MEM_PURGEABLE = 0x00020000,
288 IMAGE_SCN_MEM_16BIT = 0x00020000,
289 IMAGE_SCN_MEM_LOCKED = 0x00040000,
290 IMAGE_SCN_MEM_PRELOAD = 0x00080000,
291 IMAGE_SCN_ALIGN_1BYTES = 0x00100000,
292 IMAGE_SCN_ALIGN_2BYTES = 0x00200000,
293 IMAGE_SCN_ALIGN_4BYTES = 0x00300000,
294 IMAGE_SCN_ALIGN_8BYTES = 0x00400000,
295 IMAGE_SCN_ALIGN_16BYTES = 0x00500000,
296 IMAGE_SCN_ALIGN_32BYTES = 0x00600000,
297 IMAGE_SCN_ALIGN_64BYTES = 0x00700000,
298 IMAGE_SCN_ALIGN_128BYTES = 0x00800000,
299 IMAGE_SCN_ALIGN_256BYTES = 0x00900000,
300 IMAGE_SCN_ALIGN_512BYTES = 0x00A00000,
301 IMAGE_SCN_ALIGN_1024BYTES = 0x00B00000,
302 IMAGE_SCN_ALIGN_2048BYTES = 0x00C00000,
303 IMAGE_SCN_ALIGN_4096BYTES = 0x00D00000,
304 IMAGE_SCN_ALIGN_8192BYTES = 0x00E00000,
305 IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000,
306 IMAGE_SCN_MEM_DISCARDABLE = 0x02000000,
307 IMAGE_SCN_MEM_NOT_CACHED = 0x04000000,
308 IMAGE_SCN_MEM_NOT_PAGED = 0x08000000,
309 IMAGE_SCN_MEM_SHARED = 0x10000000,
310 IMAGE_SCN_MEM_EXECUTE = 0x20000000,
311 IMAGE_SCN_MEM_READ = 0x40000000,
312 IMAGE_SCN_MEM_WRITE = 0x80000000
313 };
314
315 struct relocation {
316 uint32_t VirtualAddress;
317 uint32_t SymbolTableIndex;
318 uint16_t Type;
319 };
320
321 enum RelocationTypeI386 {
322 IMAGE_REL_I386_ABSOLUTE = 0x0000,
323 IMAGE_REL_I386_DIR16 = 0x0001,
324 IMAGE_REL_I386_REL16 = 0x0002,
325 IMAGE_REL_I386_DIR32 = 0x0006,
326 IMAGE_REL_I386_DIR32NB = 0x0007,
327 IMAGE_REL_I386_SEG12 = 0x0009,
328 IMAGE_REL_I386_SECTION = 0x000A,
329 IMAGE_REL_I386_SECREL = 0x000B,
330 IMAGE_REL_I386_TOKEN = 0x000C,
331 IMAGE_REL_I386_SECREL7 = 0x000D,
332 IMAGE_REL_I386_REL32 = 0x0014
333 };
334
335 enum RelocationTypeAMD64 {
336 IMAGE_REL_AMD64_ABSOLUTE = 0x0000,
337 IMAGE_REL_AMD64_ADDR64 = 0x0001,
338 IMAGE_REL_AMD64_ADDR32 = 0x0002,
339 IMAGE_REL_AMD64_ADDR32NB = 0x0003,
340 IMAGE_REL_AMD64_REL32 = 0x0004,
341 IMAGE_REL_AMD64_REL32_1 = 0x0005,
342 IMAGE_REL_AMD64_REL32_2 = 0x0006,
343 IMAGE_REL_AMD64_REL32_3 = 0x0007,
344 IMAGE_REL_AMD64_REL32_4 = 0x0008,
345 IMAGE_REL_AMD64_REL32_5 = 0x0009,
346 IMAGE_REL_AMD64_SECTION = 0x000A,
347 IMAGE_REL_AMD64_SECREL = 0x000B,
348 IMAGE_REL_AMD64_SECREL7 = 0x000C,
349 IMAGE_REL_AMD64_TOKEN = 0x000D,
350 IMAGE_REL_AMD64_SREL32 = 0x000E,
351 IMAGE_REL_AMD64_PAIR = 0x000F,
352 IMAGE_REL_AMD64_SSPAN32 = 0x0010
353 };
354
355 enum RelocationTypesARM {
356 IMAGE_REL_ARM_ABSOLUTE = 0x0000,
357 IMAGE_REL_ARM_ADDR32 = 0x0001,
358 IMAGE_REL_ARM_ADDR32NB = 0x0002,
359 IMAGE_REL_ARM_BRANCH24 = 0x0003,
360 IMAGE_REL_ARM_BRANCH11 = 0x0004,
361 IMAGE_REL_ARM_TOKEN = 0x0005,
362 IMAGE_REL_ARM_BLX24 = 0x0008,
363 IMAGE_REL_ARM_BLX11 = 0x0009,
364 IMAGE_REL_ARM_SECTION = 0x000E,
365 IMAGE_REL_ARM_SECREL = 0x000F,
366 IMAGE_REL_ARM_MOV32A = 0x0010,
367 IMAGE_REL_ARM_MOV32T = 0x0011,
368 IMAGE_REL_ARM_BRANCH20T = 0x0012,
369 IMAGE_REL_ARM_BRANCH24T = 0x0014,
370 IMAGE_REL_ARM_BLX23T = 0x0015
371 };
372
373 enum RelocationTypesARM64 {
374 IMAGE_REL_ARM64_ABSOLUTE = 0x0000,
375 IMAGE_REL_ARM64_ADDR32 = 0x0001,
376 IMAGE_REL_ARM64_ADDR32NB = 0x0002,
377 IMAGE_REL_ARM64_BRANCH26 = 0x0003,
378 IMAGE_REL_ARM64_PAGEBASE_REL2 = 0x0004,
379 IMAGE_REL_ARM64_REL21 = 0x0005,
380 IMAGE_REL_ARM64_PAGEOFFSET_12A = 0x0006,
381 IMAGE_REL_ARM64_PAGEOFFSET_12L = 0x0007,
382 IMAGE_REL_ARM64_SECREL = 0x0008,
383 IMAGE_REL_ARM64_SECREL_LOW12A = 0x0009,
384 IMAGE_REL_ARM64_SECREL_HIGH12A = 0x000A,
385 IMAGE_REL_ARM64_SECREL_LOW12L = 0x000B,
386 IMAGE_REL_ARM64_TOKEN = 0x000C,
387 IMAGE_REL_ARM64_SECTION = 0x000D,
388 IMAGE_REL_ARM64_ADDR64 = 0x000E,
389 IMAGE_REL_ARM64_BRANCH19 = 0x000F,
390 IMAGE_REL_ARM64_BRANCH14 = 0x0010,
391 };
392
393 enum COMDATType {
394 IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
395 IMAGE_COMDAT_SELECT_ANY,
396 IMAGE_COMDAT_SELECT_SAME_SIZE,
397 IMAGE_COMDAT_SELECT_EXACT_MATCH,
398 IMAGE_COMDAT_SELECT_ASSOCIATIVE,
399 IMAGE_COMDAT_SELECT_LARGEST,
400 IMAGE_COMDAT_SELECT_NEWEST
401 };
402
403 // Auxiliary Symbol Formats
404 struct AuxiliaryFunctionDefinition {
405 uint32_t TagIndex;
406 uint32_t TotalSize;
407 uint32_t PointerToLinenumber;
408 uint32_t PointerToNextFunction;
409 char unused[2];
410 };
411
412 struct AuxiliarybfAndefSymbol {
413 uint8_t unused1[4];
414 uint16_t Linenumber;
415 uint8_t unused2[6];
416 uint32_t PointerToNextFunction;
417 uint8_t unused3[2];
418 };
419
420 struct AuxiliaryWeakExternal {
421 uint32_t TagIndex;
422 uint32_t Characteristics;
423 uint8_t unused[10];
424 };
425
426 enum WeakExternalCharacteristics {
427 IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1,
428 IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2,
429 IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3
430 };
431
432 struct AuxiliarySectionDefinition {
433 uint32_t Length;
434 uint16_t NumberOfRelocations;
435 uint16_t NumberOfLinenumbers;
436 uint32_t CheckSum;
437 uint32_t Number;
438 uint8_t Selection;
439 char unused;
440 };
441
442 struct AuxiliaryCLRToken {
443 uint8_t AuxType;
444 uint8_t unused1;
445 uint32_t SymbolTableIndex;
446 char unused2[12];
447 };
448
449 union Auxiliary {
450 AuxiliaryFunctionDefinition FunctionDefinition;
451 AuxiliarybfAndefSymbol bfAndefSymbol;
452 AuxiliaryWeakExternal WeakExternal;
453 AuxiliarySectionDefinition SectionDefinition;
454 };
455
456 /// @brief The Import Directory Table.
457 ///
458 /// There is a single array of these and one entry per imported DLL.
459 struct ImportDirectoryTableEntry {
460 uint32_t ImportLookupTableRVA;
461 uint32_t TimeDateStamp;
462 uint32_t ForwarderChain;
463 uint32_t NameRVA;
464 uint32_t ImportAddressTableRVA;
465 };
466
467 /// @brief The PE32 Import Lookup Table.
468 ///
469 /// There is an array of these for each imported DLL. It represents either
470 /// the ordinal to import from the target DLL, or a name to lookup and import
471 /// from the target DLL.
472 ///
473 /// This also happens to be the same format used by the Import Address Table
474 /// when it is initially written out to the image.
475 struct ImportLookupTableEntry32 {
476 uint32_t data;
477
478 /// @brief Is this entry specified by ordinal, or name?
479 bool isOrdinal() const { return data & 0x80000000; }
480
481 /// @brief Get the ordinal value of this entry. isOrdinal must be true.
482 uint16_t getOrdinal() const {
483 assert(isOrdinal() && "ILT entry is not an ordinal!");
484 return data & 0xFFFF;
485 }
486
487 /// @brief Set the ordinal value and set isOrdinal to true.
488 void setOrdinal(uint16_t o) {
489 data = o;
490 data |= 0x80000000;
491 }
492
493 /// @brief Get the Hint/Name entry RVA. isOrdinal must be false.
494 uint32_t getHintNameRVA() const {
495 assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!");
496 return data;
497 }
498
499 /// @brief Set the Hint/Name entry RVA and set isOrdinal to false.
500 void setHintNameRVA(uint32_t rva) { data = rva; }
501 };
502
503 /// @brief The DOS compatible header at the front of all PEs.
504 struct DOSHeader {
505 uint16_t Magic;
506 uint16_t UsedBytesInTheLastPage;
507 uint16_t FileSizeInPages;
508 uint16_t NumberOfRelocationItems;
509 uint16_t HeaderSizeInParagraphs;
510 uint16_t MinimumExtraParagraphs;
511 uint16_t MaximumExtraParagraphs;
512 uint16_t InitialRelativeSS;
513 uint16_t InitialSP;
514 uint16_t Checksum;
515 uint16_t InitialIP;
516 uint16_t InitialRelativeCS;
517 uint16_t AddressOfRelocationTable;
518 uint16_t OverlayNumber;
519 uint16_t Reserved[4];
520 uint16_t OEMid;
521 uint16_t OEMinfo;
522 uint16_t Reserved2[10];
523 uint32_t AddressOfNewExeHeader;
524 };
525
526 struct PE32Header {
527 enum { PE32 = 0x10b, PE32_PLUS = 0x20b };
528
529 uint16_t Magic;
530 uint8_t MajorLinkerVersion;
531 uint8_t MinorLinkerVersion;
532 uint32_t SizeOfCode;
533 uint32_t SizeOfInitializedData;
534 uint32_t SizeOfUninitializedData;
535 uint32_t AddressOfEntryPoint; // RVA
536 uint32_t BaseOfCode; // RVA
537 uint32_t BaseOfData; // RVA
538 uint32_t ImageBase;
539 uint32_t SectionAlignment;
540 uint32_t FileAlignment;
541 uint16_t MajorOperatingSystemVersion;
542 uint16_t MinorOperatingSystemVersion;
543 uint16_t MajorImageVersion;
544 uint16_t MinorImageVersion;
545 uint16_t MajorSubsystemVersion;
546 uint16_t MinorSubsystemVersion;
547 uint32_t Win32VersionValue;
548 uint32_t SizeOfImage;
549 uint32_t SizeOfHeaders;
550 uint32_t CheckSum;
551 uint16_t Subsystem;
552 // FIXME: This should be DllCharacteristics to match the COFF spec.
553 uint16_t DLLCharacteristics;
554 uint32_t SizeOfStackReserve;
555 uint32_t SizeOfStackCommit;
556 uint32_t SizeOfHeapReserve;
557 uint32_t SizeOfHeapCommit;
558 uint32_t LoaderFlags;
559 // FIXME: This should be NumberOfRvaAndSizes to match the COFF spec.
560 uint32_t NumberOfRvaAndSize;
561 };
562
563 struct DataDirectory {
564 uint32_t RelativeVirtualAddress;
565 uint32_t Size;
566 };
567
568 enum DataDirectoryIndex {
569 EXPORT_TABLE = 0,
570 IMPORT_TABLE,
571 RESOURCE_TABLE,
572 EXCEPTION_TABLE,
573 CERTIFICATE_TABLE,
574 BASE_RELOCATION_TABLE,
575 DEBUG_DIRECTORY,
576 ARCHITECTURE,
577 GLOBAL_PTR,
578 TLS_TABLE,
579 LOAD_CONFIG_TABLE,
580 BOUND_IMPORT,
581 IAT,
582 DELAY_IMPORT_DESCRIPTOR,
583 CLR_RUNTIME_HEADER,
584
585 NUM_DATA_DIRECTORIES
586 };
587
588 enum WindowsSubsystem {
589 IMAGE_SUBSYSTEM_UNKNOWN = 0, ///< An unknown subsystem.
590 IMAGE_SUBSYSTEM_NATIVE = 1, ///< Device drivers and native Windows processes
591 IMAGE_SUBSYSTEM_WINDOWS_GUI = 2, ///< The Windows GUI subsystem.
592 IMAGE_SUBSYSTEM_WINDOWS_CUI = 3, ///< The Windows character subsystem.
593 IMAGE_SUBSYSTEM_OS2_CUI = 5, ///< The OS/2 character subsytem.
594 IMAGE_SUBSYSTEM_POSIX_CUI = 7, ///< The POSIX character subsystem.
595 IMAGE_SUBSYSTEM_NATIVE_WINDOWS = 8, ///< Native Windows 9x driver.
596 IMAGE_SUBSYSTEM_WINDOWS_CE_GUI = 9, ///< Windows CE.
597 IMAGE_SUBSYSTEM_EFI_APPLICATION = 10, ///< An EFI application.
598 IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, ///< An EFI driver with boot
599 /// services.
600 IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, ///< An EFI driver with run-time
601 /// services.
602 IMAGE_SUBSYSTEM_EFI_ROM = 13, ///< An EFI ROM image.
603 IMAGE_SUBSYSTEM_XBOX = 14, ///< XBOX.
604 IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application.
605 };
606
607 enum DLLCharacteristics {
608 /// ASLR with 64 bit address space.
609 IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020,
610 /// DLL can be relocated at load time.
611 IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040,
612 /// Code integrity checks are enforced.
613 IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080,
614 ///< Image is NX compatible.
615 IMAGE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100,
616 /// Isolation aware, but do not isolate the image.
617 IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION = 0x0200,
618 /// Does not use structured exception handling (SEH). No SEH handler may be
619 /// called in this image.
620 IMAGE_DLL_CHARACTERISTICS_NO_SEH = 0x0400,
621 /// Do not bind the image.
622 IMAGE_DLL_CHARACTERISTICS_NO_BIND = 0x0800,
623 ///< Image should execute in an AppContainer.
624 IMAGE_DLL_CHARACTERISTICS_APPCONTAINER = 0x1000,
625 ///< A WDM driver.
626 IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER = 0x2000,
627 ///< Image supports Control Flow Guard.
628 IMAGE_DLL_CHARACTERISTICS_GUARD_CF = 0x4000,
629 /// Terminal Server aware.
630 IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000
631 };
632
633 enum DebugType {
634 IMAGE_DEBUG_TYPE_UNKNOWN = 0,
635 IMAGE_DEBUG_TYPE_COFF = 1,
636 IMAGE_DEBUG_TYPE_CODEVIEW = 2,
637 IMAGE_DEBUG_TYPE_FPO = 3,
638 IMAGE_DEBUG_TYPE_MISC = 4,
639 IMAGE_DEBUG_TYPE_EXCEPTION = 5,
640 IMAGE_DEBUG_TYPE_FIXUP = 6,
641 IMAGE_DEBUG_TYPE_OMAP_TO_SRC = 7,
642 IMAGE_DEBUG_TYPE_OMAP_FROM_SRC = 8,
643 IMAGE_DEBUG_TYPE_BORLAND = 9,
644 IMAGE_DEBUG_TYPE_RESERVED10 = 10,
645 IMAGE_DEBUG_TYPE_CLSID = 11,
646 IMAGE_DEBUG_TYPE_VC_FEATURE = 12,
647 IMAGE_DEBUG_TYPE_POGO = 13,
648 IMAGE_DEBUG_TYPE_ILTCG = 14,
649 IMAGE_DEBUG_TYPE_MPX = 15,
650 IMAGE_DEBUG_TYPE_REPRO = 16,
651 };
652
653 enum BaseRelocationType {
654 IMAGE_REL_BASED_ABSOLUTE = 0,
655 IMAGE_REL_BASED_HIGH = 1,
656 IMAGE_REL_BASED_LOW = 2,
657 IMAGE_REL_BASED_HIGHLOW = 3,
658 IMAGE_REL_BASED_HIGHADJ = 4,
659 IMAGE_REL_BASED_MIPS_JMPADDR = 5,
660 IMAGE_REL_BASED_ARM_MOV32A = 5,
661 IMAGE_REL_BASED_ARM_MOV32T = 7,
662 IMAGE_REL_BASED_MIPS_JMPADDR16 = 9,
663 IMAGE_REL_BASED_DIR64 = 10
664 };
665
666 enum ImportType { IMPORT_CODE = 0, IMPORT_DATA = 1, IMPORT_CONST = 2 };
667
668 enum ImportNameType {
669 /// Import is by ordinal. This indicates that the value in the Ordinal/Hint
670 /// field of the import header is the import's ordinal. If this constant is
671 /// not specified, then the Ordinal/Hint field should always be interpreted
672 /// as the import's hint.
673 IMPORT_ORDINAL = 0,
674 /// The import name is identical to the public symbol name
675 IMPORT_NAME = 1,
676 /// The import name is the public symbol name, but skipping the leading ?,
677 /// @, or optionally _.
678 IMPORT_NAME_NOPREFIX = 2,
679 /// The import name is the public symbol name, but skipping the leading ?,
680 /// @, or optionally _, and truncating at the first @.
681 IMPORT_NAME_UNDECORATE = 3
682 };
683
684 struct ImportHeader {
685 uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0).
686 uint16_t Sig2; ///< Must be 0xFFFF.
687 uint16_t Version;
688 uint16_t Machine;
689 uint32_t TimeDateStamp;
690 uint32_t SizeOfData;
691 uint16_t OrdinalHint;
692 uint16_t TypeInfo;
693
694 ImportType getType() const { return static_cast(TypeInfo & 0x3); }
695
696 ImportNameType getNameType() const {
697 return static_cast((TypeInfo & 0x1C) >> 2);
698 }
699 };
700
701 enum CodeViewIdentifiers {
702 DEBUG_SECTION_MAGIC = 0x4,
703 };
704
705 inline bool isReservedSectionNumber(int32_t SectionNumber) {
706 return SectionNumber <= 0;
707 }
708
709 } // End namespace COFF.
710 } // End namespace llvm.
711
712 #endif
0 //===- llvm/Support/Dwarf.def - Dwarf definitions ---------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Macros for running through Dwarf enumerators.
10 //
11 //===----------------------------------------------------------------------===//
12
13 // TODO: Add other DW-based macros.
14 #if !(defined HANDLE_DW_TAG || defined HANDLE_DW_AT || \
15 defined HANDLE_DW_FORM || defined HANDLE_DW_OP || \
16 defined HANDLE_DW_LANG || defined HANDLE_DW_ATE || \
17 defined HANDLE_DW_VIRTUALITY || defined HANDLE_DW_DEFAULTED || \
18 defined HANDLE_DW_CC || defined HANDLE_DW_LNS || \
19 defined HANDLE_DW_LNE || defined HANDLE_DW_LNCT || \
20 defined HANDLE_DW_MACRO || defined HANDLE_DW_RLE || \
21 defined HANDLE_DW_CFA || defined HANDLE_DW_APPLE_PROPERTY || \
22 defined HANDLE_DW_UT)
23 #error "Missing macro definition of HANDLE_DW*"
24 #endif
25
26 #ifndef HANDLE_DW_TAG
27 #define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR)
28 #endif
29
30 #ifndef HANDLE_DW_AT
31 #define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR)
32 #endif
33
34 #ifndef HANDLE_DW_FORM
35 #define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR)
36 #endif
37
38 #ifndef HANDLE_DW_OP
39 #define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR)
40 #endif
41
42 #ifndef HANDLE_DW_LANG
43 #define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR)
44 #endif
45
46 #ifndef HANDLE_DW_ATE
47 #define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR)
48 #endif
49
50 #ifndef HANDLE_DW_VIRTUALITY
51 #define HANDLE_DW_VIRTUALITY(ID, NAME)
52 #endif
53
54 #ifndef HANDLE_DW_DEFAULTED
55 #define HANDLE_DW_DEFAULTED(ID, NAME)
56 #endif
57
58 #ifndef HANDLE_DW_CC
59 #define HANDLE_DW_CC(ID, NAME)
60 #endif
61
62 #ifndef HANDLE_DW_LNS
63 #define HANDLE_DW_LNS(ID, NAME)
64 #endif
65
66 #ifndef HANDLE_DW_LNE
67 #define HANDLE_DW_LNE(ID, NAME)
68 #endif
69
70 #ifndef HANDLE_DW_LNCT
71 #define HANDLE_DW_LNCT(ID, NAME)
72 #endif
73
74 #ifndef HANDLE_DW_MACRO
75 #define HANDLE_DW_MACRO(ID, NAME)
76 #endif
77
78 #ifndef HANDLE_DW_RLE
79 #define HANDLE_DW_RLE(ID, NAME)
80 #endif
81
82 #ifndef HANDLE_DW_CFA
83 #define HANDLE_DW_CFA(ID, NAME)
84 #endif
85
86 #ifndef HANDLE_DW_APPLE_PROPERTY
87 #define HANDLE_DW_APPLE_PROPERTY(ID, NAME)
88 #endif
89
90 #ifndef HANDLE_DW_UT
91 #define HANDLE_DW_UT(ID, NAME)
92 #endif
93
94 HANDLE_DW_TAG(0x0000, null, 2, DWARF)
95 HANDLE_DW_TAG(0x0001, array_type, 2, DWARF)
96 HANDLE_DW_TAG(0x0002, class_type, 2, DWARF)
97 HANDLE_DW_TAG(0x0003, entry_point, 2, DWARF)
98 HANDLE_DW_TAG(0x0004, enumeration_type, 2, DWARF)
99 HANDLE_DW_TAG(0x0005, formal_parameter, 2, DWARF)
100 HANDLE_DW_TAG(0x0008, imported_declaration, 2, DWARF)
101 HANDLE_DW_TAG(0x000a, label, 2, DWARF)
102 HANDLE_DW_TAG(0x000b, lexical_block, 2, DWARF)
103 HANDLE_DW_TAG(0x000d, member, 2, DWARF)
104 HANDLE_DW_TAG(0x000f, pointer_type, 2, DWARF)
105 HANDLE_DW_TAG(0x0010, reference_type, 2, DWARF)
106 HANDLE_DW_TAG(0x0011, compile_unit, 2, DWARF)
107 HANDLE_DW_TAG(0x0012, string_type, 2, DWARF)
108 HANDLE_DW_TAG(0x0013, structure_type, 2, DWARF)
109 HANDLE_DW_TAG(0x0015, subroutine_type, 2, DWARF)
110 HANDLE_DW_TAG(0x0016, typedef, 2, DWARF)
111 HANDLE_DW_TAG(0x0017, union_type, 2, DWARF)
112 HANDLE_DW_TAG(0x0018, unspecified_parameters, 2, DWARF)
113 HANDLE_DW_TAG(0x0019, variant, 2, DWARF)
114 HANDLE_DW_TAG(0x001a, common_block, 2, DWARF)
115 HANDLE_DW_TAG(0x001b, common_inclusion, 2, DWARF)
116 HANDLE_DW_TAG(0x001c, inheritance, 2, DWARF)
117 HANDLE_DW_TAG(0x001d, inlined_subroutine, 2, DWARF)
118 HANDLE_DW_TAG(0x001e, module, 2, DWARF)
119 HANDLE_DW_TAG(0x001f, ptr_to_member_type, 2, DWARF)
120 HANDLE_DW_TAG(0x0020, set_type, 2, DWARF)
121 HANDLE_DW_TAG(0x0021, subrange_type, 2, DWARF)
122 HANDLE_DW_TAG(0x0022, with_stmt, 2, DWARF)
123 HANDLE_DW_TAG(0x0023, access_declaration, 2, DWARF)
124 HANDLE_DW_TAG(0x0024, base_type, 2, DWARF)
125 HANDLE_DW_TAG(0x0025, catch_block, 2, DWARF)
126 HANDLE_DW_TAG(0x0026, const_type, 2, DWARF)
127 HANDLE_DW_TAG(0x0027, constant, 2, DWARF)
128 HANDLE_DW_TAG(0x0028, enumerator, 2, DWARF)
129 HANDLE_DW_TAG(0x0029, file_type, 2, DWARF)
130 HANDLE_DW_TAG(0x002a, friend, 2, DWARF)
131 HANDLE_DW_TAG(0x002b, namelist, 2, DWARF)
132 HANDLE_DW_TAG(0x002c, namelist_item, 2, DWARF)
133 HANDLE_DW_TAG(0x002d, packed_type, 2, DWARF)
134 HANDLE_DW_TAG(0x002e, subprogram, 2, DWARF)
135 HANDLE_DW_TAG(0x002f, template_type_parameter, 2, DWARF)
136 HANDLE_DW_TAG(0x0030, template_value_parameter, 2, DWARF)
137 HANDLE_DW_TAG(0x0031, thrown_type, 2, DWARF)
138 HANDLE_DW_TAG(0x0032, try_block, 2, DWARF)
139 HANDLE_DW_TAG(0x0033, variant_part, 2, DWARF)
140 HANDLE_DW_TAG(0x0034, variable, 2, DWARF)
141 HANDLE_DW_TAG(0x0035, volatile_type, 2, DWARF)
142 // New in DWARF v3:
143 HANDLE_DW_TAG(0x0036, dwarf_procedure, 3, DWARF)
144 HANDLE_DW_TAG(0x0037, restrict_type, 3, DWARF)
145 HANDLE_DW_TAG(0x0038, interface_type, 3, DWARF)
146 HANDLE_DW_TAG(0x0039, namespace, 3, DWARF)
147 HANDLE_DW_TAG(0x003a, imported_module, 3, DWARF)
148 HANDLE_DW_TAG(0x003b, unspecified_type, 3, DWARF)
149 HANDLE_DW_TAG(0x003c, partial_unit, 3, DWARF)
150 HANDLE_DW_TAG(0x003d, imported_unit, 3, DWARF)
151 HANDLE_DW_TAG(0x003f, condition, 3, DWARF)
152 HANDLE_DW_TAG(0x0040, shared_type, 3, DWARF)
153 // New in DWARF v4:
154 HANDLE_DW_TAG(0x0041, type_unit, 4, DWARF)
155 HANDLE_DW_TAG(0x0042, rvalue_reference_type, 4, DWARF)
156 HANDLE_DW_TAG(0x0043, template_alias, 4, DWARF)
157 // New in DWARF v5:
158 HANDLE_DW_TAG(0x0044, coarray_type, 5, DWARF)
159 HANDLE_DW_TAG(0x0045, generic_subrange, 5, DWARF)
160 HANDLE_DW_TAG(0x0046, dynamic_type, 5, DWARF)
161 HANDLE_DW_TAG(0x0047, atomic_type, 5, DWARF)
162 HANDLE_DW_TAG(0x0048, call_site, 5, DWARF)
163 HANDLE_DW_TAG(0x0049, call_site_parameter, 5, DWARF)
164 HANDLE_DW_TAG(0x004a, skeleton_unit, 5, DWARF)
165 HANDLE_DW_TAG(0x004b, immutable_type, 5, DWARF)
166 // Vendor extensions:
167 HANDLE_DW_TAG(0x4081, MIPS_loop, 0, MIPS)
168 HANDLE_DW_TAG(0x4101, format_label, 0, GNU)
169 HANDLE_DW_TAG(0x4102, function_template, 0, GNU)
170 HANDLE_DW_TAG(0x4103, class_template, 0, GNU)
171 HANDLE_DW_TAG(0x4106, GNU_template_template_param, 0, GNU)
172 HANDLE_DW_TAG(0x4107, GNU_template_parameter_pack, 0, GNU)
173 HANDLE_DW_TAG(0x4108, GNU_formal_parameter_pack, 0, GNU)
174 HANDLE_DW_TAG(0x4200, APPLE_property, 0, APPLE)
175 HANDLE_DW_TAG(0xb000, BORLAND_property, 0, BORLAND)
176 HANDLE_DW_TAG(0xb001, BORLAND_Delphi_string, 0, BORLAND)
177 HANDLE_DW_TAG(0xb002, BORLAND_Delphi_dynamic_array, 0, BORLAND)
178 HANDLE_DW_TAG(0xb003, BORLAND_Delphi_set, 0, BORLAND)
179 HANDLE_DW_TAG(0xb004, BORLAND_Delphi_variant, 0, BORLAND)
180
181 // Attributes.
182 HANDLE_DW_AT(0x01, sibling, 2, DWARF)
183 HANDLE_DW_AT(0x02, location, 2, DWARF)
184 HANDLE_DW_AT(0x03, name, 2, DWARF)
185 HANDLE_DW_AT(0x09, ordering, 2, DWARF)
186 HANDLE_DW_AT(0x0b, byte_size, 2, DWARF)
187 HANDLE_DW_AT(0x0c, bit_offset, 2, DWARF)
188 HANDLE_DW_AT(0x0d, bit_size, 2, DWARF)
189 HANDLE_DW_AT(0x10, stmt_list, 2, DWARF)
190 HANDLE_DW_AT(0x11, low_pc, 2, DWARF)
191 HANDLE_DW_AT(0x12, high_pc, 2, DWARF)
192 HANDLE_DW_AT(0x13, language, 2, DWARF)
193 HANDLE_DW_AT(0x15, discr, 2, DWARF)
194 HANDLE_DW_AT(0x16, discr_value, 2, DWARF)
195 HANDLE_DW_AT(0x17, visibility, 2, DWARF)
196 HANDLE_DW_AT(0x18, import, 2, DWARF)
197 HANDLE_DW_AT(0x19, string_length, 2, DWARF)
198 HANDLE_DW_AT(0x1a, common_reference, 2, DWARF)
199 HANDLE_DW_AT(0x1b, comp_dir, 2, DWARF)
200 HANDLE_DW_AT(0x1c, const_value, 2, DWARF)
201 HANDLE_DW_AT(0x1d, containing_type, 2, DWARF)
202 HANDLE_DW_AT(0x1e, default_value, 2, DWARF)
203 HANDLE_DW_AT(0x20, inline, 2, DWARF)
204 HANDLE_DW_AT(0x21, is_optional, 2, DWARF)
205 HANDLE_DW_AT(0x22, lower_bound, 2, DWARF)
206 HANDLE_DW_AT(0x25, producer, 2, DWARF)
207 HANDLE_DW_AT(0x27, prototyped, 2, DWARF)
208 HANDLE_DW_AT(0x2a, return_addr, 2, DWARF)
209 HANDLE_DW_AT(0x2c, start_scope, 2, DWARF)
210 HANDLE_DW_AT(0x2e, bit_stride, 2, DWARF)
211 HANDLE_DW_AT(0x2f, upper_bound, 2, DWARF)
212 HANDLE_DW_AT(0x31, abstract_origin, 2, DWARF)
213 HANDLE_DW_AT(0x32, accessibility, 2, DWARF)
214 HANDLE_DW_AT(0x33, address_class, 2, DWARF)
215 HANDLE_DW_AT(0x34, artificial, 2, DWARF)
216 HANDLE_DW_AT(0x35, base_types, 2, DWARF)
217 HANDLE_DW_AT(0x36, calling_convention, 2, DWARF)
218 HANDLE_DW_AT(0x37, count, 2, DWARF)
219 HANDLE_DW_AT(0x38, data_member_location, 2, DWARF)
220 HANDLE_DW_AT(0x39, decl_column, 2, DWARF)
221 HANDLE_DW_AT(0x3a, decl_file, 2, DWARF)
222 HANDLE_DW_AT(0x3b, decl_line, 2, DWARF)
223 HANDLE_DW_AT(0x3c, declaration, 2, DWARF)
224 HANDLE_DW_AT(0x3d, discr_list, 2, DWARF)
225 HANDLE_DW_AT(0x3e, encoding, 2, DWARF)
226 HANDLE_DW_AT(0x3f, external, 2, DWARF)
227 HANDLE_DW_AT(0x40, frame_base, 2, DWARF)
228 HANDLE_DW_AT(0x41, friend, 2, DWARF)
229 HANDLE_DW_AT(0x42, identifier_case, 2, DWARF)
230 HANDLE_DW_AT(0x43, macro_info, 2, DWARF)
231 HANDLE_DW_AT(0x44, namelist_item, 2, DWARF)
232 HANDLE_DW_AT(0x45, priority, 2, DWARF)
233 HANDLE_DW_AT(0x46, segment, 2, DWARF)
234 HANDLE_DW_AT(0x47, specification, 2, DWARF)
235 HANDLE_DW_AT(0x48, static_link, 2, DWARF)
236 HANDLE_DW_AT(0x49, type, 2, DWARF)
237 HANDLE_DW_AT(0x4a, use_location, 2, DWARF)
238 HANDLE_DW_AT(0x4b, variable_parameter, 2, DWARF)
239 HANDLE_DW_AT(0x4c, virtuality, 2, DWARF)
240 HANDLE_DW_AT(0x4d, vtable_elem_location, 2, DWARF)
241 // New in DWARF v3:
242 HANDLE_DW_AT(0x4e, allocated, 3, DWARF)
243 HANDLE_DW_AT(0x4f, associated, 3, DWARF)
244 HANDLE_DW_AT(0x50, data_location, 3, DWARF)
245 HANDLE_DW_AT(0x51, byte_stride, 3, DWARF)
246 HANDLE_DW_AT(0x52, entry_pc, 3, DWARF)
247 HANDLE_DW_AT(0x53, use_UTF8, 3, DWARF)
248 HANDLE_DW_AT(0x54, extension, 3, DWARF)
249 HANDLE_DW_AT(0x55, ranges, 3, DWARF)
250 HANDLE_DW_AT(0x56, trampoline, 3, DWARF)
251 HANDLE_DW_AT(0x57, call_column, 3, DWARF)
252 HANDLE_DW_AT(0x58, call_file, 3, DWARF)
253 HANDLE_DW_AT(0x59, call_line, 3, DWARF)
254 HANDLE_DW_AT(0x5a, description, 3, DWARF)
255 HANDLE_DW_AT(0x5b, binary_scale, 3, DWARF)
256 HANDLE_DW_AT(0x5c, decimal_scale, 3, DWARF)
257 HANDLE_DW_AT(0x5d, small, 3, DWARF)
258 HANDLE_DW_AT(0x5e, decimal_sign, 3, DWARF)
259 HANDLE_DW_AT(0x5f, digit_count, 3, DWARF)
260 HANDLE_DW_AT(0x60, picture_string, 3, DWARF)
261 HANDLE_DW_AT(0x61, mutable, 3, DWARF)
262 HANDLE_DW_AT(0x62, threads_scaled, 3, DWARF)
263 HANDLE_DW_AT(0x63, explicit, 3, DWARF)
264 HANDLE_DW_AT(0x64, object_pointer, 3, DWARF)
265 HANDLE_DW_AT(0x65, endianity, 3, DWARF)
266 HANDLE_DW_AT(0x66, elemental, 3, DWARF)
267 HANDLE_DW_AT(0x67, pure, 3, DWARF)
268 HANDLE_DW_AT(0x68, recursive, 3, DWARF)
269 // New in DWARF v4:
270 HANDLE_DW_AT(0x69, signature, 4, DWARF)
271 HANDLE_DW_AT(0x6a, main_subprogram, 4, DWARF)
272 HANDLE_DW_AT(0x6b, data_bit_offset, 4, DWARF)
273 HANDLE_DW_AT(0x6c, const_expr, 4, DWARF)
274 HANDLE_DW_AT(0x6d, enum_class, 4, DWARF)
275 HANDLE_DW_AT(0x6e, linkage_name, 4, DWARF)
276 // New in DWARF v5:
277 HANDLE_DW_AT(0x6f, string_length_bit_size, 5, DWARF)
278 HANDLE_DW_AT(0x70, string_length_byte_size, 5, DWARF)
279 HANDLE_DW_AT(0x71, rank, 5, DWARF)
280 HANDLE_DW_AT(0x72, str_offsets_base, 5, DWARF)
281 HANDLE_DW_AT(0x73, addr_base, 5, DWARF)
282 HANDLE_DW_AT(0x74, rnglists_base, 5, DWARF)
283 HANDLE_DW_AT(0x75, dwo_id, 0, DWARF) ///< Retracted from DWARF v5.
284 HANDLE_DW_AT(0x76, dwo_name, 5, DWARF)
285 HANDLE_DW_AT(0x77, reference, 5, DWARF)
286 HANDLE_DW_AT(0x78, rvalue_reference, 5, DWARF)
287 HANDLE_DW_AT(0x79, macros, 5, DWARF)
288 HANDLE_DW_AT(0x7a, call_all_calls, 5, DWARF)
289 HANDLE_DW_AT(0x7b, call_all_source_calls, 5, DWARF)
290 HANDLE_DW_AT(0x7c, call_all_tail_calls, 5, DWARF)
291 HANDLE_DW_AT(0x7d, call_return_pc, 5, DWARF)
292 HANDLE_DW_AT(0x7e, call_value, 5, DWARF)
293 HANDLE_DW_AT(0x7f, call_origin, 5, DWARF)
294 HANDLE_DW_AT(0x80, call_parameter, 5, DWARF)
295 HANDLE_DW_AT(0x81, call_pc, 5, DWARF)
296 HANDLE_DW_AT(0x82, call_tail_call, 5, DWARF)
297 HANDLE_DW_AT(0x83, call_target, 5, DWARF)
298 HANDLE_DW_AT(0x84, call_target_clobbered, 5, DWARF)
299 HANDLE_DW_AT(0x85, call_data_location, 5, DWARF)
300 HANDLE_DW_AT(0x86, call_data_value, 5, DWARF)
301 HANDLE_DW_AT(0x87, noreturn, 5, DWARF)
302 HANDLE_DW_AT(0x88, alignment, 5, DWARF)
303 HANDLE_DW_AT(0x89, export_symbols, 5, DWARF)
304 HANDLE_DW_AT(0x8a, deleted, 5, DWARF)
305 HANDLE_DW_AT(0x8b, defaulted, 5, DWARF)
306 HANDLE_DW_AT(0x8c, loclists_base, 5, DWARF)
307 // Vendor extensions:
308 HANDLE_DW_AT(0x2002, MIPS_loop_begin, 0, MIPS)
309 HANDLE_DW_AT(0x2003, MIPS_tail_loop_begin, 0, MIPS)
310 HANDLE_DW_AT(0x2004, MIPS_epilog_begin, 0, MIPS)
311 HANDLE_DW_AT(0x2005, MIPS_loop_unroll_factor, 0, MIPS)
312 HANDLE_DW_AT(0x2006, MIPS_software_pipeline_depth, 0, MIPS)
313 HANDLE_DW_AT(0x2007, MIPS_linkage_name, 0, MIPS)
314 HANDLE_DW_AT(0x2008, MIPS_stride, 0, MIPS)
315 HANDLE_DW_AT(0x2009, MIPS_abstract_name, 0, MIPS)
316 HANDLE_DW_AT(0x200a, MIPS_clone_origin, 0, MIPS)
317 HANDLE_DW_AT(0x200b, MIPS_has_inlines, 0, MIPS)
318 HANDLE_DW_AT(0x200c, MIPS_stride_byte, 0, MIPS)
319 HANDLE_DW_AT(0x200d, MIPS_stride_elem, 0, MIPS)
320 HANDLE_DW_AT(0x200e, MIPS_ptr_dopetype, 0, MIPS)
321 HANDLE_DW_AT(0x200f, MIPS_allocatable_dopetype, 0, MIPS)
322 HANDLE_DW_AT(0x2010, MIPS_assumed_shape_dopetype, 0, MIPS)
323 // This one appears to have only been implemented by Open64 for
324 // fortran and may conflict with other extensions.
325 HANDLE_DW_AT(0x2011, MIPS_assumed_size, 0, MIPS)
326 // GNU extensions
327 HANDLE_DW_AT(0x2101, sf_names, 0, GNU)
328 HANDLE_DW_AT(0x2102, src_info, 0, GNU)
329 HANDLE_DW_AT(0x2103, mac_info, 0, GNU)
330 HANDLE_DW_AT(0x2104, src_coords, 0, GNU)
331 HANDLE_DW_AT(0x2105, body_begin, 0, GNU)
332 HANDLE_DW_AT(0x2106, body_end, 0, GNU)
333 HANDLE_DW_AT(0x2107, GNU_vector, 0, GNU)
334 HANDLE_DW_AT(0x2110, GNU_template_name, 0, GNU)
335 HANDLE_DW_AT(0x210f, GNU_odr_signature, 0, GNU)
336 HANDLE_DW_AT(0x2119, GNU_macros, 0, GNU)
337 // Extensions for Fission proposal.
338 HANDLE_DW_AT(0x2130, GNU_dwo_name, 0, GNU)
339 HANDLE_DW_AT(0x2131, GNU_dwo_id, 0, GNU)
340 HANDLE_DW_AT(0x2132, GNU_ranges_base, 0, GNU)
341 HANDLE_DW_AT(0x2133, GNU_addr_base, 0, GNU)
342 HANDLE_DW_AT(0x2134, GNU_pubnames, 0, GNU)
343 HANDLE_DW_AT(0x2135, GNU_pubtypes, 0, GNU)
344 HANDLE_DW_AT(0x2136, GNU_discriminator, 0, GNU)
345 // Borland extensions.
346 HANDLE_DW_AT(0x3b11, BORLAND_property_read, 0, BORLAND)
347 HANDLE_DW_AT(0x3b12, BORLAND_property_write, 0, BORLAND)
348 HANDLE_DW_AT(0x3b13, BORLAND_property_implements, 0, BORLAND)
349 HANDLE_DW_AT(0x3b14, BORLAND_property_index, 0, BORLAND)
350 HANDLE_DW_AT(0x3b15, BORLAND_property_default, 0, BORLAND)
351 HANDLE_DW_AT(0x3b20, BORLAND_Delphi_unit, 0, BORLAND)
352 HANDLE_DW_AT(0x3b21, BORLAND_Delphi_class, 0, BORLAND)
353 HANDLE_DW_AT(0x3b22, BORLAND_Delphi_record, 0, BORLAND)
354 HANDLE_DW_AT(0x3b23, BORLAND_Delphi_metaclass, 0, BORLAND)
355 HANDLE_DW_AT(0x3b24, BORLAND_Delphi_constructor, 0, BORLAND)
356 HANDLE_DW_AT(0x3b25, BORLAND_Delphi_destructor, 0, BORLAND)
357 HANDLE_DW_AT(0x3b26, BORLAND_Delphi_anonymous_method, 0, BORLAND)
358 HANDLE_DW_AT(0x3b27, BORLAND_Delphi_interface, 0, BORLAND)
359 HANDLE_DW_AT(0x3b28, BORLAND_Delphi_ABI, 0, BORLAND)
360 HANDLE_DW_AT(0x3b29, BORLAND_Delphi_return, 0, BORLAND)
361 HANDLE_DW_AT(0x3b30, BORLAND_Delphi_frameptr, 0, BORLAND)
362 HANDLE_DW_AT(0x3b31, BORLAND_closure, 0, BORLAND)
363 // LLVM project extensions.
364 HANDLE_DW_AT(0x3e00, LLVM_include_path, 0, LLVM)
365 HANDLE_DW_AT(0x3e01, LLVM_config_macros, 0, LLVM)
366 HANDLE_DW_AT(0x3e02, LLVM_isysroot, 0, LLVM)
367 // Apple extensions.
368 HANDLE_DW_AT(0x3fe1, APPLE_optimized, 0, APPLE)
369 HANDLE_DW_AT(0x3fe2, APPLE_flags, 0, APPLE)
370 HANDLE_DW_AT(0x3fe3, APPLE_isa, 0, APPLE)
371 HANDLE_DW_AT(0x3fe4, APPLE_block, 0, APPLE)
372 HANDLE_DW_AT(0x3fe5, APPLE_major_runtime_vers, 0, APPLE)
373 HANDLE_DW_AT(0x3fe6, APPLE_runtime_class, 0, APPLE)
374 HANDLE_DW_AT(0x3fe7, APPLE_omit_frame_ptr, 0, APPLE)
375 HANDLE_DW_AT(0x3fe8, APPLE_property_name, 0, APPLE)
376 HANDLE_DW_AT(0x3fe9, APPLE_property_getter, 0, APPLE)
377 HANDLE_DW_AT(0x3fea, APPLE_property_setter, 0, APPLE)
378 HANDLE_DW_AT(0x3feb, APPLE_property_attribute, 0, APPLE)
379 HANDLE_DW_AT(0x3fec, APPLE_objc_complete_type, 0, APPLE)
380 HANDLE_DW_AT(0x3fed, APPLE_property, 0, APPLE)
381
382 // Attribute form encodings.
383 HANDLE_DW_FORM(0x01, addr, 2, DWARF)
384 HANDLE_DW_FORM(0x03, block2, 2, DWARF)
385 HANDLE_DW_FORM(0x04, block4, 2, DWARF)
386 HANDLE_DW_FORM(0x05, data2, 2, DWARF)
387 HANDLE_DW_FORM(0x06, data4, 2, DWARF)
388 HANDLE_DW_FORM(0x07, data8, 2, DWARF)
389 HANDLE_DW_FORM(0x08, string, 2, DWARF)
390 HANDLE_DW_FORM(0x09, block, 2, DWARF)
391 HANDLE_DW_FORM(0x0a, block1, 2, DWARF)
392 HANDLE_DW_FORM(0x0b, data1, 2, DWARF)
393 HANDLE_DW_FORM(0x0c, flag, 2, DWARF)
394 HANDLE_DW_FORM(0x0d, sdata, 2, DWARF)
395 HANDLE_DW_FORM(0x0e, strp, 2, DWARF)
396 HANDLE_DW_FORM(0x0f, udata, 2, DWARF)
397 HANDLE_DW_FORM(0x10, ref_addr, 2, DWARF)
398 HANDLE_DW_FORM(0x11, ref1, 2, DWARF)
399 HANDLE_DW_FORM(0x12, ref2, 2, DWARF)
400 HANDLE_DW_FORM(0x13, ref4, 2, DWARF)
401 HANDLE_DW_FORM(0x14, ref8, 2, DWARF)
402 HANDLE_DW_FORM(0x15, ref_udata, 2, DWARF)
403 HANDLE_DW_FORM(0x16, indirect, 2, DWARF)
404 // New in DWARF v4:
405 HANDLE_DW_FORM(0x17, sec_offset, 4, DWARF)
406 HANDLE_DW_FORM(0x18, exprloc, 4, DWARF)
407 HANDLE_DW_FORM(0x19, flag_present, 4, DWARF)
408 // This was defined out of sequence.
409 HANDLE_DW_FORM(0x20, ref_sig8, 4, DWARF)
410 // New in DWARF v5:
411 HANDLE_DW_FORM(0x1a, strx, 5, DWARF)
412 HANDLE_DW_FORM(0x1b, addrx, 5, DWARF)
413 HANDLE_DW_FORM(0x1c, ref_sup4, 5, DWARF)
414 HANDLE_DW_FORM(0x1d, strp_sup, 5, DWARF)
415 HANDLE_DW_FORM(0x1e, data16, 5, DWARF)
416 HANDLE_DW_FORM(0x1f, line_strp, 5, DWARF)
417 HANDLE_DW_FORM(0x21, implicit_const, 5, DWARF)
418 HANDLE_DW_FORM(0x22, loclistx, 5, DWARF)
419 HANDLE_DW_FORM(0x23, rnglistx, 5, DWARF)
420 HANDLE_DW_FORM(0x24, ref_sup8, 5, DWARF)
421 HANDLE_DW_FORM(0x25, strx1, 5, DWARF)
422 HANDLE_DW_FORM(0x26, strx2, 5, DWARF)
423 HANDLE_DW_FORM(0x27, strx3, 5, DWARF)
424 HANDLE_DW_FORM(0x28, strx4, 5, DWARF)
425 HANDLE_DW_FORM(0x29, addrx1, 5, DWARF)
426 HANDLE_DW_FORM(0x2a, addrx2, 5, DWARF)
427 HANDLE_DW_FORM(0x2b, addrx3, 5, DWARF)
428 HANDLE_DW_FORM(0x2c, addrx4, 5, DWARF)
429 // Extensions for Fission proposal
430 HANDLE_DW_FORM(0x1f01, GNU_addr_index, 0, GNU)
431 HANDLE_DW_FORM(0x1f02, GNU_str_index, 0, GNU)
432 // Alternate debug sections proposal (output of "dwz" tool).
433 HANDLE_DW_FORM(0x1f20, GNU_ref_alt, 0, GNU)
434 HANDLE_DW_FORM(0x1f21, GNU_strp_alt, 0, GNU)
435
436 // DWARF Expression operators.
437 HANDLE_DW_OP(0x03, addr, 2, DWARF)
438 HANDLE_DW_OP(0x06, deref, 2, DWARF)
439 HANDLE_DW_OP(0x08, const1u, 2, DWARF)
440 HANDLE_DW_OP(0x09, const1s, 2, DWARF)
441 HANDLE_DW_OP(0x0a, const2u, 2, DWARF)
442 HANDLE_DW_OP(0x0b, const2s, 2, DWARF)
443 HANDLE_DW_OP(0x0c, const4u, 2, DWARF)
444 HANDLE_DW_OP(0x0d, const4s, 2, DWARF)
445 HANDLE_DW_OP(0x0e, const8u, 2, DWARF)
446 HANDLE_DW_OP(0x0f, const8s, 2, DWARF)
447 HANDLE_DW_OP(0x10, constu, 2, DWARF)
448 HANDLE_DW_OP(0x11, consts, 2, DWARF)
449 HANDLE_DW_OP(0x12, dup, 2, DWARF)
450 HANDLE_DW_OP(0x13, drop, 2, DWARF)
451 HANDLE_DW_OP(0x14, over, 2, DWARF)
452 HANDLE_DW_OP(0x15, pick, 2, DWARF)
453 HANDLE_DW_OP(0x16, swap, 2, DWARF)
454 HANDLE_DW_OP(0x17, rot, 2, DWARF)
455 HANDLE_DW_OP(0x18, xderef, 2, DWARF)
456 HANDLE_DW_OP(0x19, abs, 2, DWARF)
457 HANDLE_DW_OP(0x1a, and, 2, DWARF)
458 HANDLE_DW_OP(0x1b, div, 2, DWARF)
459 HANDLE_DW_OP(0x1c, minus, 2, DWARF)
460 HANDLE_DW_OP(0x1d, mod, 2, DWARF)
461 HANDLE_DW_OP(0x1e, mul, 2, DWARF)
462 HANDLE_DW_OP(0x1f, neg, 2, DWARF)
463 HANDLE_DW_OP(0x20, not, 2, DWARF)
464 HANDLE_DW_OP(0x21, or, 2, DWARF)
465 HANDLE_DW_OP(0x22, plus, 2, DWARF)
466 HANDLE_DW_OP(0x23, plus_uconst, 2, DWARF)
467 HANDLE_DW_OP(0x24, shl, 2, DWARF)
468 HANDLE_DW_OP(0x25, shr, 2, DWARF)
469 HANDLE_DW_OP(0x26, shra, 2, DWARF)
470 HANDLE_DW_OP(0x27, xor, 2, DWARF)
471 HANDLE_DW_OP(0x28, bra, 2, DWARF)
472 HANDLE_DW_OP(0x29, eq, 2, DWARF)
473 HANDLE_DW_OP(0x2a, ge, 2, DWARF)
474 HANDLE_DW_OP(0x2b, gt, 2, DWARF)
475 HANDLE_DW_OP(0x2c, le, 2, DWARF)
476 HANDLE_DW_OP(0x2d, lt, 2, DWARF)
477 HANDLE_DW_OP(0x2e, ne, 2, DWARF)
478 HANDLE_DW_OP(0x2f, skip, 2, DWARF)
479 HANDLE_DW_OP(0x30, lit0, 2, DWARF)
480 HANDLE_DW_OP(0x31, lit1, 2, DWARF)
481 HANDLE_DW_OP(0x32, lit2, 2, DWARF)
482 HANDLE_DW_OP(0x33, lit3, 2, DWARF)
483 HANDLE_DW_OP(0x34, lit4, 2, DWARF)
484 HANDLE_DW_OP(0x35, lit5, 2, DWARF)
485 HANDLE_DW_OP(0x36, lit6, 2, DWARF)
486 HANDLE_DW_OP(0x37, lit7, 2, DWARF)
487 HANDLE_DW_OP(0x38, lit8, 2, DWARF)
488 HANDLE_DW_OP(0x39, lit9, 2, DWARF)
489 HANDLE_DW_OP(0x3a, lit10, 2, DWARF)
490 HANDLE_DW_OP(0x3b, lit11, 2, DWARF)
491 HANDLE_DW_OP(0x3c, lit12, 2, DWARF)
492 HANDLE_DW_OP(0x3d, lit13, 2, DWARF)
493 HANDLE_DW_OP(0x3e, lit14, 2, DWARF)
494 HANDLE_DW_OP(0x3f, lit15, 2, DWARF)
495 HANDLE_DW_OP(0x40, lit16, 2, DWARF)
496 HANDLE_DW_OP(0x41, lit17, 2, DWARF)
497 HANDLE_DW_OP(0x42, lit18, 2, DWARF)
498 HANDLE_DW_OP(0x43, lit19, 2, DWARF)
499 HANDLE_DW_OP(0x44, lit20, 2, DWARF)
500 HANDLE_DW_OP(0x45, lit21, 2, DWARF)
501 HANDLE_DW_OP(0x46, lit22, 2, DWARF)
502 HANDLE_DW_OP(0x47, lit23, 2, DWARF)
503 HANDLE_DW_OP(0x48, lit24, 2, DWARF)
504 HANDLE_DW_OP(0x49, lit25, 2, DWARF)
505 HANDLE_DW_OP(0x4a, lit26, 2, DWARF)
506 HANDLE_DW_OP(0x4b, lit27, 2, DWARF)
507 HANDLE_DW_OP(0x4c, lit28, 2, DWARF)
508 HANDLE_DW_OP(0x4d, lit29, 2, DWARF)
509 HANDLE_DW_OP(0x4e, lit30, 2, DWARF)
510 HANDLE_DW_OP(0x4f, lit31, 2, DWARF)
511 HANDLE_DW_OP(0x50, reg0, 2, DWARF)
512 HANDLE_DW_OP(0x51, reg1, 2, DWARF)
513 HANDLE_DW_OP(0x52, reg2, 2, DWARF)
514 HANDLE_DW_OP(0x53, reg3, 2, DWARF)
515 HANDLE_DW_OP(0x54, reg4, 2, DWARF)
516 HANDLE_DW_OP(0x55, reg5, 2, DWARF)
517 HANDLE_DW_OP(0x56, reg6, 2, DWARF)
518 HANDLE_DW_OP(0x57, reg7, 2, DWARF)
519 HANDLE_DW_OP(0x58, reg8, 2, DWARF)
520 HANDLE_DW_OP(0x59, reg9, 2, DWARF)
521 HANDLE_DW_OP(0x5a, reg10, 2, DWARF)
522 HANDLE_DW_OP(0x5b, reg11, 2, DWARF)
523 HANDLE_DW_OP(0x5c, reg12, 2, DWARF)
524 HANDLE_DW_OP(0x5d, reg13, 2, DWARF)
525 HANDLE_DW_OP(0x5e, reg14, 2, DWARF)
526 HANDLE_DW_OP(0x5f, reg15, 2, DWARF)
527 HANDLE_DW_OP(0x60, reg16, 2, DWARF)
528 HANDLE_DW_OP(0x61, reg17, 2, DWARF)
529 HANDLE_DW_OP(0x62, reg18, 2, DWARF)
530 HANDLE_DW_OP(0x63, reg19, 2, DWARF)
531 HANDLE_DW_OP(0x64, reg20, 2, DWARF)
532 HANDLE_DW_OP(0x65, reg21, 2, DWARF)
533 HANDLE_DW_OP(0x66, reg22, 2, DWARF)
534 HANDLE_DW_OP(0x67, reg23, 2, DWARF)
535 HANDLE_DW_OP(0x68, reg24, 2, DWARF)
536 HANDLE_DW_OP(0x69, reg25, 2, DWARF)
537 HANDLE_DW_OP(0x6a, reg26, 2, DWARF)
538 HANDLE_DW_OP(0x6b, reg27, 2, DWARF)
539 HANDLE_DW_OP(0x6c, reg28, 2, DWARF)
540 HANDLE_DW_OP(0x6d, reg29, 2, DWARF)
541 HANDLE_DW_OP(0x6e, reg30, 2, DWARF)
542 HANDLE_DW_OP(0x6f, reg31, 2, DWARF)
543 HANDLE_DW_OP(0x70, breg0, 2, DWARF)
544 HANDLE_DW_OP(0x71, breg1, 2, DWARF)
545 HANDLE_DW_OP(0x72, breg2, 2, DWARF)
546 HANDLE_DW_OP(0x73, breg3, 2, DWARF)
547 HANDLE_DW_OP(0x74, breg4, 2, DWARF)
548 HANDLE_DW_OP(0x75, breg5, 2, DWARF)
549 HANDLE_DW_OP(0x76, breg6, 2, DWARF)
550 HANDLE_DW_OP(0x77, breg7, 2, DWARF)
551 HANDLE_DW_OP(0x78, breg8, 2, DWARF)
552 HANDLE_DW_OP(0x79, breg9, 2, DWARF)
553 HANDLE_DW_OP(0x7a, breg10, 2, DWARF)
554 HANDLE_DW_OP(0x7b, breg11, 2, DWARF)
555 HANDLE_DW_OP(0x7c, breg12, 2, DWARF)
556 HANDLE_DW_OP(0x7d, breg13, 2, DWARF)
557 HANDLE_DW_OP(0x7e, breg14, 2, DWARF)
558 HANDLE_DW_OP(0x7f, breg15, 2, DWARF)
559 HANDLE_DW_OP(0x80, breg16, 2, DWARF)
560 HANDLE_DW_OP(0x81, breg17, 2, DWARF)
561 HANDLE_DW_OP(0x82, breg18, 2, DWARF)
562 HANDLE_DW_OP(0x83, breg19, 2, DWARF)
563 HANDLE_DW_OP(0x84, breg20, 2, DWARF)
564 HANDLE_DW_OP(0x85, breg21, 2, DWARF)
565 HANDLE_DW_OP(0x86, breg22, 2, DWARF)
566 HANDLE_DW_OP(0x87, breg23, 2, DWARF)
567 HANDLE_DW_OP(0x88, breg24, 2, DWARF)
568 HANDLE_DW_OP(0x89, breg25, 2, DWARF)
569 HANDLE_DW_OP(0x8a, breg26, 2, DWARF)
570 HANDLE_DW_OP(0x8b, breg27, 2, DWARF)
571 HANDLE_DW_OP(0x8c, breg28, 2, DWARF)
572 HANDLE_DW_OP(0x8d, breg29, 2, DWARF)
573 HANDLE_DW_OP(0x8e, breg30, 2, DWARF)
574 HANDLE_DW_OP(0x8f, breg31, 2, DWARF)
575 HANDLE_DW_OP(0x90, regx, 2, DWARF)
576 HANDLE_DW_OP(0x91, fbreg, 2, DWARF)
577 HANDLE_DW_OP(0x92, bregx, 2, DWARF)
578 HANDLE_DW_OP(0x93, piece, 2, DWARF)
579 HANDLE_DW_OP(0x94, deref_size, 2, DWARF)
580 HANDLE_DW_OP(0x95, xderef_size, 2, DWARF)
581 HANDLE_DW_OP(0x96, nop, 2, DWARF)
582 // New in DWARF v3:
583 HANDLE_DW_OP(0x97, push_object_address, 3, DWARF)
584 HANDLE_DW_OP(0x98, call2, 3, DWARF)
585 HANDLE_DW_OP(0x99, call4, 3, DWARF)
586 HANDLE_DW_OP(0x9a, call_ref, 3, DWARF)
587 HANDLE_DW_OP(0x9b, form_tls_address, 3, DWARF)
588 HANDLE_DW_OP(0x9c, call_frame_cfa, 3, DWARF)
589 HANDLE_DW_OP(0x9d, bit_piece, 3, DWARF)
590 // New in DWARF v4:
591 HANDLE_DW_OP(0x9e, implicit_value, 4, DWARF)
592 HANDLE_DW_OP(0x9f, stack_value, 4, DWARF)
593 // New in DWARF v5:
594 HANDLE_DW_OP(0xa0, implicit_pointer, 5, DWARF)
595 HANDLE_DW_OP(0xa1, addrx, 5, DWARF)
596 HANDLE_DW_OP(0xa2, constx, 5, DWARF)
597 HANDLE_DW_OP(0xa3, entry_value, 5, DWARF)
598 HANDLE_DW_OP(0xa4, const_type, 5, DWARF)
599 HANDLE_DW_OP(0xa5, regval_type, 5, DWARF)
600 HANDLE_DW_OP(0xa6, deref_type, 5, DWARF)
601 HANDLE_DW_OP(0xa7, xderef_type, 5, DWARF)
602 HANDLE_DW_OP(0xa8, convert, 5, DWARF)
603 HANDLE_DW_OP(0xa9, reinterpret, 5, DWARF)
604 // Vendor extensions:
605 // Extensions for GNU-style thread-local storage.
606 HANDLE_DW_OP(0xe0, GNU_push_tls_address, 0, GNU)
607 // Extensions for Fission proposal.
608 HANDLE_DW_OP(0xfb, GNU_addr_index, 0, GNU)
609 HANDLE_DW_OP(0xfc, GNU_const_index, 0, GNU)
610
611 // DWARF languages.
612 HANDLE_DW_LANG(0x0001, C89, 2, DWARF)
613 HANDLE_DW_LANG(0x0002, C, 2, DWARF)
614 HANDLE_DW_LANG(0x0003, Ada83, 2, DWARF)
615 HANDLE_DW_LANG(0x0004, C_plus_plus, 2, DWARF)
616 HANDLE_DW_LANG(0x0005, Cobol74, 2, DWARF)
617 HANDLE_DW_LANG(0x0006, Cobol85, 2, DWARF)
618 HANDLE_DW_LANG(0x0007, Fortran77, 2, DWARF)
619 HANDLE_DW_LANG(0x0008, Fortran90, 2, DWARF)
620 HANDLE_DW_LANG(0x0009, Pascal83, 2, DWARF)
621 HANDLE_DW_LANG(0x000a, Modula2, 2, DWARF)
622 // New in DWARF v3:
623 HANDLE_DW_LANG(0x000b, Java, 3, DWARF)
624 HANDLE_DW_LANG(0x000c, C99, 3, DWARF)
625 HANDLE_DW_LANG(0x000d, Ada95, 3, DWARF)
626 HANDLE_DW_LANG(0x000e, Fortran95, 3, DWARF)
627 HANDLE_DW_LANG(0x000f, PLI, 3, DWARF)
628 HANDLE_DW_LANG(0x0010, ObjC, 3, DWARF)
629 HANDLE_DW_LANG(0x0011, ObjC_plus_plus, 3, DWARF)
630 HANDLE_DW_LANG(0x0012, UPC, 3, DWARF)
631 HANDLE_DW_LANG(0x0013, D, 3, DWARF)
632 // New in DWARF v4:
633 HANDLE_DW_LANG(0x0014, Python, 4, DWARF)
634 // New in DWARF v5:
635 HANDLE_DW_LANG(0x0015, OpenCL, 5, DWARF)
636 HANDLE_DW_LANG(0x0016, Go, 5, DWARF)
637 HANDLE_DW_LANG(0x0017, Modula3, 5, DWARF)
638 HANDLE_DW_LANG(0x0018, Haskell, 5, DWARF)
639 HANDLE_DW_LANG(0x0019, C_plus_plus_03, 5, DWARF)
640 HANDLE_DW_LANG(0x001a, C_plus_plus_11, 5, DWARF)
641 HANDLE_DW_LANG(0x001b, OCaml, 5, DWARF)
642 HANDLE_DW_LANG(0x001c, Rust, 5, DWARF)
643 HANDLE_DW_LANG(0x001d, C11, 5, DWARF)
644 HANDLE_DW_LANG(0x001e, Swift, 5, DWARF)
645 HANDLE_DW_LANG(0x001f, Julia, 5, DWARF)
646 HANDLE_DW_LANG(0x0020, Dylan, 5, DWARF)
647 HANDLE_DW_LANG(0x0021, C_plus_plus_14, 5, DWARF)
648 HANDLE_DW_LANG(0x0022, Fortran03, 5, DWARF)
649 HANDLE_DW_LANG(0x0023, Fortran08, 5, DWARF)
650 HANDLE_DW_LANG(0x0024, RenderScript, 5, DWARF)
651 HANDLE_DW_LANG(0x0025, BLISS, 5, DWARF)
652 // Vendor extensions:
653 HANDLE_DW_LANG(0x8001, Mips_Assembler, 0, MIPS)
654 HANDLE_DW_LANG(0x8e57, GOOGLE_RenderScript, 0, GOOGLE)
655 HANDLE_DW_LANG(0xb000, BORLAND_Delphi, 0, BORLAND)
656
657 // DWARF attribute type encodings.
658 HANDLE_DW_ATE(0x01, address, 2, DWARF)
659 HANDLE_DW_ATE(0x02, boolean, 2, DWARF)
660 HANDLE_DW_ATE(0x03, complex_float, 2, DWARF)
661 HANDLE_DW_ATE(0x04, float, 2, DWARF)
662 HANDLE_DW_ATE(0x05, signed, 2, DWARF)
663 HANDLE_DW_ATE(0x06, signed_char, 2, DWARF)
664 HANDLE_DW_ATE(0x07, unsigned, 2, DWARF)
665 HANDLE_DW_ATE(0x08, unsigned_char, 2, DWARF)
666 // New in DWARF v3:
667 HANDLE_DW_ATE(0x09, imaginary_float, 3, DWARF)
668 HANDLE_DW_ATE(0x0a, packed_decimal, 3, DWARF)
669 HANDLE_DW_ATE(0x0b, numeric_string, 3, DWARF)
670 HANDLE_DW_ATE(0x0c, edited, 3, DWARF)
671 HANDLE_DW_ATE(0x0d, signed_fixed, 3, DWARF)
672 HANDLE_DW_ATE(0x0e, unsigned_fixed, 3, DWARF)
673 HANDLE_DW_ATE(0x0f, decimal_float, 3, DWARF)
674 // New in DWARF v4:
675 HANDLE_DW_ATE(0x10, UTF, 4, DWARF)
676 // New in DWARF v5:
677 HANDLE_DW_ATE(0x11, UCS, 5, DWARF)
678 HANDLE_DW_ATE(0x12, ASCII, 5, DWARF)
679
680 // DWARF virtuality codes.
681 HANDLE_DW_VIRTUALITY(0x00, none)
682 HANDLE_DW_VIRTUALITY(0x01, virtual)
683 HANDLE_DW_VIRTUALITY(0x02, pure_virtual)
684
685 // DWARF v5 Defaulted Member Encodings.
686 HANDLE_DW_DEFAULTED(0x00, no)
687 HANDLE_DW_DEFAULTED(0x01, in_class)
688 HANDLE_DW_DEFAULTED(0x02, out_of_class)
689
690 // DWARF calling convention codes.
691 HANDLE_DW_CC(0x01, normal)
692 HANDLE_DW_CC(0x02, program)
693 HANDLE_DW_CC(0x03, nocall)
694 // New in DWARF v5:
695 HANDLE_DW_CC(0x04, pass_by_reference)
696 HANDLE_DW_CC(0x05, pass_by_value)
697 // Vendor extensions:
698 HANDLE_DW_CC(0x41, GNU_borland_fastcall_i386)
699 HANDLE_DW_CC(0xb0, BORLAND_safecall)
700 HANDLE_DW_CC(0xb1, BORLAND_stdcall)
701 HANDLE_DW_CC(0xb2, BORLAND_pascal)
702 HANDLE_DW_CC(0xb3, BORLAND_msfastcall)
703 HANDLE_DW_CC(0xb4, BORLAND_msreturn)
704 HANDLE_DW_CC(0xb5, BORLAND_thiscall)
705 HANDLE_DW_CC(0xb6, BORLAND_fastcall)
706 HANDLE_DW_CC(0xc0, LLVM_vectorcall)
707
708 // Line Number Extended Opcode Encodings
709 HANDLE_DW_LNE(0x01, end_sequence)
710 HANDLE_DW_LNE(0x02, set_address)
711 HANDLE_DW_LNE(0x03, define_file)
712 // New in DWARF v4:
713 HANDLE_DW_LNE(0x04, set_discriminator)
714
715 // Line Number Standard Opcode Encodings.
716 HANDLE_DW_LNS(0x00, extended_op)
717 HANDLE_DW_LNS(0x01, copy)
718 HANDLE_DW_LNS(0x02, advance_pc)
719 HANDLE_DW_LNS(0x03, advance_line)
720 HANDLE_DW_LNS(0x04, set_file)
721 HANDLE_DW_LNS(0x05, set_column)
722 HANDLE_DW_LNS(0x06, negate_stmt)
723 HANDLE_DW_LNS(0x07, set_basic_block)
724 HANDLE_DW_LNS(0x08, const_add_pc)
725 HANDLE_DW_LNS(0x09, fixed_advance_pc)
726 // New in DWARF v3:
727 HANDLE_DW_LNS(0x0a, set_prologue_end)
728 HANDLE_DW_LNS(0x0b, set_epilogue_begin)
729 HANDLE_DW_LNS(0x0c, set_isa)
730
731 // DWARF v5 Line number header entry format.
732 HANDLE_DW_LNCT(0x01, path)
733 HANDLE_DW_LNCT(0x02, directory_index)
734 HANDLE_DW_LNCT(0x03, timestamp)
735 HANDLE_DW_LNCT(0x04, size)
736 HANDLE_DW_LNCT(0x05, MD5)
737
738 // DWARF v5 Macro information.
739 HANDLE_DW_MACRO(0x01, define)
740 HANDLE_DW_MACRO(0x02, undef)
741 HANDLE_DW_MACRO(0x03, start_file)
742 HANDLE_DW_MACRO(0x04, end_file)
743 HANDLE_DW_MACRO(0x05, define_strp)
744 HANDLE_DW_MACRO(0x06, undef_strp)
745 HANDLE_DW_MACRO(0x07, import)
746 HANDLE_DW_MACRO(0x08, define_sup)
747 HANDLE_DW_MACRO(0x09, undef_sup)
748 HANDLE_DW_MACRO(0x0a, import_sup)
749 HANDLE_DW_MACRO(0x0b, define_strx)
750 HANDLE_DW_MACRO(0x0c, undef_strx)
751
752 // DWARF v5 Range List Entry encoding values.
753 HANDLE_DW_RLE(0x00, end_of_list)
754 HANDLE_DW_RLE(0x01, base_addressx)
755 HANDLE_DW_RLE(0x02, startx_endx)
756 HANDLE_DW_RLE(0x03, startx_length)
757 HANDLE_DW_RLE(0x04, offset_pair)
758 HANDLE_DW_RLE(0x05, base_address)
759 HANDLE_DW_RLE(0x06, start_end)
760 HANDLE_DW_RLE(0x07, start_length)
761
762 // Call frame instruction encodings.
763 HANDLE_DW_CFA(0x00, nop)
764 HANDLE_DW_CFA(0x40, advance_loc)
765 HANDLE_DW_CFA(0x80, offset)
766 HANDLE_DW_CFA(0xc0, restore)
767 HANDLE_DW_CFA(0x01, set_loc)
768 HANDLE_DW_CFA(0x02, advance_loc1)
769 HANDLE_DW_CFA(0x03, advance_loc2)
770 HANDLE_DW_CFA(0x04, advance_loc4)
771 HANDLE_DW_CFA(0x05, offset_extended)
772 HANDLE_DW_CFA(0x06, restore_extended)
773 HANDLE_DW_CFA(0x07, undefined)
774 HANDLE_DW_CFA(0x08, same_value)
775 HANDLE_DW_CFA(0x09, register)
776 HANDLE_DW_CFA(0x0a, remember_state)
777 HANDLE_DW_CFA(0x0b, restore_state)
778 HANDLE_DW_CFA(0x0c, def_cfa)
779 HANDLE_DW_CFA(0x0d, def_cfa_register)
780 HANDLE_DW_CFA(0x0e, def_cfa_offset)
781 // New in DWARF v3:
782 HANDLE_DW_CFA(0x0f, def_cfa_expression)
783 HANDLE_DW_CFA(0x10, expression)
784 HANDLE_DW_CFA(0x11, offset_extended_sf)
785 HANDLE_DW_CFA(0x12, def_cfa_sf)
786 HANDLE_DW_CFA(0x13, def_cfa_offset_sf)
787 HANDLE_DW_CFA(0x14, val_offset)
788 HANDLE_DW_CFA(0x15, val_offset_sf)
789 HANDLE_DW_CFA(0x16, val_expression)
790 // Vendor extensions:
791 HANDLE_DW_CFA(0x1d, MIPS_advance_loc8)
792 HANDLE_DW_CFA(0x2d, GNU_window_save)
793 HANDLE_DW_CFA(0x2e, GNU_args_size)
794
795 // Apple Objective-C Property Attributes.
796 // Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
797 HANDLE_DW_APPLE_PROPERTY(0x01, readonly)
798 HANDLE_DW_APPLE_PROPERTY(0x02, getter)
799 HANDLE_DW_APPLE_PROPERTY(0x04, assign)
800 HANDLE_DW_APPLE_PROPERTY(0x08, readwrite)
801 HANDLE_DW_APPLE_PROPERTY(0x10, retain)
802 HANDLE_DW_APPLE_PROPERTY(0x20, copy)
803 HANDLE_DW_APPLE_PROPERTY(0x40, nonatomic)
804 HANDLE_DW_APPLE_PROPERTY(0x80, setter)
805 HANDLE_DW_APPLE_PROPERTY(0x100, atomic)
806 HANDLE_DW_APPLE_PROPERTY(0x200, weak)
807 HANDLE_DW_APPLE_PROPERTY(0x400, strong)
808 HANDLE_DW_APPLE_PROPERTY(0x800, unsafe_unretained)
809 HANDLE_DW_APPLE_PROPERTY(0x1000, nullability)
810 HANDLE_DW_APPLE_PROPERTY(0x2000, null_resettable)
811 HANDLE_DW_APPLE_PROPERTY(0x4000, class)
812
813 // DWARF v5 Unit Types.
814 HANDLE_DW_UT(0x01, compile)
815 HANDLE_DW_UT(0x02, type)
816 HANDLE_DW_UT(0x03, partial)
817 HANDLE_DW_UT(0x04, skeleton)
818 HANDLE_DW_UT(0x05, split_compile)
819 HANDLE_DW_UT(0x06, split_type)
820
821 #undef HANDLE_DW_TAG
822 #undef HANDLE_DW_AT
823 #undef HANDLE_DW_FORM
824 #undef HANDLE_DW_OP
825 #undef HANDLE_DW_LANG
826 #undef HANDLE_DW_ATE
827 #undef HANDLE_DW_VIRTUALITY
828 #undef HANDLE_DW_DEFAULTED
829 #undef HANDLE_DW_CC
830 #undef HANDLE_DW_LNS
831 #undef HANDLE_DW_LNE
832 #undef HANDLE_DW_LNCT
833 #undef HANDLE_DW_MACRO
834 #undef HANDLE_DW_RLE
835 #undef HANDLE_DW_CFA
836 #undef HANDLE_DW_APPLE_PROPERTY
837 #undef HANDLE_DW_UT
0 //===-- llvm/BinaryFormat/Dwarf.h ---Dwarf Constants-------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // \file
10 // \brief This file contains constants used for implementing Dwarf
11 // debug support.
12 //
13 // For details on the Dwarf specfication see the latest DWARF Debugging
14 // Information Format standard document on http://www.dwarfstd.org. This
15 // file often includes support for non-released standard features.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef LLVM_BINARYFORMAT_DWARF_H
20 #define LLVM_BINARYFORMAT_DWARF_H
21
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/DataTypes.h"
24
25 namespace llvm {
26 class StringRef;
27
28 namespace dwarf {
29
30 //===----------------------------------------------------------------------===//
31 // DWARF constants as gleaned from the DWARF Debugging Information Format V.5
32 // reference manual http://www.dwarfstd.org/.
33 //
34
35 // Do not mix the following two enumerations sets. DW_TAG_invalid changes the
36 // enumeration base type.
37
38 enum LLVMConstants : uint32_t {
39 // LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
40 DW_TAG_invalid = ~0U, // Tag for invalid results.
41 DW_VIRTUALITY_invalid = ~0U, // Virtuality for invalid results.
42 DW_MACINFO_invalid = ~0U, // Macinfo type for invalid results.
43
44 // Other constants.
45 DWARF_VERSION = 4, // Default dwarf version we output.
46 DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes.
47 DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames.
48 DW_ARANGES_VERSION = 2, // Section version number for .debug_aranges.
49 // Identifiers we use to distinguish vendor extensions.
50 DWARF_VENDOR_DWARF = 0, // Defined in v2 or later of the DWARF standard.
51 DWARF_VENDOR_APPLE = 1,
52 DWARF_VENDOR_BORLAND = 2,
53 DWARF_VENDOR_GNU = 3,
54 DWARF_VENDOR_GOOGLE = 4,
55 DWARF_VENDOR_LLVM = 5,
56 DWARF_VENDOR_MIPS = 6
57 };
58
59 // Special ID values that distinguish a CIE from a FDE in DWARF CFI.
60 // Not inside an enum because a 64-bit value is needed.
61 const uint32_t DW_CIE_ID = UINT32_MAX;
62 const uint64_t DW64_CIE_ID = UINT64_MAX;
63
64 enum Tag : uint16_t {
65 #define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) DW_TAG_##NAME = ID,
66 #include "llvm/BinaryFormat/Dwarf.def"
67 DW_TAG_lo_user = 0x4080,
68 DW_TAG_hi_user = 0xffff,
69 DW_TAG_user_base = 0x1000 // Recommended base for user tags.
70 };
71
72 inline bool isType(Tag T) {
73 switch (T) {
74 case DW_TAG_array_type:
75 case DW_TAG_class_type:
76 case DW_TAG_interface_type:
77 case DW_TAG_enumeration_type:
78 case DW_TAG_pointer_type:
79 case DW_TAG_reference_type:
80 case DW_TAG_rvalue_reference_type:
81 case DW_TAG_string_type:
82 case DW_TAG_structure_type:
83 case DW_TAG_subroutine_type:
84 case DW_TAG_union_type:
85 case DW_TAG_ptr_to_member_type:
86 case DW_TAG_set_type:
87 case DW_TAG_subrange_type:
88 case DW_TAG_base_type:
89 case DW_TAG_const_type:
90 case DW_TAG_file_type:
91 case DW_TAG_packed_type:
92 case DW_TAG_volatile_type:
93 case DW_TAG_typedef:
94 return true;
95 default:
96 return false;
97 }
98 }
99
100 /// Attributes.
101 enum Attribute : uint16_t {
102 #define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) DW_AT_##NAME = ID,
103 #include "llvm/BinaryFormat/Dwarf.def"
104 DW_AT_lo_user = 0x2000,
105 DW_AT_hi_user = 0x3fff,
106 };
107
108 enum Form : uint16_t {
109 #define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) DW_FORM_##NAME = ID,
110 #include "llvm/BinaryFormat/Dwarf.def"
111 DW_FORM_lo_user = 0x1f00, ///< Not specified by DWARF.
112 };
113
114 enum LocationAtom {
115 #define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) DW_OP_##NAME = ID,
116 #include "llvm/BinaryFormat/Dwarf.def"
117 DW_OP_lo_user = 0xe0,
118 DW_OP_hi_user = 0xff,
119 DW_OP_LLVM_fragment = 0x1000 ///< Only used in LLVM metadata.
120 };
121
122 enum TypeKind {
123 #define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) DW_ATE_##NAME = ID,
124 #include "llvm/BinaryFormat/Dwarf.def"
125 DW_ATE_lo_user = 0x80,
126 DW_ATE_hi_user = 0xff
127 };
128
129 enum DecimalSignEncoding {
130 // Decimal sign attribute values
131 DW_DS_unsigned = 0x01,
132 DW_DS_leading_overpunch = 0x02,
133 DW_DS_trailing_overpunch = 0x03,
134 DW_DS_leading_separate = 0x04,
135 DW_DS_trailing_separate = 0x05
136 };
137
138 enum EndianityEncoding {
139 // Endianity attribute values
140 DW_END_default = 0x00,
141 DW_END_big = 0x01,
142 DW_END_little = 0x02,
143 DW_END_lo_user = 0x40,
144 DW_END_hi_user = 0xff
145 };
146
147 enum AccessAttribute {
148 // Accessibility codes
149 DW_ACCESS_public = 0x01,
150 DW_ACCESS_protected = 0x02,
151 DW_ACCESS_private = 0x03
152 };
153
154 enum VisibilityAttribute {
155 // Visibility codes
156 DW_VIS_local = 0x01,
157 DW_VIS_exported = 0x02,
158 DW_VIS_qualified = 0x03
159 };
160
161 enum VirtualityAttribute {
162 #define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID,
163 #include "llvm/BinaryFormat/Dwarf.def"
164 DW_VIRTUALITY_max = 0x02
165 };
166
167 enum DefaultedMemberAttribute {
168 #define HANDLE_DW_DEFAULTED(ID, NAME) DW_DEFAULTED_##NAME = ID,
169 #include "llvm/BinaryFormat/Dwarf.def"
170 DW_DEFAULTED_max = 0x02
171 };
172
173 enum SourceLanguage {
174 #define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR) DW_LANG_##NAME = ID,
175 #include "llvm/BinaryFormat/Dwarf.def"
176 DW_LANG_lo_user = 0x8000,
177 DW_LANG_hi_user = 0xffff
178 };
179
180 enum CaseSensitivity {
181 // Identifier case codes
182 DW_ID_case_sensitive = 0x00,
183 DW_ID_up_case = 0x01,
184 DW_ID_down_case = 0x02,
185 DW_ID_case_insensitive = 0x03
186 };
187
188 enum CallingConvention {
189 // Calling convention codes
190 #define HANDLE_DW_CC(ID, NAME) DW_CC_##NAME = ID,
191 #include "llvm/BinaryFormat/Dwarf.def"
192 DW_CC_lo_user = 0x40,
193 DW_CC_hi_user = 0xff
194 };
195
196 enum InlineAttribute {
197 // Inline codes
198 DW_INL_not_inlined = 0x00,
199 DW_INL_inlined = 0x01,
200 DW_INL_declared_not_inlined = 0x02,
201 DW_INL_declared_inlined = 0x03
202 };
203
204 enum ArrayDimensionOrdering {
205 // Array ordering
206 DW_ORD_row_major = 0x00,
207 DW_ORD_col_major = 0x01
208 };
209
210 enum DiscriminantList {
211 // Discriminant descriptor values
212 DW_DSC_label = 0x00,
213 DW_DSC_range = 0x01
214 };
215
216 /// Line Number Standard Opcode Encodings.
217 enum LineNumberOps : uint8_t {
218 #define HANDLE_DW_LNS(ID, NAME) DW_LNS_##NAME = ID,
219 #include "llvm/BinaryFormat/Dwarf.def"
220 };
221
222 /// Line Number Extended Opcode Encodings.
223 enum LineNumberExtendedOps {
224 #define HANDLE_DW_LNE(ID, NAME) DW_LNE_##NAME = ID,
225 #include "llvm/BinaryFormat/Dwarf.def"
226 DW_LNE_lo_user = 0x80,
227 DW_LNE_hi_user = 0xff
228 };
229
230 enum LineNumberEntryFormat {
231 #define HANDLE_DW_LNCT(ID, NAME) DW_LNCT_##NAME = ID,
232 #include "llvm/BinaryFormat/Dwarf.def"
233 DW_LNCT_lo_user = 0x2000,
234 DW_LNCT_hi_user = 0x3fff,
235 };
236
237 enum MacinfoRecordType {
238 // Macinfo Type Encodings
239 DW_MACINFO_define = 0x01,
240 DW_MACINFO_undef = 0x02,
241 DW_MACINFO_start_file = 0x03,
242 DW_MACINFO_end_file = 0x04,
243 DW_MACINFO_vendor_ext = 0xff
244 };
245
246 /// DWARF v5 macro information entry type encodings.
247 enum MacroEntryType {
248 #define HANDLE_DW_MACRO(ID, NAME) DW_MACRO_##NAME = ID,
249 #include "llvm/BinaryFormat/Dwarf.def"
250 DW_MACRO_lo_user = 0xe0,
251 DW_MACRO_hi_user = 0xff
252 };
253
254 /// DWARF v5 range list entry encoding values.
255 enum RangeListEntries {
256 #define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID,
257 #include "llvm/BinaryFormat/Dwarf.def"
258 };
259
260 /// Call frame instruction encodings.
261 enum CallFrameInfo {
262 #define HANDLE_DW_CFA(ID, NAME) DW_CFA_##NAME = ID,
263 #include "llvm/BinaryFormat/Dwarf.def"
264 DW_CFA_extended = 0x00,
265
266 DW_CFA_lo_user = 0x1c,
267 DW_CFA_hi_user = 0x3f
268 };
269
270 enum Constants {
271 // Children flag
272 DW_CHILDREN_no = 0x00,
273 DW_CHILDREN_yes = 0x01,
274
275 DW_EH_PE_absptr = 0x00,
276 DW_EH_PE_omit = 0xff,
277 DW_EH_PE_uleb128 = 0x01,
278 DW_EH_PE_udata2 = 0x02,
279 DW_EH_PE_udata4 = 0x03,
280 DW_EH_PE_udata8 = 0x04,
281 DW_EH_PE_sleb128 = 0x09,
282 DW_EH_PE_sdata2 = 0x0A,
283 DW_EH_PE_sdata4 = 0x0B,
284 DW_EH_PE_sdata8 = 0x0C,
285 DW_EH_PE_signed = 0x08,
286 DW_EH_PE_pcrel = 0x10,
287 DW_EH_PE_textrel = 0x20,
288 DW_EH_PE_datarel = 0x30,
289 DW_EH_PE_funcrel = 0x40,
290 DW_EH_PE_aligned = 0x50,
291 DW_EH_PE_indirect = 0x80
292 };
293
294 /// Constants for location lists in DWARF v5.
295 enum LocationListEntry : unsigned char {
296 DW_LLE_end_of_list = 0x00,
297 DW_LLE_base_addressx = 0x01,
298 DW_LLE_startx_endx = 0x02,
299 DW_LLE_startx_length = 0x03,
300 DW_LLE_offset_pair = 0x04,
301 DW_LLE_default_location = 0x05,
302 DW_LLE_base_address = 0x06,
303 DW_LLE_start_end = 0x07,
304 DW_LLE_start_length = 0x08
305 };
306
307 /// Constants for the DW_APPLE_PROPERTY_attributes attribute.
308 /// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
309 enum ApplePropertyAttributes {
310 #define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
311 #include "llvm/BinaryFormat/Dwarf.def"
312 };
313
314 /// Constants for unit types in DWARF v5.
315 enum UnitType : unsigned char {
316 #define HANDLE_DW_UT(ID, NAME) DW_UT_##NAME = ID,
317 #include "llvm/BinaryFormat/Dwarf.def"
318 DW_UT_lo_user = 0x80,
319 DW_UT_hi_user = 0xff
320 };
321
322 // Constants for the DWARF v5 Accelerator Table Proposal
323 enum AcceleratorTable {
324 // Data layout descriptors.
325 DW_ATOM_null = 0u, // Marker as the end of a list of atoms.
326 DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
327 DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
328 // item in question.
329 DW_ATOM_die_tag = 3u, // A tag entry.
330 DW_ATOM_type_flags = 4u, // Set of flags for a type.
331
332 // DW_ATOM_type_flags values.
333
334 // Always set for C++, only set for ObjC if this is the @implementation for a
335 // class.
336 DW_FLAG_type_implementation = 2u,
337
338 // Hash functions.
339
340 // Daniel J. Bernstein hash.
341 DW_hash_function_djb = 0u
342 };
343
344 // Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
345 enum GDBIndexEntryKind {
346 GIEK_NONE,
347 GIEK_TYPE,
348 GIEK_VARIABLE,
349 GIEK_FUNCTION,
350 GIEK_OTHER,
351 GIEK_UNUSED5,
352 GIEK_UNUSED6,
353 GIEK_UNUSED7
354 };
355
356 enum GDBIndexEntryLinkage { GIEL_EXTERNAL, GIEL_STATIC };
357
358 /// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
359 ///
360 /// All these functions map their argument's value back to the
361 /// corresponding enumerator name or return nullptr if the value isn't
362 /// known.
363 ///
364 /// @{
365 StringRef TagString(unsigned Tag);
366 StringRef ChildrenString(unsigned Children);
367 StringRef AttributeString(unsigned Attribute);
368 StringRef FormEncodingString(unsigned Encoding);
369 StringRef OperationEncodingString(unsigned Encoding);
370 StringRef AttributeEncodingString(unsigned Encoding);
371 StringRef DecimalSignString(unsigned Sign);
372 StringRef EndianityString(unsigned Endian);
373 StringRef AccessibilityString(unsigned Access);
374 StringRef VisibilityString(unsigned Visibility);
375 StringRef VirtualityString(unsigned Virtuality);
376 StringRef LanguageString(unsigned Language);
377 StringRef CaseString(unsigned Case);
378 StringRef ConventionString(unsigned Convention);
379 StringRef InlineCodeString(unsigned Code);
380 StringRef ArrayOrderString(unsigned Order);
381 StringRef DiscriminantString(unsigned Discriminant);
382 StringRef LNStandardString(unsigned Standard);
383 StringRef LNExtendedString(unsigned Encoding);
384 StringRef MacinfoString(unsigned Encoding);
385 StringRef CallFrameString(unsigned Encoding);
386 StringRef ApplePropertyString(unsigned);
387 StringRef UnitTypeString(unsigned);
388 StringRef AtomTypeString(unsigned Atom);
389 StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind);
390 StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
391 /// @}
392
393 /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
394 ///
395 /// These functions map their strings back to the corresponding enumeration
396 /// value or return 0 if there is none, except for these exceptions:
397 ///
398 /// \li \a getTag() returns \a DW_TAG_invalid on invalid input.
399 /// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input.
400 /// \li \a getMacinfo() returns \a DW_MACINFO_invalid on invalid input.
401 ///
402 /// @{
403 unsigned getTag(StringRef TagString);
404 unsigned getOperationEncoding(StringRef OperationEncodingString);
405 unsigned getVirtuality(StringRef VirtualityString);
406 unsigned getLanguage(StringRef LanguageString);
407 unsigned getCallingConvention(StringRef LanguageString);
408 unsigned getAttributeEncoding(StringRef EncodingString);
409 unsigned getMacinfo(StringRef MacinfoString);
410 /// @}
411
412 /// \defgroup DwarfConstantsVersioning Dwarf version for constants
413 ///
414 /// For constants defined by DWARF, returns the DWARF version when the constant
415 /// was first defined. For vendor extensions, if there is a version-related
416 /// policy for when to emit it, returns a version number for that policy.
417 /// Otherwise returns 0.
418 ///
419 /// @{
420 unsigned TagVersion(Tag T);
421 unsigned AttributeVersion(Attribute A);
422 unsigned FormVersion(Form F);
423 unsigned OperationVersion(LocationAtom O);
424 unsigned AttributeEncodingVersion(TypeKind E);
425 unsigned LanguageVersion(SourceLanguage L);
426 /// @}
427
428 /// \defgroup DwarfConstantsVendor Dwarf "vendor" for constants
429 ///
430 /// These functions return an identifier describing "who" defined the constant,
431 /// either the DWARF standard itself or the vendor who defined the extension.
432 ///
433 /// @{
434 unsigned TagVendor(Tag T);
435 unsigned AttributeVendor(Attribute A);
436 unsigned FormVendor(Form F);
437 unsigned OperationVendor(LocationAtom O);
438 unsigned AttributeEncodingVendor(TypeKind E);
439 unsigned LanguageVendor(SourceLanguage L);
440 /// @}
441
442 /// Tells whether the specified form is defined in the specified version,
443 /// or is an extension if extensions are allowed.
444 bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk = true);
445
446 /// \brief Returns the symbolic string representing Val when used as a value
447 /// for attribute Attr.
448 StringRef AttributeValueString(uint16_t Attr, unsigned Val);
449
450 /// \brief Decsribes an entry of the various gnu_pub* debug sections.
451 ///
452 /// The gnu_pub* kind looks like:
453 ///
454 /// 0-3 reserved
455 /// 4-6 symbol kind
456 /// 7 0 == global, 1 == static
457 ///
458 /// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
459 /// offset of the cu within the debug_info section stored in those 24 bits.
460 struct PubIndexEntryDescriptor {
461 GDBIndexEntryKind Kind;
462 GDBIndexEntryLinkage Linkage;
463 PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
464 : Kind(Kind), Linkage(Linkage) {}
465 /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
466 : Kind(Kind), Linkage(GIEL_EXTERNAL) {}
467 explicit PubIndexEntryDescriptor(uint8_t Value)
468 : Kind(
469 static_cast((Value & KIND_MASK) >> KIND_OFFSET)),
470 Linkage(static_cast((Value & LINKAGE_MASK) >>
471 LINKAGE_OFFSET)) {}
472 uint8_t toBits() const {
473 return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET;
474 }
475
476 private:
477 enum {
478 KIND_OFFSET = 4,
479 KIND_MASK = 7 << KIND_OFFSET,
480 LINKAGE_OFFSET = 7,
481 LINKAGE_MASK = 1 << LINKAGE_OFFSET
482 };
483 };
484
485 /// Constants that define the DWARF format as 32 or 64 bit.
486 enum DwarfFormat { DWARF32, DWARF64 };
487
488 } // End of namespace dwarf
489
490 } // End of namespace llvm
491
492 #endif
0 //===-- llvm/BinaryFormat/ELF.h - ELF constants and structures --*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This header contains common, non-processor-specific data structures and
10 // constants for the ELF file format.
11 //
12 // The details of the ELF32 bits in this file are largely based on the Tool
13 // Interface Standard (TIS) Executable and Linking Format (ELF) Specification
14 // Version 1.2, May 1995. The ELF64 stuff is based on ELF-64 Object File Format
15 // Version 1.5, Draft 2, May 1998 as well as OpenBSD header files.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef LLVM_BINARYFORMAT_ELF_H
20 #define LLVM_BINARYFORMAT_ELF_H
21
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/DataTypes.h"
24 #include
25
26 namespace llvm {
27
28 namespace ELF {
29
30 typedef uint32_t Elf32_Addr; // Program address
31 typedef uint32_t Elf32_Off; // File offset
32 typedef uint16_t Elf32_Half;
33 typedef uint32_t Elf32_Word;
34 typedef int32_t Elf32_Sword;
35
36 typedef uint64_t Elf64_Addr;
37 typedef uint64_t Elf64_Off;
38 typedef uint16_t Elf64_Half;
39 typedef uint32_t Elf64_Word;
40 typedef int32_t Elf64_Sword;
41 typedef uint64_t Elf64_Xword;
42 typedef int64_t Elf64_Sxword;
43
44 // Object file magic string.
45 static const char ElfMagic[] = {0x7f, 'E', 'L', 'F', '\0'};
46
47 // e_ident size and indices.
48 enum {
49 EI_MAG0 = 0, // File identification index.
50 EI_MAG1 = 1, // File identification index.
51 EI_MAG2 = 2, // File identification index.
52 EI_MAG3 = 3, // File identification index.
53 EI_CLASS = 4, // File class.
54 EI_DATA = 5, // Data encoding.
55 EI_VERSION = 6, // File version.
56 EI_OSABI = 7, // OS/ABI identification.
57 EI_ABIVERSION = 8, // ABI version.
58 EI_PAD = 9, // Start of padding bytes.
59 EI_NIDENT = 16 // Number of bytes in e_ident.
60 };
61
62 struct Elf32_Ehdr {
63 unsigned char e_ident[EI_NIDENT]; // ELF Identification bytes
64 Elf32_Half e_type; // Type of file (see ET_* below)
65 Elf32_Half e_machine; // Required architecture for this file (see EM_*)
66 Elf32_Word e_version; // Must be equal to 1
67 Elf32_Addr e_entry; // Address to jump to in order to start program
68 Elf32_Off e_phoff; // Program header table's file offset, in bytes
69 Elf32_Off e_shoff; // Section header table's file offset, in bytes
70 Elf32_Word e_flags; // Processor-specific flags
71 Elf32_Half e_ehsize; // Size of ELF header, in bytes
72 Elf32_Half e_phentsize; // Size of an entry in the program header table
73 Elf32_Half e_phnum; // Number of entries in the program header table
74 Elf32_Half e_shentsize; // Size of an entry in the section header table
75 Elf32_Half e_shnum; // Number of entries in the section header table
76 Elf32_Half e_shstrndx; // Sect hdr table index of sect name string table
77 bool checkMagic() const {
78 return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0;
79 }
80 unsigned char getFileClass() const { return e_ident[EI_CLASS]; }
81 unsigned char getDataEncoding() const { return e_ident[EI_DATA]; }
82 };
83
84 // 64-bit ELF header. Fields are the same as for ELF32, but with different
85 // types (see above).
86 struct Elf64_Ehdr {
87 unsigned char e_ident[EI_NIDENT];
88 Elf64_Half e_type;
89 Elf64_Half e_machine;
90 Elf64_Word e_version;
91 Elf64_Addr e_entry;
92 Elf64_Off e_phoff;
93 Elf64_Off e_shoff;
94 Elf64_Word e_flags;
95 Elf64_Half e_ehsize;
96 Elf64_Half e_phentsize;
97 Elf64_Half e_phnum;
98 Elf64_Half e_shentsize;
99 Elf64_Half e_shnum;
100 Elf64_Half e_shstrndx;
101 bool checkMagic() const {
102 return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0;
103 }
104 unsigned char getFileClass() const { return e_ident[EI_CLASS]; }
105 unsigned char getDataEncoding() const { return e_ident[EI_DATA]; }
106 };
107
108 // File types
109 enum {
110 ET_NONE = 0, // No file type
111 ET_REL = 1, // Relocatable file
112 ET_EXEC = 2, // Executable file
113 ET_DYN = 3, // Shared object file
114 ET_CORE = 4, // Core file
115 ET_LOPROC = 0xff00, // Beginning of processor-specific codes
116 ET_HIPROC = 0xffff // Processor-specific
117 };
118
119 // Versioning
120 enum { EV_NONE = 0, EV_CURRENT = 1 };
121
122 // Machine architectures
123 // See current registered ELF machine architectures at:
124 // http://www.uxsglobal.com/developers/gabi/latest/ch4.eheader.html
125 enum {
126 EM_NONE = 0, // No machine
127 EM_M32 = 1, // AT&T WE 32100
128 EM_SPARC = 2, // SPARC
129 EM_386 = 3, // Intel 386
130 EM_68K = 4, // Motorola 68000
131 EM_88K = 5, // Motorola 88000
132 EM_IAMCU = 6, // Intel MCU
133 EM_860 = 7, // Intel 80860
134 EM_MIPS = 8, // MIPS R3000
135 EM_S370 = 9, // IBM System/370
136 EM_MIPS_RS3_LE = 10, // MIPS RS3000 Little-endian
137 EM_PARISC = 15, // Hewlett-Packard PA-RISC
138 EM_VPP500 = 17, // Fujitsu VPP500
139 EM_SPARC32PLUS = 18, // Enhanced instruction set SPARC
140 EM_960 = 19, // Intel 80960
141 EM_PPC = 20, // PowerPC
142 EM_PPC64 = 21, // PowerPC64
143 EM_S390 = 22, // IBM System/390
144 EM_SPU = 23, // IBM SPU/SPC
145 EM_V800 = 36, // NEC V800
146 EM_FR20 = 37, // Fujitsu FR20
147 EM_RH32 = 38, // TRW RH-32
148 EM_RCE = 39, // Motorola RCE
149 EM_ARM = 40, // ARM
150 EM_ALPHA = 41, // DEC Alpha
151 EM_SH = 42, // Hitachi SH
152 EM_SPARCV9 = 43, // SPARC V9
153 EM_TRICORE = 44, // Siemens TriCore
154 EM_ARC = 45, // Argonaut RISC Core
155 EM_H8_300 = 46, // Hitachi H8/300
156 EM_H8_300H = 47, // Hitachi H8/300H
157 EM_H8S = 48, // Hitachi H8S
158 EM_H8_500 = 49, // Hitachi H8/500
159 EM_IA_64 = 50, // Intel IA-64 processor architecture
160 EM_MIPS_X = 51, // Stanford MIPS-X
161 EM_COLDFIRE = 52, // Motorola ColdFire
162 EM_68HC12 = 53, // Motorola M68HC12
163 EM_MMA = 54, // Fujitsu MMA Multimedia Accelerator
164 EM_PCP = 55, // Siemens PCP
165 EM_NCPU = 56, // Sony nCPU embedded RISC processor
166 EM_NDR1 = 57, // Denso NDR1 microprocessor
167 EM_STARCORE = 58, // Motorola Star*Core processor
168 EM_ME16 = 59, // Toyota ME16 processor
169 EM_ST100 = 60, // STMicroelectronics ST100 processor
170 EM_TINYJ = 61, // Advanced Logic Corp. TinyJ embedded processor family
171 EM_X86_64 = 62, // AMD x86-64 architecture
172 EM_PDSP = 63, // Sony DSP Processor
173 EM_PDP10 = 64, // Digital Equipment Corp. PDP-10
174 EM_PDP11 = 65, // Digital Equipment Corp. PDP-11
175 EM_FX66 = 66, // Siemens FX66 microcontroller
176 EM_ST9PLUS = 67, // STMicroelectronics ST9+ 8/16 bit microcontroller
177 EM_ST7 = 68, // STMicroelectronics ST7 8-bit microcontroller
178 EM_68HC16 = 69, // Motorola MC68HC16 Microcontroller
179 EM_68HC11 = 70, // Motorola MC68HC11 Microcontroller
180 EM_68HC08 = 71, // Motorola MC68HC08 Microcontroller
181 EM_68HC05 = 72, // Motorola MC68HC05 Microcontroller
182 EM_SVX = 73, // Silicon Graphics SVx
183 EM_ST19 = 74, // STMicroelectronics ST19 8-bit microcontroller
184 EM_VAX = 75, // Digital VAX
185 EM_CRIS = 76, // Axis Communications 32-bit embedded processor
186 EM_JAVELIN = 77, // Infineon Technologies 32-bit embedded processor
187 EM_FIREPATH = 78, // Element 14 64-bit DSP Processor
188 EM_ZSP = 79, // LSI Logic 16-bit DSP Processor
189 EM_MMIX = 80, // Donald Knuth's educational 64-bit processor
190 EM_HUANY = 81, // Harvard University machine-independent object files
191 EM_PRISM = 82, // SiTera Prism
192 EM_AVR = 83, // Atmel AVR 8-bit microcontroller
193 EM_FR30 = 84, // Fujitsu FR30
194 EM_D10V = 85, // Mitsubishi D10V
195 EM_D30V = 86, // Mitsubishi D30V
196 EM_V850 = 87, // NEC v850
197 EM_M32R = 88, // Mitsubishi M32R
198 EM_MN10300 = 89, // Matsushita MN10300
199 EM_MN10200 = 90, // Matsushita MN10200
200 EM_PJ = 91, // picoJava
201 EM_OPENRISC = 92, // OpenRISC 32-bit embedded processor
202 EM_ARC_COMPACT = 93, // ARC International ARCompact processor (old
203 // spelling/synonym: EM_ARC_A5)
204 EM_XTENSA = 94, // Tensilica Xtensa Architecture
205 EM_VIDEOCORE = 95, // Alphamosaic VideoCore processor
206 EM_TMM_GPP = 96, // Thompson Multimedia General Purpose Processor
207 EM_NS32K = 97, // National Semiconductor 32000 series
208 EM_TPC = 98, // Tenor Network TPC processor
209 EM_SNP1K = 99, // Trebia SNP 1000 processor
210 EM_ST200 = 100, // STMicroelectronics (www.st.com) ST200
211 EM_IP2K = 101, // Ubicom IP2xxx microcontroller family
212 EM_MAX = 102, // MAX Processor
213 EM_CR = 103, // National Semiconductor CompactRISC microprocessor
214 EM_F2MC16 = 104, // Fujitsu F2MC16
215 EM_MSP430 = 105, // Texas Instruments embedded microcontroller msp430
216 EM_BLACKFIN = 106, // Analog Devices Blackfin (DSP) processor
217 EM_SE_C33 = 107, // S1C33 Family of Seiko Epson processors
218 EM_SEP = 108, // Sharp embedded microprocessor
219 EM_ARCA = 109, // Arca RISC Microprocessor
220 EM_UNICORE = 110, // Microprocessor series from PKU-Unity Ltd. and MPRC
221 // of Peking University
222 EM_EXCESS = 111, // eXcess: 16/32/64-bit configurable embedded CPU
223 EM_DXP = 112, // Icera Semiconductor Inc. Deep Execution Processor
224 EM_ALTERA_NIOS2 = 113, // Altera Nios II soft-core processor
225 EM_CRX = 114, // National Semiconductor CompactRISC CRX
226 EM_XGATE = 115, // Motorola XGATE embedded processor
227 EM_C166 = 116, // Infineon C16x/XC16x processor
228 EM_M16C = 117, // Renesas M16C series microprocessors
229 EM_DSPIC30F = 118, // Microchip Technology dsPIC30F Digital Signal
230 // Controller
231 EM_CE = 119, // Freescale Communication Engine RISC core
232 EM_M32C = 120, // Renesas M32C series microprocessors
233 EM_TSK3000 = 131, // Altium TSK3000 core
234 EM_RS08 = 132, // Freescale RS08 embedded processor
235 EM_SHARC = 133, // Analog Devices SHARC family of 32-bit DSP
236 // processors
237 EM_ECOG2 = 134, // Cyan Technology eCOG2 microprocessor
238 EM_SCORE7 = 135, // Sunplus S+core7 RISC processor
239 EM_DSP24 = 136, // New Japan Radio (NJR) 24-bit DSP Processor
240 EM_VIDEOCORE3 = 137, // Broadcom VideoCore III processor
241 EM_LATTICEMICO32 = 138, // RISC processor for Lattice FPGA architecture
242 EM_SE_C17 = 139, // Seiko Epson C17 family
243 EM_TI_C6000 = 140, // The Texas Instruments TMS320C6000 DSP family
244 EM_TI_C2000 = 141, // The Texas Instruments TMS320C2000 DSP family
245 EM_TI_C5500 = 142, // The Texas Instruments TMS320C55x DSP family
246 EM_MMDSP_PLUS = 160, // STMicroelectronics 64bit VLIW Data Signal Processor
247 EM_CYPRESS_M8C = 161, // Cypress M8C microprocessor
248 EM_R32C = 162, // Renesas R32C series microprocessors
249 EM_TRIMEDIA = 163, // NXP Semiconductors TriMedia architecture family
250 EM_HEXAGON = 164, // Qualcomm Hexagon processor
251 EM_8051 = 165, // Intel 8051 and variants
252 EM_STXP7X = 166, // STMicroelectronics STxP7x family of configurable
253 // and extensible RISC processors
254 EM_NDS32 = 167, // Andes Technology compact code size embedded RISC
255 // processor family
256 EM_ECOG1 = 168, // Cyan Technology eCOG1X family
257 EM_ECOG1X = 168, // Cyan Technology eCOG1X family
258 EM_MAXQ30 = 169, // Dallas Semiconductor MAXQ30 Core Micro-controllers
259 EM_XIMO16 = 170, // New Japan Radio (NJR) 16-bit DSP Processor
260 EM_MANIK = 171, // M2000 Reconfigurable RISC Microprocessor
261 EM_CRAYNV2 = 172, // Cray Inc. NV2 vector architecture
262 EM_RX = 173, // Renesas RX family
263 EM_METAG = 174, // Imagination Technologies META processor
264 // architecture
265 EM_MCST_ELBRUS = 175, // MCST Elbrus general purpose hardware architecture
266 EM_ECOG16 = 176, // Cyan Technology eCOG16 family
267 EM_CR16 = 177, // National Semiconductor CompactRISC CR16 16-bit
268 // microprocessor
269 EM_ETPU = 178, // Freescale Extended Time Processing Unit
270 EM_SLE9X = 179, // Infineon Technologies SLE9X core
271 EM_L10M = 180, // Intel L10M
272 EM_K10M = 181, // Intel K10M
273 EM_AARCH64 = 183, // ARM AArch64
274 EM_AVR32 = 185, // Atmel Corporation 32-bit microprocessor family
275 EM_STM8 = 186, // STMicroeletronics STM8 8-bit microcontroller
276 EM_TILE64 = 187, // Tilera TILE64 multicore architecture family
277 EM_TILEPRO = 188, // Tilera TILEPro multicore architecture family
278 EM_CUDA = 190, // NVIDIA CUDA architecture
279 EM_TILEGX = 191, // Tilera TILE-Gx multicore architecture family
280 EM_CLOUDSHIELD = 192, // CloudShield architecture family
281 EM_COREA_1ST = 193, // KIPO-KAIST Core-A 1st generation processor family
282 EM_COREA_2ND = 194, // KIPO-KAIST Core-A 2nd generation processor family
283 EM_ARC_COMPACT2 = 195, // Synopsys ARCompact V2
284 EM_OPEN8 = 196, // Open8 8-bit RISC soft processor core
285 EM_RL78 = 197, // Renesas RL78 family
286 EM_VIDEOCORE5 = 198, // Broadcom VideoCore V processor
287 EM_78KOR = 199, // Renesas 78KOR family
288 EM_56800EX = 200, // Freescale 56800EX Digital Signal Controller (DSC)
289 EM_BA1 = 201, // Beyond BA1 CPU architecture
290 EM_BA2 = 202, // Beyond BA2 CPU architecture
291 EM_XCORE = 203, // XMOS xCORE processor family
292 EM_MCHP_PIC = 204, // Microchip 8-bit PIC(r) family
293 EM_INTEL205 = 205, // Reserved by Intel
294 EM_INTEL206 = 206, // Reserved by Intel
295 EM_INTEL207 = 207, // Reserved by Intel
296 EM_INTEL208 = 208, // Reserved by Intel
297 EM_INTEL209 = 209, // Reserved by Intel
298 EM_KM32 = 210, // KM211 KM32 32-bit processor
299 EM_KMX32 = 211, // KM211 KMX32 32-bit processor
300 EM_KMX16 = 212, // KM211 KMX16 16-bit processor
301 EM_KMX8 = 213, // KM211 KMX8 8-bit processor
302 EM_KVARC = 214, // KM211 KVARC processor
303 EM_CDP = 215, // Paneve CDP architecture family
304 EM_COGE = 216, // Cognitive Smart Memory Processor
305 EM_COOL = 217, // iCelero CoolEngine
306 EM_NORC = 218, // Nanoradio Optimized RISC
307 EM_CSR_KALIMBA = 219, // CSR Kalimba architecture family
308 EM_AMDGPU = 224, // AMD GPU architecture
309 EM_RISCV = 243, // RISC-V
310 EM_LANAI = 244, // Lanai 32-bit processor
311 EM_BPF = 247, // Linux kernel bpf virtual machine
312
313 // A request has been made to the maintainer of the official registry for
314 // such numbers for an official value for WebAssembly. As soon as one is
315 // allocated, this enum will be updated to use it.
316 EM_WEBASSEMBLY = 0x4157, // WebAssembly architecture
317 };
318
319 // Object file classes.
320 enum {
321 ELFCLASSNONE = 0,
322 ELFCLASS32 = 1, // 32-bit object file
323 ELFCLASS64 = 2 // 64-bit object file
324 };
325
326 // Object file byte orderings.
327 enum {
328 ELFDATANONE = 0, // Invalid data encoding.
329 ELFDATA2LSB = 1, // Little-endian object file
330 ELFDATA2MSB = 2 // Big-endian object file
331 };
332
333 // OS ABI identification.
334 enum {
335 ELFOSABI_NONE = 0, // UNIX System V ABI
336 ELFOSABI_HPUX = 1, // HP-UX operating system
337 ELFOSABI_NETBSD = 2, // NetBSD
338 ELFOSABI_GNU = 3, // GNU/Linux
339 ELFOSABI_LINUX = 3, // Historical alias for ELFOSABI_GNU.
340 ELFOSABI_HURD = 4, // GNU/Hurd
341 ELFOSABI_SOLARIS = 6, // Solaris
342 ELFOSABI_AIX = 7, // AIX
343 ELFOSABI_IRIX = 8, // IRIX
344 ELFOSABI_FREEBSD = 9, // FreeBSD
345 ELFOSABI_TRU64 = 10, // TRU64 UNIX
346 ELFOSABI_MODESTO = 11, // Novell Modesto
347 ELFOSABI_OPENBSD = 12, // OpenBSD
348 ELFOSABI_OPENVMS = 13, // OpenVMS
349 ELFOSABI_NSK = 14, // Hewlett-Packard Non-Stop Kernel
350 ELFOSABI_AROS = 15, // AROS
351 ELFOSABI_FENIXOS = 16, // FenixOS
352 ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
353 ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
354 ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
355 ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000
356 ELFOSABI_ARM = 97, // ARM
357 ELFOSABI_STANDALONE = 255 // Standalone (embedded) application
358 };
359
360 #define ELF_RELOC(name, value) name = value,
361
362 // X86_64 relocations.
363 enum {
364 #include "ELFRelocs/x86_64.def"
365 };
366
367 // i386 relocations.
368 enum {
369 #include "ELFRelocs/i386.def"
370 };
371
372 // ELF Relocation types for PPC32
373 enum {
374 #include "ELFRelocs/PowerPC.def"
375 };
376
377 // Specific e_flags for PPC64
378 enum {
379 // e_flags bits specifying ABI:
380 // 1 for original ABI using function descriptors,
381 // 2 for revised ABI without function descriptors,
382 // 0 for unspecified or not using any features affected by the differences.
383 EF_PPC64_ABI = 3
384 };
385
386 // Special values for the st_other field in the symbol table entry for PPC64.
387 enum {
388 STO_PPC64_LOCAL_BIT = 5,
389 STO_PPC64_LOCAL_MASK = (7 << STO_PPC64_LOCAL_BIT)
390 };
391 static inline int64_t decodePPC64LocalEntryOffset(unsigned Other) {
392 unsigned Val = (Other & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT;
393 return ((1 << Val) >> 2) << 2;
394 }
395 static inline unsigned encodePPC64LocalEntryOffset(int64_t Offset) {
396 unsigned Val =
397 (Offset >= 4 * 4 ? (Offset >= 8 * 4 ? (Offset >= 16 * 4 ? 6 : 5) : 4)
398 : (Offset >= 2 * 4 ? 3 : (Offset >= 1 * 4 ? 2 : 0)));
399 return Val << STO_PPC64_LOCAL_BIT;
400 }
401
402 // ELF Relocation types for PPC64
403 enum {
404 #include "ELFRelocs/PowerPC64.def"
405 };
406
407 // ELF Relocation types for AArch64
408 enum {
409 #include "ELFRelocs/AArch64.def"
410 };
411
412 // ARM Specific e_flags
413 enum : unsigned {
414 EF_ARM_SOFT_FLOAT = 0x00000200U,
415 EF_ARM_VFP_FLOAT = 0x00000400U,
416 EF_ARM_EABI_UNKNOWN = 0x00000000U,
417 EF_ARM_EABI_VER1 = 0x01000000U,
418 EF_ARM_EABI_VER2 = 0x02000000U,
419 EF_ARM_EABI_VER3 = 0x03000000U,
420 EF_ARM_EABI_VER4 = 0x04000000U,
421 EF_ARM_EABI_VER5 = 0x05000000U,
422 EF_ARM_EABIMASK = 0xFF000000U
423 };
424
425 // ELF Relocation types for ARM
426 enum {
427 #include "ELFRelocs/ARM.def"
428 };
429
430 // AVR specific e_flags
431 enum : unsigned {
432 EF_AVR_ARCH_AVR1 = 1,
433 EF_AVR_ARCH_AVR2 = 2,
434 EF_AVR_ARCH_AVR25 = 25,
435 EF_AVR_ARCH_AVR3 = 3,
436 EF_AVR_ARCH_AVR31 = 31,
437 EF_AVR_ARCH_AVR35 = 35,
438 EF_AVR_ARCH_AVR4 = 4,
439 EF_AVR_ARCH_AVR5 = 5,
440 EF_AVR_ARCH_AVR51 = 51,
441 EF_AVR_ARCH_AVR6 = 6,
442 EF_AVR_ARCH_AVRTINY = 100,
443 EF_AVR_ARCH_XMEGA1 = 101,
444 EF_AVR_ARCH_XMEGA2 = 102,
445 EF_AVR_ARCH_XMEGA3 = 103,
446 EF_AVR_ARCH_XMEGA4 = 104,
447 EF_AVR_ARCH_XMEGA5 = 105,
448 EF_AVR_ARCH_XMEGA6 = 106,
449 EF_AVR_ARCH_XMEGA7 = 107
450 };
451
452 // ELF Relocation types for AVR
453 enum {
454 #include "ELFRelocs/AVR.def"
455 };
456
457 // Mips Specific e_flags
458 enum : unsigned {
459 EF_MIPS_NOREORDER = 0x00000001, // Don't reorder instructions
460 EF_MIPS_PIC = 0x00000002, // Position independent code
461 EF_MIPS_CPIC = 0x00000004, // Call object with Position independent code
462 EF_MIPS_ABI2 = 0x00000020, // File uses N32 ABI
463 EF_MIPS_32BITMODE = 0x00000100, // Code compiled for a 64-bit machine
464 // in 32-bit mode
465 EF_MIPS_FP64 = 0x00000200, // Code compiled for a 32-bit machine
466 // but uses 64-bit FP registers
467 EF_MIPS_NAN2008 = 0x00000400, // Uses IEE 754-2008 NaN encoding
468
469 // ABI flags
470 EF_MIPS_ABI_O32 = 0x00001000, // This file follows the first MIPS 32 bit ABI
471 EF_MIPS_ABI_O64 = 0x00002000, // O32 ABI extended for 64-bit architecture.
472 EF_MIPS_ABI_EABI32 = 0x00003000, // EABI in 32 bit mode.
473 EF_MIPS_ABI_EABI64 = 0x00004000, // EABI in 64 bit mode.
474 EF_MIPS_ABI = 0x0000f000, // Mask for selecting EF_MIPS_ABI_ variant.
475
476 // MIPS machine variant
477 EF_MIPS_MACH_NONE = 0x00000000, // A standard MIPS implementation.
478 EF_MIPS_MACH_3900 = 0x00810000, // Toshiba R3900
479 EF_MIPS_MACH_4010 = 0x00820000, // LSI R4010
480 EF_MIPS_MACH_4100 = 0x00830000, // NEC VR4100
481 EF_MIPS_MACH_4650 = 0x00850000, // MIPS R4650
482 EF_MIPS_MACH_4120 = 0x00870000, // NEC VR4120
483 EF_MIPS_MACH_4111 = 0x00880000, // NEC VR4111/VR4181
484 EF_MIPS_MACH_SB1 = 0x008a0000, // Broadcom SB-1
485 EF_MIPS_MACH_OCTEON = 0x008b0000, // Cavium Networks Octeon
486 EF_MIPS_MACH_XLR = 0x008c0000, // RMI Xlr
487 EF_MIPS_MACH_OCTEON2 = 0x008d0000, // Cavium Networks Octeon2
488 EF_MIPS_MACH_OCTEON3 = 0x008e0000, // Cavium Networks Octeon3
489 EF_MIPS_MACH_5400 = 0x00910000, // NEC VR5400
490 EF_MIPS_MACH_5900 = 0x00920000, // MIPS R5900
491 EF_MIPS_MACH_5500 = 0x00980000, // NEC VR5500
492 EF_MIPS_MACH_9000 = 0x00990000, // Unknown
493 EF_MIPS_MACH_LS2E = 0x00a00000, // ST Microelectronics Loongson 2E
494 EF_MIPS_MACH_LS2F = 0x00a10000, // ST Microelectronics Loongson 2F
495 EF_MIPS_MACH_LS3A = 0x00a20000, // Loongson 3A
496 EF_MIPS_MACH = 0x00ff0000, // EF_MIPS_MACH_xxx selection mask
497
498 // ARCH_ASE
499 EF_MIPS_MICROMIPS = 0x02000000, // microMIPS
500 EF_MIPS_ARCH_ASE_M16 = 0x04000000, // Has Mips-16 ISA extensions
501 EF_MIPS_ARCH_ASE_MDMX = 0x08000000, // Has MDMX multimedia extensions
502 EF_MIPS_ARCH_ASE = 0x0f000000, // Mask for EF_MIPS_ARCH_ASE_xxx flags
503
504 // ARCH
505 EF_MIPS_ARCH_1 = 0x00000000, // MIPS1 instruction set
506 EF_MIPS_ARCH_2 = 0x10000000, // MIPS2 instruction set
507 EF_MIPS_ARCH_3 = 0x20000000, // MIPS3 instruction set
508 EF_MIPS_ARCH_4 = 0x30000000, // MIPS4 instruction set
509 EF_MIPS_ARCH_5 = 0x40000000, // MIPS5 instruction set
510 EF_MIPS_ARCH_32 = 0x50000000, // MIPS32 instruction set per linux not elf.h
511 EF_MIPS_ARCH_64 = 0x60000000, // MIPS64 instruction set per linux not elf.h
512 EF_MIPS_ARCH_32R2 = 0x70000000, // mips32r2, mips32r3, mips32r5
513 EF_MIPS_ARCH_64R2 = 0x80000000, // mips64r2, mips64r3, mips64r5
514 EF_MIPS_ARCH_32R6 = 0x90000000, // mips32r6
515 EF_MIPS_ARCH_64R6 = 0xa0000000, // mips64r6
516 EF_MIPS_ARCH = 0xf0000000 // Mask for applying EF_MIPS_ARCH_ variant
517 };
518
519 // ELF Relocation types for Mips
520 enum {
521 #include "ELFRelocs/Mips.def"
522 };
523
524 // Special values for the st_other field in the symbol table entry for MIPS.
525 enum {
526 STO_MIPS_OPTIONAL = 0x04, // Symbol whose definition is optional
527 STO_MIPS_PLT = 0x08, // PLT entry related dynamic table record
528 STO_MIPS_PIC = 0x20, // PIC func in an object mixes PIC/non-PIC
529 STO_MIPS_MICROMIPS = 0x80, // MIPS Specific ISA for MicroMips
530 STO_MIPS_MIPS16 = 0xf0 // MIPS Specific ISA for Mips16
531 };
532
533 // .MIPS.options section descriptor kinds
534 enum {
535 ODK_NULL = 0, // Undefined
536 ODK_REGINFO = 1, // Register usage information
537 ODK_EXCEPTIONS = 2, // Exception processing options
538 ODK_PAD = 3, // Section padding options
539 ODK_HWPATCH = 4, // Hardware patches applied
540 ODK_FILL = 5, // Linker fill value
541 ODK_TAGS = 6, // Space for tool identification
542 ODK_HWAND = 7, // Hardware AND patches applied
543 ODK_HWOR = 8, // Hardware OR patches applied
544 ODK_GP_GROUP = 9, // GP group to use for text/data sections
545 ODK_IDENT = 10, // ID information
546 ODK_PAGESIZE = 11 // Page size information
547 };
548
549 // Hexagon-specific e_flags
550 enum {
551 // Object processor version flags, bits[11:0]
552 EF_HEXAGON_MACH_V2 = 0x00000001, // Hexagon V2
553 EF_HEXAGON_MACH_V3 = 0x00000002, // Hexagon V3
554 EF_HEXAGON_MACH_V4 = 0x00000003, // Hexagon V4
555 EF_HEXAGON_MACH_V5 = 0x00000004, // Hexagon V5
556 EF_HEXAGON_MACH_V55 = 0x00000005, // Hexagon V55
557 EF_HEXAGON_MACH_V60 = 0x00000060, // Hexagon V60
558 EF_HEXAGON_MACH_V62 = 0x00000062, // Hexagon V62
559
560 // Highest ISA version flags
561 EF_HEXAGON_ISA_MACH = 0x00000000, // Same as specified in bits[11:0]
562 // of e_flags
563 EF_HEXAGON_ISA_V2 = 0x00000010, // Hexagon V2 ISA
564 EF_HEXAGON_ISA_V3 = 0x00000020, // Hexagon V3 ISA
565 EF_HEXAGON_ISA_V4 = 0x00000030, // Hexagon V4 ISA
566 EF_HEXAGON_ISA_V5 = 0x00000040, // Hexagon V5 ISA
567 EF_HEXAGON_ISA_V55 = 0x00000050, // Hexagon V55 ISA
568 EF_HEXAGON_ISA_V60 = 0x00000060, // Hexagon V60 ISA
569 EF_HEXAGON_ISA_V62 = 0x00000062, // Hexagon V62 ISA
570 };
571
572 // Hexagon-specific section indexes for common small data
573 enum {
574 SHN_HEXAGON_SCOMMON = 0xff00, // Other access sizes
575 SHN_HEXAGON_SCOMMON_1 = 0xff01, // Byte-sized access
576 SHN_HEXAGON_SCOMMON_2 = 0xff02, // Half-word-sized access
577 SHN_HEXAGON_SCOMMON_4 = 0xff03, // Word-sized access
578 SHN_HEXAGON_SCOMMON_8 = 0xff04 // Double-word-size access
579 };
580
581 // ELF Relocation types for Hexagon
582 enum {
583 #include "ELFRelocs/Hexagon.def"
584 };
585
586 // ELF Relocation type for Lanai.
587 enum {
588 #include "ELFRelocs/Lanai.def"
589 };
590
591 // ELF Relocation types for RISC-V
592 enum {
593 #include "ELFRelocs/RISCV.def"
594 };
595
596 // ELF Relocation types for S390/zSeries
597 enum {
598 #include "ELFRelocs/SystemZ.def"
599 };
600
601 // ELF Relocation type for Sparc.
602 enum {
603 #include "ELFRelocs/Sparc.def"
604 };
605
606 // ELF Relocation types for WebAssembly
607 enum {
608 #include "ELFRelocs/WebAssembly.def"
609 };
610
611 // ELF Relocation types for AMDGPU
612 enum {
613 #include "ELFRelocs/AMDGPU.def"
614 };
615
616 // ELF Relocation types for BPF
617 enum {
618 #include "ELFRelocs/BPF.def"
619 };
620
621 #undef ELF_RELOC
622
623 // Section header.
624 struct Elf32_Shdr {
625 Elf32_Word sh_name; // Section name (index into string table)
626 Elf32_Word sh_type; // Section type (SHT_*)
627 Elf32_Word sh_flags; // Section flags (SHF_*)
628 Elf32_Addr sh_addr; // Address where section is to be loaded
629 Elf32_Off sh_offset; // File offset of section data, in bytes
630 Elf32_Word sh_size; // Size of section, in bytes
631 Elf32_Word sh_link; // Section type-specific header table index link
632 Elf32_Word sh_info; // Section type-specific extra information
633 Elf32_Word sh_addralign; // Section address alignment
634 Elf32_Word sh_entsize; // Size of records contained within the section
635 };
636
637 // Section header for ELF64 - same fields as ELF32, different types.
638 struct Elf64_Shdr {
639 Elf64_Word sh_name;
640 Elf64_Word sh_type;
641 Elf64_Xword sh_flags;
642 Elf64_Addr sh_addr;
643 Elf64_Off sh_offset;
644 Elf64_Xword sh_size;
645 Elf64_Word sh_link;
646 Elf64_Word sh_info;
647 Elf64_Xword sh_addralign;
648 Elf64_Xword sh_entsize;
649 };
650
651 // Special section indices.
652 enum {
653 SHN_UNDEF = 0, // Undefined, missing, irrelevant, or meaningless
654 SHN_LORESERVE = 0xff00, // Lowest reserved index
655 SHN_LOPROC = 0xff00, // Lowest processor-specific index
656 SHN_HIPROC = 0xff1f, // Highest processor-specific index
657 SHN_LOOS = 0xff20, // Lowest operating system-specific index
658 SHN_HIOS = 0xff3f, // Highest operating system-specific index
659 SHN_ABS = 0xfff1, // Symbol has absolute value; does not need relocation
660 SHN_COMMON = 0xfff2, // FORTRAN COMMON or C external global variables
661 SHN_XINDEX = 0xffff, // Mark that the index is >= SHN_LORESERVE
662 SHN_HIRESERVE = 0xffff // Highest reserved index
663 };
664
665 // Section types.
666 enum : unsigned {
667 SHT_NULL = 0, // No associated section (inactive entry).
668 SHT_PROGBITS = 1, // Program-defined contents.
669 SHT_SYMTAB = 2, // Symbol table.
670 SHT_STRTAB = 3, // String table.
671 SHT_RELA = 4, // Relocation entries; explicit addends.
672 SHT_HASH = 5, // Symbol hash table.
673 SHT_DYNAMIC = 6, // Information for dynamic linking.
674 SHT_NOTE = 7, // Information about the file.
675 SHT_NOBITS = 8, // Data occupies no space in the file.
676 SHT_REL = 9, // Relocation entries; no explicit addends.
677 SHT_SHLIB = 10, // Reserved.
678 SHT_DYNSYM = 11, // Symbol table.
679 SHT_INIT_ARRAY = 14, // Pointers to initialization functions.
680 SHT_FINI_ARRAY = 15, // Pointers to termination functions.
681 SHT_PREINIT_ARRAY = 16, // Pointers to pre-init functions.
682 SHT_GROUP = 17, // Section group.
683 SHT_SYMTAB_SHNDX = 18, // Indices for SHN_XINDEX entries.
684 SHT_LOOS = 0x60000000, // Lowest operating system-specific type.
685 SHT_GNU_ATTRIBUTES = 0x6ffffff5, // Object attributes.
686 SHT_GNU_HASH = 0x6ffffff6, // GNU-style hash table.
687 SHT_GNU_verdef = 0x6ffffffd, // GNU version definitions.
688 SHT_GNU_verneed = 0x6ffffffe, // GNU version references.
689 SHT_GNU_versym = 0x6fffffff, // GNU symbol versions table.
690 SHT_HIOS = 0x6fffffff, // Highest operating system-specific type.
691 SHT_LOPROC = 0x70000000, // Lowest processor arch-specific type.
692 // Fixme: All this is duplicated in MCSectionELF. Why??
693 // Exception Index table
694 SHT_ARM_EXIDX = 0x70000001U,
695 // BPABI DLL dynamic linking pre-emption map
696 SHT_ARM_PREEMPTMAP = 0x70000002U,
697 // Object file compatibility attributes
698 SHT_ARM_ATTRIBUTES = 0x70000003U,
699 SHT_ARM_DEBUGOVERLAY = 0x70000004U,
700 SHT_ARM_OVERLAYSECTION = 0x70000005U,
701 SHT_HEX_ORDERED = 0x70000000, // Link editor is to sort the entries in
702 // this section based on their sizes
703 SHT_X86_64_UNWIND = 0x70000001, // Unwind information
704
705 SHT_MIPS_REGINFO = 0x70000006, // Register usage information
706 SHT_MIPS_OPTIONS = 0x7000000d, // General options
707 SHT_MIPS_DWARF = 0x7000001e, // DWARF debugging section.
708 SHT_MIPS_ABIFLAGS = 0x7000002a, // ABI information.
709
710 SHT_HIPROC = 0x7fffffff, // Highest processor arch-specific type.
711 SHT_LOUSER = 0x80000000, // Lowest type reserved for applications.
712 SHT_HIUSER = 0xffffffff // Highest type reserved for applications.
713 };
714
715 // Section flags.
716 enum : unsigned {
717 // Section data should be writable during execution.
718 SHF_WRITE = 0x1,
719
720 // Section occupies memory during program execution.
721 SHF_ALLOC = 0x2,
722
723 // Section contains executable machine instructions.
724 SHF_EXECINSTR = 0x4,
725
726 // The data in this section may be merged.
727 SHF_MERGE = 0x10,
728
729 // The data in this section is null-terminated strings.
730 SHF_STRINGS = 0x20,
731
732 // A field in this section holds a section header table index.
733 SHF_INFO_LINK = 0x40U,
734
735 // Adds special ordering requirements for link editors.
736 SHF_LINK_ORDER = 0x80U,
737
738 // This section requires special OS-specific processing to avoid incorrect
739 // behavior.
740 SHF_OS_NONCONFORMING = 0x100U,
741
742 // This section is a member of a section group.
743 SHF_GROUP = 0x200U,
744
745 // This section holds Thread-Local Storage.
746 SHF_TLS = 0x400U,
747
748 // Identifies a section containing compressed data.
749 SHF_COMPRESSED = 0x800U,
750
751 // This section is excluded from the final executable or shared library.
752 SHF_EXCLUDE = 0x80000000U,
753
754 // Start of target-specific flags.
755
756 SHF_MASKOS = 0x0ff00000,
757
758 // Bits indicating processor-specific flags.
759 SHF_MASKPROC = 0xf0000000,
760
761 /// All sections with the "d" flag are grouped together by the linker to form
762 /// the data section and the dp register is set to the start of the section by
763 /// the boot code.
764 XCORE_SHF_DP_SECTION = 0x10000000,
765
766 /// All sections with the "c" flag are grouped together by the linker to form
767 /// the constant pool and the cp register is set to the start of the constant
768 /// pool by the boot code.
769 XCORE_SHF_CP_SECTION = 0x20000000,
770
771 // If an object file section does not have this flag set, then it may not hold
772 // more than 2GB and can be freely referred to in objects using smaller code
773 // models. Otherwise, only objects using larger code models can refer to them.
774 // For example, a medium code model object can refer to data in a section that
775 // sets this flag besides being able to refer to data in a section that does
776 // not set it; likewise, a small code model object can refer only to code in a
777 // section that does not set this flag.
778 SHF_X86_64_LARGE = 0x10000000,
779
780 // All sections with the GPREL flag are grouped into a global data area
781 // for faster accesses
782 SHF_HEX_GPREL = 0x10000000,
783
784 // Section contains text/data which may be replicated in other sections.
785 // Linker must retain only one copy.
786 SHF_MIPS_NODUPES = 0x01000000,
787
788 // Linker must generate implicit hidden weak names.
789 SHF_MIPS_NAMES = 0x02000000,
790
791 // Section data local to process.
792 SHF_MIPS_LOCAL = 0x04000000,
793
794 // Do not strip this section.
795 SHF_MIPS_NOSTRIP = 0x08000000,
796
797 // Section must be part of global data area.
798 SHF_MIPS_GPREL = 0x10000000,
799
800 // This section should be merged.
801 SHF_MIPS_MERGE = 0x20000000,
802
803 // Address size to be inferred from section entry size.
804 SHF_MIPS_ADDR = 0x40000000,
805
806 // Section data is string data by default.
807 SHF_MIPS_STRING = 0x80000000,
808
809 // Make code section unreadable when in execute-only mode
810 SHF_ARM_PURECODE = 0x20000000
811 };
812
813 // Section Group Flags
814 enum : unsigned {
815 GRP_COMDAT = 0x1,
816 GRP_MASKOS = 0x0ff00000,
817 GRP_MASKPROC = 0xf0000000
818 };
819
820 // Symbol table entries for ELF32.
821 struct Elf32_Sym {
822 Elf32_Word st_name; // Symbol name (index into string table)
823 Elf32_Addr st_value; // Value or address associated with the symbol
824 Elf32_Word st_size; // Size of the symbol
825 unsigned char st_info; // Symbol's type and binding attributes
826 unsigned char st_other; // Must be zero; reserved
827 Elf32_Half st_shndx; // Which section (header table index) it's defined in
828
829 // These accessors and mutators correspond to the ELF32_ST_BIND,
830 // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification:
831 unsigned char getBinding() const { return st_info >> 4; }
832 unsigned char getType() const { return st_info & 0x0f; }
833 void setBinding(unsigned char b) { setBindingAndType(b, getType()); }
834 void setType(unsigned char t) { setBindingAndType(getBinding(), t); }
835 void setBindingAndType(unsigned char b, unsigned char t) {
836 st_info = (b << 4) + (t & 0x0f);
837 }
838 };
839
840 // Symbol table entries for ELF64.
841 struct Elf64_Sym {
842 Elf64_Word st_name; // Symbol name (index into string table)
843 unsigned char st_info; // Symbol's type and binding attributes
844 unsigned char st_other; // Must be zero; reserved
845 Elf64_Half st_shndx; // Which section (header tbl index) it's defined in
846 Elf64_Addr st_value; // Value or address associated with the symbol
847 Elf64_Xword st_size; // Size of the symbol
848
849 // These accessors and mutators are identical to those defined for ELF32
850 // symbol table entries.
851 unsigned char getBinding() const { return st_info >> 4; }
852 unsigned char getType() const { return st_info & 0x0f; }
853 void setBinding(unsigned char b) { setBindingAndType(b, getType()); }
854 void setType(unsigned char t) { setBindingAndType(getBinding(), t); }
855 void setBindingAndType(unsigned char b, unsigned char t) {
856 st_info = (b << 4) + (t & 0x0f);
857 }
858 };
859
860 // The size (in bytes) of symbol table entries.
861 enum {
862 SYMENTRY_SIZE32 = 16, // 32-bit symbol entry size
863 SYMENTRY_SIZE64 = 24 // 64-bit symbol entry size.
864 };
865
866 // Symbol bindings.
867 enum {
868 STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def
869 STB_GLOBAL = 1, // Global symbol, visible to all object files being combined
870 STB_WEAK = 2, // Weak symbol, like global but lower-precedence
871 STB_GNU_UNIQUE = 10,
872 STB_LOOS = 10, // Lowest operating system-specific binding type
873 STB_HIOS = 12, // Highest operating system-specific binding type
874 STB_LOPROC = 13, // Lowest processor-specific binding type
875 STB_HIPROC = 15 // Highest processor-specific binding type
876 };
877
878 // Symbol types.
879 enum {
880 STT_NOTYPE = 0, // Symbol's type is not specified
881 STT_OBJECT = 1, // Symbol is a data object (variable, array, etc.)
882 STT_FUNC = 2, // Symbol is executable code (function, etc.)
883 STT_SECTION = 3, // Symbol refers to a section
884 STT_FILE = 4, // Local, absolute symbol that refers to a file
885 STT_COMMON = 5, // An uninitialized common block
886 STT_TLS = 6, // Thread local data object
887 STT_GNU_IFUNC = 10, // GNU indirect function
888 STT_LOOS = 10, // Lowest operating system-specific symbol type
889 STT_HIOS = 12, // Highest operating system-specific symbol type
890 STT_LOPROC = 13, // Lowest processor-specific symbol type
891 STT_HIPROC = 15, // Highest processor-specific symbol type
892
893 // AMDGPU symbol types
894 STT_AMDGPU_HSA_KERNEL = 10
895 };
896
897 enum {
898 STV_DEFAULT = 0, // Visibility is specified by binding type
899 STV_INTERNAL = 1, // Defined by processor supplements
900 STV_HIDDEN = 2, // Not visible to other components
901 STV_PROTECTED = 3 // Visible in other components but not preemptable
902 };
903
904 // Symbol number.
905 enum { STN_UNDEF = 0 };
906
907 // Special relocation symbols used in the MIPS64 ELF relocation entries
908 enum {
909 RSS_UNDEF = 0, // None
910 RSS_GP = 1, // Value of gp
911 RSS_GP0 = 2, // Value of gp used to create object being relocated
912 RSS_LOC = 3 // Address of location being relocated
913 };
914
915 // Relocation entry, without explicit addend.
916 struct Elf32_Rel {
917 Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
918 Elf32_Word r_info; // Symbol table index and type of relocation to apply
919
920 // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
921 // and ELF32_R_INFO macros defined in the ELF specification:
922 Elf32_Word getSymbol() const { return (r_info >> 8); }
923 unsigned char getType() const { return (unsigned char)(r_info & 0x0ff); }
924 void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); }
925 void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); }
926 void setSymbolAndType(Elf32_Word s, unsigned char t) {
927 r_info = (s << 8) + t;
928 }
929 };
930
931 // Relocation entry with explicit addend.
932 struct Elf32_Rela {
933 Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
934 Elf32_Word r_info; // Symbol table index and type of relocation to apply
935 Elf32_Sword r_addend; // Compute value for relocatable field by adding this
936
937 // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
938 // and ELF32_R_INFO macros defined in the ELF specification:
939 Elf32_Word getSymbol() const { return (r_info >> 8); }
940 unsigned char getType() const { return (unsigned char)(r_info & 0x0ff); }
941 void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); }
942 void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); }
943 void setSymbolAndType(Elf32_Word s, unsigned char t) {
944 r_info = (s << 8) + t;
945 }
946 };
947
948 // Relocation entry, without explicit addend.
949 struct Elf64_Rel {
950 Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr).
951 Elf64_Xword r_info; // Symbol table index and type of relocation to apply.
952
953 // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE,
954 // and ELF64_R_INFO macros defined in the ELF specification:
955 Elf64_Word getSymbol() const { return (r_info >> 32); }
956 Elf64_Word getType() const { return (Elf64_Word)(r_info & 0xffffffffL); }
957 void setSymbol(Elf64_Word s) { setSymbolAndType(s, getType()); }
958 void setType(Elf64_Word t) { setSymbolAndType(getSymbol(), t); }
959 void setSymbolAndType(Elf64_Word s, Elf64_Word t) {
960 r_info = ((Elf64_Xword)s << 32) + (t & 0xffffffffL);
961 }
962 };
963
964 // Relocation entry with explicit addend.
965 struct Elf64_Rela {
966 Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr).
967 Elf64_Xword r_info; // Symbol table index and type of relocation to apply.
968 Elf64_Sxword r_addend; // Compute value for relocatable field by adding this.
969
970 // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE,
971 // and ELF64_R_INFO macros defined in the ELF specification:
972 Elf64_Word getSymbol() const { return (r_info >> 32); }
973 Elf64_Word getType() const { return (Elf64_Word)(r_info & 0xffffffffL); }
974 void setSymbol(Elf64_Word s) { setSymbolAndType(s, getType()); }
975 void setType(Elf64_Word t) { setSymbolAndType(getSymbol(), t); }
976 void setSymbolAndType(Elf64_Word s, Elf64_Word t) {
977 r_info = ((Elf64_Xword)s << 32) + (t & 0xffffffffL);
978 }
979 };
980
981 // Program header for ELF32.
982 struct Elf32_Phdr {
983 Elf32_Word p_type; // Type of segment
984 Elf32_Off p_offset; // File offset where segment is located, in bytes
985 Elf32_Addr p_vaddr; // Virtual address of beginning of segment
986 Elf32_Addr p_paddr; // Physical address of beginning of segment (OS-specific)
987 Elf32_Word p_filesz; // Num. of bytes in file image of segment (may be zero)
988 Elf32_Word p_memsz; // Num. of bytes in mem image of segment (may be zero)
989 Elf32_Word p_flags; // Segment flags
990 Elf32_Word p_align; // Segment alignment constraint
991 };
992
993 // Program header for ELF64.
994 struct Elf64_Phdr {
995 Elf64_Word p_type; // Type of segment
996 Elf64_Word p_flags; // Segment flags
997 Elf64_Off p_offset; // File offset where segment is located, in bytes
998 Elf64_Addr p_vaddr; // Virtual address of beginning of segment
999 Elf64_Addr p_paddr; // Physical addr of beginning of segment (OS-specific)
1000 Elf64_Xword p_filesz; // Num. of bytes in file image of segment (may be zero)
1001 Elf64_Xword p_memsz; // Num. of bytes in mem image of segment (may be zero)
1002 Elf64_Xword p_align; // Segment alignment constraint
1003 };
1004
1005 // Segment types.
1006 enum {
1007 PT_NULL = 0, // Unused segment.
1008 PT_LOAD = 1, // Loadable segment.
1009 PT_DYNAMIC = 2, // Dynamic linking information.
1010 PT_INTERP = 3, // Interpreter pathname.
1011 PT_NOTE = 4, // Auxiliary information.
1012 PT_SHLIB = 5, // Reserved.
1013 PT_PHDR = 6, // The program header table itself.
1014 PT_TLS = 7, // The thread-local storage template.
1015 PT_LOOS = 0x60000000, // Lowest operating system-specific pt entry type.
1016 PT_HIOS = 0x6fffffff, // Highest operating system-specific pt entry type.
1017 PT_LOPROC = 0x70000000, // Lowest processor-specific program hdr entry type.
1018 PT_HIPROC = 0x7fffffff, // Highest processor-specific program hdr entry type.
1019
1020 // x86-64 program header types.
1021 // These all contain stack unwind tables.
1022 PT_GNU_EH_FRAME = 0x6474e550,
1023 PT_SUNW_EH_FRAME = 0x6474e550,
1024 PT_SUNW_UNWIND = 0x6464e550,
1025
1026 PT_GNU_STACK = 0x6474e551, // Indicates stack executability.
1027 PT_GNU_RELRO = 0x6474e552, // Read-only after relocation.
1028
1029 PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data.
1030 PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations.
1031 PT_OPENBSD_BOOTDATA = 0x65a41be6, // Section for boot arguments.
1032
1033 // ARM program header types.
1034 PT_ARM_ARCHEXT = 0x70000000, // Platform architecture compatibility info
1035 // These all contain stack unwind tables.
1036 PT_ARM_EXIDX = 0x70000001,
1037 PT_ARM_UNWIND = 0x70000001,
1038
1039 // MIPS program header types.
1040 PT_MIPS_REGINFO = 0x70000000, // Register usage information.
1041 PT_MIPS_RTPROC = 0x70000001, // Runtime procedure table.
1042 PT_MIPS_OPTIONS = 0x70000002, // Options segment.
1043 PT_MIPS_ABIFLAGS = 0x70000003, // Abiflags segment.
1044
1045 // WebAssembly program header types.
1046 PT_WEBASSEMBLY_FUNCTIONS = PT_LOPROC + 0, // Function definitions.
1047 };
1048
1049 // Segment flag bits.
1050 enum : unsigned {
1051 PF_X = 1, // Execute
1052 PF_W = 2, // Write
1053 PF_R = 4, // Read
1054 PF_MASKOS = 0x0ff00000, // Bits for operating system-specific semantics.
1055 PF_MASKPROC = 0xf0000000 // Bits for processor-specific semantics.
1056 };
1057
1058 // Dynamic table entry for ELF32.
1059 struct Elf32_Dyn {
1060 Elf32_Sword d_tag; // Type of dynamic table entry.
1061 union {
1062 Elf32_Word d_val; // Integer value of entry.
1063 Elf32_Addr d_ptr; // Pointer value of entry.
1064 } d_un;
1065 };
1066
1067 // Dynamic table entry for ELF64.
1068 struct Elf64_Dyn {
1069 Elf64_Sxword d_tag; // Type of dynamic table entry.
1070 union {
1071 Elf64_Xword d_val; // Integer value of entry.
1072 Elf64_Addr d_ptr; // Pointer value of entry.
1073 } d_un;
1074 };
1075
1076 // Dynamic table entry tags.
1077 enum {
1078 DT_NULL = 0, // Marks end of dynamic array.
1079 DT_NEEDED = 1, // String table offset of needed library.
1080 DT_PLTRELSZ = 2, // Size of relocation entries in PLT.
1081 DT_PLTGOT = 3, // Address associated with linkage table.
1082 DT_HASH = 4, // Address of symbolic hash table.
1083 DT_STRTAB = 5, // Address of dynamic string table.
1084 DT_SYMTAB = 6, // Address of dynamic symbol table.
1085 DT_RELA = 7, // Address of relocation table (Rela entries).
1086 DT_RELASZ = 8, // Size of Rela relocation table.
1087 DT_RELAENT = 9, // Size of a Rela relocation entry.
1088 DT_STRSZ = 10, // Total size of the string table.
1089 DT_SYMENT = 11, // Size of a symbol table entry.
1090 DT_INIT = 12, // Address of initialization function.
1091 DT_FINI = 13, // Address of termination function.
1092 DT_SONAME = 14, // String table offset of a shared objects name.
1093 DT_RPATH = 15, // String table offset of library search path.
1094 DT_SYMBOLIC = 16, // Changes symbol resolution algorithm.
1095 DT_REL = 17, // Address of relocation table (Rel entries).
1096 DT_RELSZ = 18, // Size of Rel relocation table.
1097 DT_RELENT = 19, // Size of a Rel relocation entry.
1098 DT_PLTREL = 20, // Type of relocation entry used for linking.
1099 DT_DEBUG = 21, // Reserved for debugger.
1100 DT_TEXTREL = 22, // Relocations exist for non-writable segments.
1101 DT_JMPREL = 23, // Address of relocations associated with PLT.
1102 DT_BIND_NOW = 24, // Process all relocations before execution.
1103 DT_INIT_ARRAY = 25, // Pointer to array of initialization functions.
1104 DT_FINI_ARRAY = 26, // Pointer to array of termination functions.
1105 DT_INIT_ARRAYSZ = 27, // Size of DT_INIT_ARRAY.
1106 DT_FINI_ARRAYSZ = 28, // Size of DT_FINI_ARRAY.
1107 DT_RUNPATH = 29, // String table offset of lib search path.
1108 DT_FLAGS = 30, // Flags.
1109 DT_ENCODING = 32, // Values from here to DT_LOOS follow the rules
1110 // for the interpretation of the d_un union.
1111
1112 DT_PREINIT_ARRAY = 32, // Pointer to array of preinit functions.
1113 DT_PREINIT_ARRAYSZ = 33, // Size of the DT_PREINIT_ARRAY array.
1114
1115 DT_LOOS = 0x60000000, // Start of environment specific tags.
1116 DT_HIOS = 0x6FFFFFFF, // End of environment specific tags.
1117 DT_LOPROC = 0x70000000, // Start of processor specific tags.
1118 DT_HIPROC = 0x7FFFFFFF, // End of processor specific tags.
1119
1120 DT_GNU_HASH = 0x6FFFFEF5, // Reference to the GNU hash table.
1121 DT_TLSDESC_PLT =
1122 0x6FFFFEF6, // Location of PLT entry for TLS descriptor resolver calls.
1123 DT_TLSDESC_GOT = 0x6FFFFEF7, // Location of GOT entry used by TLS descriptor
1124 // resolver PLT entry.
1125 DT_RELACOUNT = 0x6FFFFFF9, // ELF32_Rela count.
1126 DT_RELCOUNT = 0x6FFFFFFA, // ELF32_Rel count.
1127
1128 DT_FLAGS_1 = 0X6FFFFFFB, // Flags_1.
1129 DT_VERSYM = 0x6FFFFFF0, // The address of .gnu.version section.
1130 DT_VERDEF = 0X6FFFFFFC, // The address of the version definition table.
1131 DT_VERDEFNUM = 0X6FFFFFFD, // The number of entries in DT_VERDEF.
1132 DT_VERNEED = 0X6FFFFFFE, // The address of the version Dependency table.
1133 DT_VERNEEDNUM = 0X6FFFFFFF, // The number of entries in DT_VERNEED.
1134
1135 // Hexagon specific dynamic table entries
1136 DT_HEXAGON_SYMSZ = 0x70000000,
1137 DT_HEXAGON_VER = 0x70000001,
1138 DT_HEXAGON_PLT = 0x70000002,
1139
1140 // Mips specific dynamic table entry tags.
1141 DT_MIPS_RLD_VERSION = 0x70000001, // 32 bit version number for runtime
1142 // linker interface.
1143 DT_MIPS_TIME_STAMP = 0x70000002, // Time stamp.
1144 DT_MIPS_ICHECKSUM = 0x70000003, // Checksum of external strings
1145 // and common sizes.
1146 DT_MIPS_IVERSION = 0x70000004, // Index of version string
1147 // in string table.
1148 DT_MIPS_FLAGS = 0x70000005, // 32 bits of flags.
1149 DT_MIPS_BASE_ADDRESS = 0x70000006, // Base address of the segment.
1150 DT_MIPS_MSYM = 0x70000007, // Address of .msym section.
1151 DT_MIPS_CONFLICT = 0x70000008, // Address of .conflict section.
1152 DT_MIPS_LIBLIST = 0x70000009, // Address of .liblist section.
1153 DT_MIPS_LOCAL_GOTNO = 0x7000000a, // Number of local global offset
1154 // table entries.
1155 DT_MIPS_CONFLICTNO = 0x7000000b, // Number of entries
1156 // in the .conflict section.
1157 DT_MIPS_LIBLISTNO = 0x70000010, // Number of entries
1158 // in the .liblist section.
1159 DT_MIPS_SYMTABNO = 0x70000011, // Number of entries
1160 // in the .dynsym section.
1161 DT_MIPS_UNREFEXTNO = 0x70000012, // Index of first external dynamic symbol
1162 // not referenced locally.
1163 DT_MIPS_GOTSYM = 0x70000013, // Index of first dynamic symbol
1164 // in global offset table.
1165 DT_MIPS_HIPAGENO = 0x70000014, // Number of page table entries
1166 // in global offset table.
1167 DT_MIPS_RLD_MAP = 0x70000016, // Address of run time loader map,
1168 // used for debugging.
1169 DT_MIPS_DELTA_CLASS = 0x70000017, // Delta C++ class definition.
1170 DT_MIPS_DELTA_CLASS_NO = 0x70000018, // Number of entries
1171 // in DT_MIPS_DELTA_CLASS.
1172 DT_MIPS_DELTA_INSTANCE = 0x70000019, // Delta C++ class instances.
1173 DT_MIPS_DELTA_INSTANCE_NO = 0x7000001A, // Number of entries
1174 // in DT_MIPS_DELTA_INSTANCE.
1175 DT_MIPS_DELTA_RELOC = 0x7000001B, // Delta relocations.
1176 DT_MIPS_DELTA_RELOC_NO = 0x7000001C, // Number of entries
1177 // in DT_MIPS_DELTA_RELOC.
1178 DT_MIPS_DELTA_SYM = 0x7000001D, // Delta symbols that Delta
1179 // relocations refer to.
1180 DT_MIPS_DELTA_SYM_NO = 0x7000001E, // Number of entries
1181 // in DT_MIPS_DELTA_SYM.
1182 DT_MIPS_DELTA_CLASSSYM = 0x70000020, // Delta symbols that hold
1183 // class declarations.
1184 DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021, // Number of entries
1185 // in DT_MIPS_DELTA_CLASSSYM.
1186 DT_MIPS_CXX_FLAGS = 0x70000022, // Flags indicating information
1187 // about C++ flavor.
1188 DT_MIPS_PIXIE_INIT = 0x70000023, // Pixie information.
1189 DT_MIPS_SYMBOL_LIB = 0x70000024, // Address of .MIPS.symlib
1190 DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025, // The GOT index of the first PTE
1191 // for a segment
1192 DT_MIPS_LOCAL_GOTIDX = 0x70000026, // The GOT index of the first PTE
1193 // for a local symbol
1194 DT_MIPS_HIDDEN_GOTIDX = 0x70000027, // The GOT index of the first PTE
1195 // for a hidden symbol
1196 DT_MIPS_PROTECTED_GOTIDX = 0x70000028, // The GOT index of the first PTE
1197 // for a protected symbol
1198 DT_MIPS_OPTIONS = 0x70000029, // Address of `.MIPS.options'.
1199 DT_MIPS_INTERFACE = 0x7000002A, // Address of `.interface'.
1200 DT_MIPS_DYNSTR_ALIGN = 0x7000002B, // Unknown.
1201 DT_MIPS_INTERFACE_SIZE = 0x7000002C, // Size of the .interface section.
1202 DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002D, // Size of rld_text_resolve
1203 // function stored in the GOT.
1204 DT_MIPS_PERF_SUFFIX = 0x7000002E, // Default suffix of DSO to be added
1205 // by rld on dlopen() calls.
1206 DT_MIPS_COMPACT_SIZE = 0x7000002F, // Size of compact relocation
1207 // section (O32).
1208 DT_MIPS_GP_VALUE = 0x70000030, // GP value for auxiliary GOTs.
1209 DT_MIPS_AUX_DYNAMIC = 0x70000031, // Address of auxiliary .dynamic.
1210 DT_MIPS_PLTGOT = 0x70000032, // Address of the base of the PLTGOT.
1211 DT_MIPS_RWPLT = 0x70000034, // Points to the base
1212 // of a writable PLT.
1213 DT_MIPS_RLD_MAP_REL = 0x70000035, // Relative offset of run time loader
1214 // map, used for debugging.
1215
1216 // Sun machine-independent extensions.
1217 DT_AUXILIARY = 0x7FFFFFFD, // Shared object to load before self
1218 DT_FILTER = 0x7FFFFFFF // Shared object to get values from
1219 };
1220
1221 // DT_FLAGS values.
1222 enum {
1223 DF_ORIGIN = 0x01, // The object may reference $ORIGIN.
1224 DF_SYMBOLIC = 0x02, // Search the shared lib before searching the exe.
1225 DF_TEXTREL = 0x04, // Relocations may modify a non-writable segment.
1226 DF_BIND_NOW = 0x08, // Process all relocations on load.
1227 DF_STATIC_TLS = 0x10 // Reject attempts to load dynamically.
1228 };
1229
1230 // State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 entry.
1231 enum {
1232 DF_1_NOW = 0x00000001, // Set RTLD_NOW for this object.
1233 DF_1_GLOBAL = 0x00000002, // Set RTLD_GLOBAL for this object.
1234 DF_1_GROUP = 0x00000004, // Set RTLD_GROUP for this object.
1235 DF_1_NODELETE = 0x00000008, // Set RTLD_NODELETE for this object.
1236 DF_1_LOADFLTR = 0x00000010, // Trigger filtee loading at runtime.
1237 DF_1_INITFIRST = 0x00000020, // Set RTLD_INITFIRST for this object.
1238 DF_1_NOOPEN = 0x00000040, // Set RTLD_NOOPEN for this object.
1239 DF_1_ORIGIN = 0x00000080, // $ORIGIN must be handled.
1240 DF_1_DIRECT = 0x00000100, // Direct binding enabled.
1241 DF_1_TRANS = 0x00000200,
1242 DF_1_INTERPOSE = 0x00000400, // Object is used to interpose.
1243 DF_1_NODEFLIB = 0x00000800, // Ignore default lib search path.
1244 DF_1_NODUMP = 0x00001000, // Object can't be dldump'ed.
1245 DF_1_CONFALT = 0x00002000, // Configuration alternative created.
1246 DF_1_ENDFILTEE = 0x00004000, // Filtee terminates filters search.
1247 DF_1_DISPRELDNE = 0x00008000, // Disp reloc applied at build time.
1248 DF_1_DISPRELPND = 0x00010000, // Disp reloc applied at run-time.
1249 DF_1_NODIRECT = 0x00020000, // Object has no-direct binding.
1250 DF_1_IGNMULDEF = 0x00040000,
1251 DF_1_NOKSYMS = 0x00080000,
1252 DF_1_NOHDR = 0x00100000,
1253 DF_1_EDITED = 0x00200000, // Object is modified after built.
1254 DF_1_NORELOC = 0x00400000,
1255 DF_1_SYMINTPOSE = 0x00800000, // Object has individual interposers.
1256 DF_1_GLOBAUDIT = 0x01000000, // Global auditing required.
1257 DF_1_SINGLETON = 0x02000000 // Singleton symbols are used.
1258 };
1259
1260 // DT_MIPS_FLAGS values.
1261 enum {
1262 RHF_NONE = 0x00000000, // No flags.
1263 RHF_QUICKSTART = 0x00000001, // Uses shortcut pointers.
1264 RHF_NOTPOT = 0x00000002, // Hash size is not a power of two.
1265 RHS_NO_LIBRARY_REPLACEMENT = 0x00000004, // Ignore LD_LIBRARY_PATH.
1266 RHF_NO_MOVE = 0x00000008, // DSO address may not be relocated.
1267 RHF_SGI_ONLY = 0x00000010, // SGI specific features.
1268 RHF_GUARANTEE_INIT = 0x00000020, // Guarantee that .init will finish
1269 // executing before any non-init
1270 // code in DSO is called.
1271 RHF_DELTA_C_PLUS_PLUS = 0x00000040, // Contains Delta C++ code.
1272 RHF_GUARANTEE_START_INIT = 0x00000080, // Guarantee that .init will start
1273 // executing before any non-init
1274 // code in DSO is called.
1275 RHF_PIXIE = 0x00000100, // Generated by pixie.
1276 RHF_DEFAULT_DELAY_LOAD = 0x00000200, // Delay-load DSO by default.
1277 RHF_REQUICKSTART = 0x00000400, // Object may be requickstarted
1278 RHF_REQUICKSTARTED = 0x00000800, // Object has been requickstarted
1279 RHF_CORD = 0x00001000, // Generated by cord.
1280 RHF_NO_UNRES_UNDEF = 0x00002000, // Object contains no unresolved
1281 // undef symbols.
1282 RHF_RLD_ORDER_SAFE = 0x00004000 // Symbol table is in a safe order.
1283 };
1284
1285 // ElfXX_VerDef structure version (GNU versioning)
1286 enum { VER_DEF_NONE = 0, VER_DEF_CURRENT = 1 };
1287
1288 // VerDef Flags (ElfXX_VerDef::vd_flags)
1289 enum { VER_FLG_BASE = 0x1, VER_FLG_WEAK = 0x2, VER_FLG_INFO = 0x4 };
1290
1291 // Special constants for the version table. (SHT_GNU_versym/.gnu.version)
1292 enum {
1293 VER_NDX_LOCAL = 0, // Unversioned local symbol
1294 VER_NDX_GLOBAL = 1, // Unversioned global symbol
1295 VERSYM_VERSION = 0x7fff, // Version Index mask
1296 VERSYM_HIDDEN = 0x8000 // Hidden bit (non-default version)
1297 };
1298
1299 // ElfXX_VerNeed structure version (GNU versioning)
1300 enum { VER_NEED_NONE = 0, VER_NEED_CURRENT = 1 };
1301
1302 // SHT_NOTE section types
1303 enum {
1304 NT_FREEBSD_THRMISC = 7,
1305 NT_FREEBSD_PROCSTAT_PROC = 8,
1306 NT_FREEBSD_PROCSTAT_FILES = 9,
1307 NT_FREEBSD_PROCSTAT_VMMAP = 10,
1308 NT_FREEBSD_PROCSTAT_GROUPS = 11,
1309 NT_FREEBSD_PROCSTAT_UMASK = 12,
1310 NT_FREEBSD_PROCSTAT_RLIMIT = 13,
1311 NT_FREEBSD_PROCSTAT_OSREL = 14,
1312 NT_FREEBSD_PROCSTAT_PSSTRINGS = 15,
1313 NT_FREEBSD_PROCSTAT_AUXV = 16,
1314 };
1315
1316 enum {
1317 NT_GNU_ABI_TAG = 1,
1318 NT_GNU_HWCAP = 2,
1319 NT_GNU_BUILD_ID = 3,
1320 NT_GNU_GOLD_VERSION = 4,
1321 };
1322
1323 enum {
1324 GNU_ABI_TAG_LINUX = 0,
1325 GNU_ABI_TAG_HURD = 1,
1326 GNU_ABI_TAG_SOLARIS = 2,
1327 GNU_ABI_TAG_FREEBSD = 3,
1328 GNU_ABI_TAG_NETBSD = 4,
1329 GNU_ABI_TAG_SYLLABLE = 5,
1330 GNU_ABI_TAG_NACL = 6,
1331 };
1332
1333 // Compressed section header for ELF32.
1334 struct Elf32_Chdr {
1335 Elf32_Word ch_type;
1336 Elf32_Word ch_size;
1337 Elf32_Word ch_addralign;
1338 };
1339
1340 // Compressed section header for ELF64.
1341 struct Elf64_Chdr {
1342 Elf64_Word ch_type;
1343 Elf64_Word ch_reserved;
1344 Elf64_Xword ch_size;
1345 Elf64_Xword ch_addralign;
1346 };
1347
1348 // Legal values for ch_type field of compressed section header.
1349 enum {
1350 ELFCOMPRESS_ZLIB = 1, // ZLIB/DEFLATE algorithm.
1351 ELFCOMPRESS_LOOS = 0x60000000, // Start of OS-specific.
1352 ELFCOMPRESS_HIOS = 0x6fffffff, // End of OS-specific.
1353 ELFCOMPRESS_LOPROC = 0x70000000, // Start of processor-specific.
1354 ELFCOMPRESS_HIPROC = 0x7fffffff // End of processor-specific.
1355 };
1356
1357 } // end namespace ELF
1358
1359 } // end namespace llvm
1360
1361 #endif
0
1 #ifndef ELF_RELOC
2 #error "ELF_RELOC must be defined"
3 #endif
4
5 // Based on ABI release 1.1-beta, dated 6 November 2013. NB: The cover page of
6 // this document, IHI0056C_beta_aaelf64.pdf, on infocenter.arm.com, still
7 // labels this as release 1.0.
8 ELF_RELOC(R_AARCH64_NONE, 0)
9 ELF_RELOC(R_AARCH64_ABS64, 0x101)
10 ELF_RELOC(R_AARCH64_ABS32, 0x102)
11 ELF_RELOC(R_AARCH64_ABS16, 0x103)
12 ELF_RELOC(R_AARCH64_PREL64, 0x104)
13 ELF_RELOC(R_AARCH64_PREL32, 0x105)
14 ELF_RELOC(R_AARCH64_PREL16, 0x106)
15 ELF_RELOC(R_AARCH64_MOVW_UABS_G0, 0x107)
16 ELF_RELOC(R_AARCH64_MOVW_UABS_G0_NC, 0x108)
17 ELF_RELOC(R_AARCH64_MOVW_UABS_G1, 0x109)
18 ELF_RELOC(R_AARCH64_MOVW_UABS_G1_NC, 0x10a)
19 ELF_RELOC(R_AARCH64_MOVW_UABS_G2, 0x10b)
20 ELF_RELOC(R_AARCH64_MOVW_UABS_G2_NC, 0x10c)
21 ELF_RELOC(R_AARCH64_MOVW_UABS_G3, 0x10d)
22 ELF_RELOC(R_AARCH64_MOVW_SABS_G0, 0x10e)
23 ELF_RELOC(R_AARCH64_MOVW_SABS_G1, 0x10f)
24 ELF_RELOC(R_AARCH64_MOVW_SABS_G2, 0x110)
25 ELF_RELOC(R_AARCH64_LD_PREL_LO19, 0x111)
26 ELF_RELOC(R_AARCH64_ADR_PREL_LO21, 0x112)
27 ELF_RELOC(R_AARCH64_ADR_PREL_PG_HI21, 0x113)
28 ELF_RELOC(R_AARCH64_ADR_PREL_PG_HI21_NC, 0x114)
29 ELF_RELOC(R_AARCH64_ADD_ABS_LO12_NC, 0x115)
30 ELF_RELOC(R_AARCH64_LDST8_ABS_LO12_NC, 0x116)
31 ELF_RELOC(R_AARCH64_TSTBR14, 0x117)
32 ELF_RELOC(R_AARCH64_CONDBR19, 0x118)
33 ELF_RELOC(R_AARCH64_JUMP26, 0x11a)
34 ELF_RELOC(R_AARCH64_CALL26, 0x11b)
35 ELF_RELOC(R_AARCH64_LDST16_ABS_LO12_NC, 0x11c)
36 ELF_RELOC(R_AARCH64_LDST32_ABS_LO12_NC, 0x11d)
37 ELF_RELOC(R_AARCH64_LDST64_ABS_LO12_NC, 0x11e)
38 ELF_RELOC(R_AARCH64_MOVW_PREL_G0, 0x11f)
39 ELF_RELOC(R_AARCH64_MOVW_PREL_G0_NC, 0x120)
40 ELF_RELOC(R_AARCH64_MOVW_PREL_G1, 0x121)
41 ELF_RELOC(R_AARCH64_MOVW_PREL_G1_NC, 0x122)
42 ELF_RELOC(R_AARCH64_MOVW_PREL_G2, 0x123)
43 ELF_RELOC(R_AARCH64_MOVW_PREL_G2_NC, 0x124)
44 ELF_RELOC(R_AARCH64_MOVW_PREL_G3, 0x125)
45 ELF_RELOC(R_AARCH64_LDST128_ABS_LO12_NC, 0x12b)
46 ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G0, 0x12c)
47 ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G0_NC, 0x12d)
48 ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G1, 0x12e)
49 ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G1_NC, 0x12f)
50 ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G2, 0x130)
51 ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G2_NC, 0x131)
52 ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G3, 0x132)
53