Skip to main content

object/
elf.rs

1//! ELF definitions.
2//!
3//! These definitions are independent of read/write support, although we do implement
4//! some traits useful for those.
5//!
6//! This module is the equivalent of /usr/include/elf.h, and is based heavily on it.
7
8#![allow(missing_docs)]
9#![allow(clippy::identity_op)]
10
11use crate::endian::{Endian, I32, I64, U16, U32, U64};
12use crate::pod::Pod;
13
14/// The header at the start of every 32-bit ELF file.
15#[derive(Debug, Clone, Copy)]
16#[repr(C)]
17pub struct FileHeader32<E: Endian> {
18    /// Magic number and other information.
19    pub e_ident: Ident,
20    /// Object file type. One of the `ET_*` constants.
21    pub e_type: U16<E>,
22    /// Architecture. One of the `EM_*` constants.
23    pub e_machine: U16<E>,
24    /// Object file version. Must be `EV_CURRENT`.
25    pub e_version: U32<E>,
26    /// Entry point virtual address.
27    pub e_entry: U32<E>,
28    /// Program header table file offset.
29    pub e_phoff: U32<E>,
30    /// Section header table file offset.
31    pub e_shoff: U32<E>,
32    /// Processor-specific flags.
33    ///
34    /// A combination of the `EF_*` constants.
35    pub e_flags: U32<E>,
36    /// Size in bytes of this header.
37    pub e_ehsize: U16<E>,
38    /// Program header table entry size.
39    pub e_phentsize: U16<E>,
40    /// Program header table entry count.
41    ///
42    /// If the count is greater than or equal to `PN_XNUM` then this field is set to
43    /// `PN_XNUM` and the count is stored in the `sh_info` field of section 0.
44    pub e_phnum: U16<E>,
45    /// Section header table entry size.
46    pub e_shentsize: U16<E>,
47    /// Section header table entry count.
48    ///
49    /// If the count is greater than or equal to `SHN_LORESERVE` then this field is set to
50    /// `0` and the count is stored in the `sh_size` field of section 0.
51    /// first section header.
52    pub e_shnum: U16<E>,
53    /// Section header string table index.
54    ///
55    /// If the index is greater than or equal to `SHN_LORESERVE` then this field is set to
56    /// `SHN_XINDEX` and the index is stored in the `sh_link` field of section 0.
57    pub e_shstrndx: U16<E>,
58}
59
60/// The header at the start of every 64-bit ELF file.
61#[derive(Debug, Clone, Copy)]
62#[repr(C)]
63pub struct FileHeader64<E: Endian> {
64    /// Magic number and other information.
65    pub e_ident: Ident,
66    /// Object file type. One of the `ET_*` constants.
67    pub e_type: U16<E>,
68    /// Architecture. One of the `EM_*` constants.
69    pub e_machine: U16<E>,
70    /// Object file version. Must be `EV_CURRENT`.
71    pub e_version: U32<E>,
72    /// Entry point virtual address.
73    pub e_entry: U64<E>,
74    /// Program header table file offset.
75    pub e_phoff: U64<E>,
76    /// Section header table file offset.
77    pub e_shoff: U64<E>,
78    /// Processor-specific flags.
79    ///
80    /// A combination of the `EF_*` constants.
81    pub e_flags: U32<E>,
82    /// Size in bytes of this header.
83    pub e_ehsize: U16<E>,
84    /// Program header table entry size.
85    pub e_phentsize: U16<E>,
86    /// Program header table entry count.
87    ///
88    /// If the count is greater than or equal to `PN_XNUM` then this field is set to
89    /// `PN_XNUM` and the count is stored in the `sh_info` field of section 0.
90    pub e_phnum: U16<E>,
91    /// Section header table entry size.
92    pub e_shentsize: U16<E>,
93    /// Section header table entry count.
94    ///
95    /// If the count is greater than or equal to `SHN_LORESERVE` then this field is set to
96    /// `0` and the count is stored in the `sh_size` field of section 0.
97    /// first section header.
98    pub e_shnum: U16<E>,
99    /// Section header string table index.
100    ///
101    /// If the index is greater than or equal to `SHN_LORESERVE` then this field is set to
102    /// `SHN_XINDEX` and the index is stored in the `sh_link` field of section 0.
103    pub e_shstrndx: U16<E>,
104}
105
106/// Magic number and other information.
107///
108/// Contained in the file header.
109#[derive(Debug, Clone, Copy)]
110#[repr(C)]
111pub struct Ident {
112    /// Magic number. Must be `ELFMAG`.
113    pub magic: [u8; 4],
114    /// File class. One of the `ELFCLASS*` constants.
115    pub class: u8,
116    /// Data encoding. One of the `ELFDATA*` constants.
117    pub data: u8,
118    /// ELF version. Must be `EV_CURRENT`.
119    pub version: u8,
120    /// OS ABI identification. One of the `ELFOSABI*` constants.
121    pub os_abi: u8,
122    /// ABI version.
123    ///
124    /// The meaning of this field depends on the `os_abi` value.
125    pub abi_version: u8,
126    /// Padding bytes.
127    pub padding: [u8; 7],
128}
129
130/// File identification bytes stored in `Ident::magic`.
131pub const ELFMAG: [u8; 4] = [0x7f, b'E', b'L', b'F'];
132
133// Values for `Ident::class`.
134/// Invalid class.
135pub const ELFCLASSNONE: u8 = 0;
136/// 32-bit object.
137pub const ELFCLASS32: u8 = 1;
138/// 64-bit object.
139pub const ELFCLASS64: u8 = 2;
140
141// Values for `Ident::data`.
142/// Invalid data encoding.
143pub const ELFDATANONE: u8 = 0;
144/// 2's complement, little endian.
145pub const ELFDATA2LSB: u8 = 1;
146/// 2's complement, big endian.
147pub const ELFDATA2MSB: u8 = 2;
148
149// Values for `Ident::os_abi`.
150/// UNIX System V ABI.
151pub const ELFOSABI_NONE: u8 = 0;
152/// UNIX System V ABI.
153///
154/// Alias.
155pub const ELFOSABI_SYSV: u8 = 0;
156/// HP-UX.
157pub const ELFOSABI_HPUX: u8 = 1;
158/// NetBSD.
159pub const ELFOSABI_NETBSD: u8 = 2;
160/// Object uses GNU ELF extensions.
161pub const ELFOSABI_GNU: u8 = 3;
162/// Object uses GNU ELF extensions.
163///
164/// Compatibility alias.
165pub const ELFOSABI_LINUX: u8 = ELFOSABI_GNU;
166/// GNU/Hurd.
167pub const ELFOSABI_HURD: u8 = 4;
168/// Sun Solaris.
169pub const ELFOSABI_SOLARIS: u8 = 6;
170/// IBM AIX.
171pub const ELFOSABI_AIX: u8 = 7;
172/// SGI Irix.
173pub const ELFOSABI_IRIX: u8 = 8;
174/// FreeBSD.
175pub const ELFOSABI_FREEBSD: u8 = 9;
176/// Compaq TRU64 UNIX.
177pub const ELFOSABI_TRU64: u8 = 10;
178/// Novell Modesto.
179pub const ELFOSABI_MODESTO: u8 = 11;
180/// OpenBSD.
181pub const ELFOSABI_OPENBSD: u8 = 12;
182/// OpenVMS.
183pub const ELFOSABI_OPENVMS: u8 = 13;
184/// Hewlett-Packard Non-Stop Kernel.
185pub const ELFOSABI_NSK: u8 = 14;
186/// AROS
187pub const ELFOSABI_AROS: u8 = 15;
188/// FenixOS
189pub const ELFOSABI_FENIXOS: u8 = 16;
190/// Nuxi CloudABI
191pub const ELFOSABI_CLOUDABI: u8 = 17;
192/// ARM EABI.
193pub const ELFOSABI_ARM_AEABI: u8 = 64;
194/// ARM.
195pub const ELFOSABI_ARM: u8 = 97;
196/// Standalone (embedded) application.
197pub const ELFOSABI_STANDALONE: u8 = 255;
198
199// Values for `FileHeader*::e_type`.
200/// No file type.
201pub const ET_NONE: u16 = 0;
202/// Relocatable file.
203pub const ET_REL: u16 = 1;
204/// Executable file.
205pub const ET_EXEC: u16 = 2;
206/// Shared object file.
207pub const ET_DYN: u16 = 3;
208/// Core file.
209pub const ET_CORE: u16 = 4;
210/// OS-specific range start.
211pub const ET_LOOS: u16 = 0xfe00;
212/// OS-specific range end.
213pub const ET_HIOS: u16 = 0xfeff;
214/// Processor-specific range start.
215pub const ET_LOPROC: u16 = 0xff00;
216/// Processor-specific range end.
217pub const ET_HIPROC: u16 = 0xffff;
218
219// Values for `FileHeader*::e_machine`.
220/// No machine
221pub const EM_NONE: u16 = 0;
222/// AT&T WE 32100
223pub const EM_M32: u16 = 1;
224/// SUN SPARC
225pub const EM_SPARC: u16 = 2;
226/// Intel 80386
227pub const EM_386: u16 = 3;
228/// Motorola m68k family
229pub const EM_68K: u16 = 4;
230/// Motorola m88k family
231pub const EM_88K: u16 = 5;
232/// Intel MCU
233pub const EM_IAMCU: u16 = 6;
234/// Intel 80860
235pub const EM_860: u16 = 7;
236/// MIPS R3000 big-endian
237pub const EM_MIPS: u16 = 8;
238/// IBM System/370
239pub const EM_S370: u16 = 9;
240/// MIPS R3000 little-endian
241pub const EM_MIPS_RS3_LE: u16 = 10;
242/// HPPA
243pub const EM_PARISC: u16 = 15;
244/// Fujitsu VPP500
245pub const EM_VPP500: u16 = 17;
246/// Sun's "v8plus"
247pub const EM_SPARC32PLUS: u16 = 18;
248/// Intel 80960
249pub const EM_960: u16 = 19;
250/// PowerPC
251pub const EM_PPC: u16 = 20;
252/// PowerPC 64-bit
253pub const EM_PPC64: u16 = 21;
254/// IBM S390
255pub const EM_S390: u16 = 22;
256/// IBM SPU/SPC
257pub const EM_SPU: u16 = 23;
258/// NEC V800 series
259pub const EM_V800: u16 = 36;
260/// Fujitsu FR20
261pub const EM_FR20: u16 = 37;
262/// TRW RH-32
263pub const EM_RH32: u16 = 38;
264/// Motorola RCE
265pub const EM_RCE: u16 = 39;
266/// ARM
267pub const EM_ARM: u16 = 40;
268/// Digital Alpha
269pub const EM_FAKE_ALPHA: u16 = 41;
270/// Hitachi SH
271pub const EM_SH: u16 = 42;
272/// SPARC v9 64-bit
273pub const EM_SPARCV9: u16 = 43;
274/// Siemens Tricore
275pub const EM_TRICORE: u16 = 44;
276/// Argonaut RISC Core
277pub const EM_ARC: u16 = 45;
278/// Hitachi H8/300
279pub const EM_H8_300: u16 = 46;
280/// Hitachi H8/300H
281pub const EM_H8_300H: u16 = 47;
282/// Hitachi H8S
283pub const EM_H8S: u16 = 48;
284/// Hitachi H8/500
285pub const EM_H8_500: u16 = 49;
286/// Intel Merced
287pub const EM_IA_64: u16 = 50;
288/// Stanford MIPS-X
289pub const EM_MIPS_X: u16 = 51;
290/// Motorola Coldfire
291pub const EM_COLDFIRE: u16 = 52;
292/// Motorola M68HC12
293pub const EM_68HC12: u16 = 53;
294/// Fujitsu MMA Multimedia Accelerator
295pub const EM_MMA: u16 = 54;
296/// Siemens PCP
297pub const EM_PCP: u16 = 55;
298/// Sony nCPU embeeded RISC
299pub const EM_NCPU: u16 = 56;
300/// Denso NDR1 microprocessor
301pub const EM_NDR1: u16 = 57;
302/// Motorola Start*Core processor
303pub const EM_STARCORE: u16 = 58;
304/// Toyota ME16 processor
305pub const EM_ME16: u16 = 59;
306/// STMicroelectronic ST100 processor
307pub const EM_ST100: u16 = 60;
308/// Advanced Logic Corp. Tinyj emb.fam
309pub const EM_TINYJ: u16 = 61;
310/// AMD x86-64 architecture
311pub const EM_X86_64: u16 = 62;
312/// Sony DSP Processor
313pub const EM_PDSP: u16 = 63;
314/// Digital PDP-10
315pub const EM_PDP10: u16 = 64;
316/// Digital PDP-11
317pub const EM_PDP11: u16 = 65;
318/// Siemens FX66 microcontroller
319pub const EM_FX66: u16 = 66;
320/// STMicroelectronics ST9+ 8/16 mc
321pub const EM_ST9PLUS: u16 = 67;
322/// STmicroelectronics ST7 8 bit mc
323pub const EM_ST7: u16 = 68;
324/// Motorola MC68HC16 microcontroller
325pub const EM_68HC16: u16 = 69;
326/// Motorola MC68HC11 microcontroller
327pub const EM_68HC11: u16 = 70;
328/// Motorola MC68HC08 microcontroller
329pub const EM_68HC08: u16 = 71;
330/// Motorola MC68HC05 microcontroller
331pub const EM_68HC05: u16 = 72;
332/// Silicon Graphics SVx
333pub const EM_SVX: u16 = 73;
334/// STMicroelectronics ST19 8 bit mc
335pub const EM_ST19: u16 = 74;
336/// Digital VAX
337pub const EM_VAX: u16 = 75;
338/// Axis Communications 32-bit emb.proc
339pub const EM_CRIS: u16 = 76;
340/// Infineon Technologies 32-bit emb.proc
341pub const EM_JAVELIN: u16 = 77;
342/// Element 14 64-bit DSP Processor
343pub const EM_FIREPATH: u16 = 78;
344/// LSI Logic 16-bit DSP Processor
345pub const EM_ZSP: u16 = 79;
346/// Donald Knuth's educational 64-bit proc
347pub const EM_MMIX: u16 = 80;
348/// Harvard University machine-independent object files
349pub const EM_HUANY: u16 = 81;
350/// SiTera Prism
351pub const EM_PRISM: u16 = 82;
352/// Atmel AVR 8-bit microcontroller
353pub const EM_AVR: u16 = 83;
354/// Fujitsu FR30
355pub const EM_FR30: u16 = 84;
356/// Mitsubishi D10V
357pub const EM_D10V: u16 = 85;
358/// Mitsubishi D30V
359pub const EM_D30V: u16 = 86;
360/// NEC v850
361pub const EM_V850: u16 = 87;
362/// Mitsubishi M32R
363pub const EM_M32R: u16 = 88;
364/// Matsushita MN10300
365pub const EM_MN10300: u16 = 89;
366/// Matsushita MN10200
367pub const EM_MN10200: u16 = 90;
368/// picoJava
369pub const EM_PJ: u16 = 91;
370/// OpenRISC 32-bit embedded processor
371pub const EM_OPENRISC: u16 = 92;
372/// ARC International ARCompact
373pub const EM_ARC_COMPACT: u16 = 93;
374/// Tensilica Xtensa Architecture
375pub const EM_XTENSA: u16 = 94;
376/// Alphamosaic VideoCore
377pub const EM_VIDEOCORE: u16 = 95;
378/// Thompson Multimedia General Purpose Proc
379pub const EM_TMM_GPP: u16 = 96;
380/// National Semi. 32000
381pub const EM_NS32K: u16 = 97;
382/// Tenor Network TPC
383pub const EM_TPC: u16 = 98;
384/// Trebia SNP 1000
385pub const EM_SNP1K: u16 = 99;
386/// STMicroelectronics ST200
387pub const EM_ST200: u16 = 100;
388/// Ubicom IP2xxx
389pub const EM_IP2K: u16 = 101;
390/// MAX processor
391pub const EM_MAX: u16 = 102;
392/// National Semi. CompactRISC
393pub const EM_CR: u16 = 103;
394/// Fujitsu F2MC16
395pub const EM_F2MC16: u16 = 104;
396/// Texas Instruments msp430
397pub const EM_MSP430: u16 = 105;
398/// Analog Devices Blackfin DSP
399pub const EM_BLACKFIN: u16 = 106;
400/// Seiko Epson S1C33 family
401pub const EM_SE_C33: u16 = 107;
402/// Sharp embedded microprocessor
403pub const EM_SEP: u16 = 108;
404/// Arca RISC
405pub const EM_ARCA: u16 = 109;
406/// PKU-Unity & MPRC Peking Uni. mc series
407pub const EM_UNICORE: u16 = 110;
408/// eXcess configurable cpu
409pub const EM_EXCESS: u16 = 111;
410/// Icera Semi. Deep Execution Processor
411pub const EM_DXP: u16 = 112;
412/// Altera Nios II
413pub const EM_ALTERA_NIOS2: u16 = 113;
414/// National Semi. CompactRISC CRX
415pub const EM_CRX: u16 = 114;
416/// Motorola XGATE
417pub const EM_XGATE: u16 = 115;
418/// Infineon C16x/XC16x
419pub const EM_C166: u16 = 116;
420/// Renesas M16C
421pub const EM_M16C: u16 = 117;
422/// Microchip Technology dsPIC30F
423pub const EM_DSPIC30F: u16 = 118;
424/// Freescale Communication Engine RISC
425pub const EM_CE: u16 = 119;
426/// Renesas M32C
427pub const EM_M32C: u16 = 120;
428/// Altium TSK3000
429pub const EM_TSK3000: u16 = 131;
430/// Freescale RS08
431pub const EM_RS08: u16 = 132;
432/// Analog Devices SHARC family
433pub const EM_SHARC: u16 = 133;
434/// Cyan Technology eCOG2
435pub const EM_ECOG2: u16 = 134;
436/// Sunplus S+core7 RISC
437pub const EM_SCORE7: u16 = 135;
438/// New Japan Radio (NJR) 24-bit DSP
439pub const EM_DSP24: u16 = 136;
440/// Broadcom VideoCore III
441pub const EM_VIDEOCORE3: u16 = 137;
442/// RISC for Lattice FPGA
443pub const EM_LATTICEMICO32: u16 = 138;
444/// Seiko Epson C17
445pub const EM_SE_C17: u16 = 139;
446/// Texas Instruments TMS320C6000 DSP
447pub const EM_TI_C6000: u16 = 140;
448/// Texas Instruments TMS320C2000 DSP
449pub const EM_TI_C2000: u16 = 141;
450/// Texas Instruments TMS320C55x DSP
451pub const EM_TI_C5500: u16 = 142;
452/// Texas Instruments App. Specific RISC
453pub const EM_TI_ARP32: u16 = 143;
454/// Texas Instruments Prog. Realtime Unit
455pub const EM_TI_PRU: u16 = 144;
456/// STMicroelectronics 64bit VLIW DSP
457pub const EM_MMDSP_PLUS: u16 = 160;
458/// Cypress M8C
459pub const EM_CYPRESS_M8C: u16 = 161;
460/// Renesas R32C
461pub const EM_R32C: u16 = 162;
462/// NXP Semi. TriMedia
463pub const EM_TRIMEDIA: u16 = 163;
464/// QUALCOMM Hexagon
465pub const EM_HEXAGON: u16 = 164;
466/// Intel 8051 and variants
467pub const EM_8051: u16 = 165;
468/// STMicroelectronics STxP7x
469pub const EM_STXP7X: u16 = 166;
470/// Andes Tech. compact code emb. RISC
471pub const EM_NDS32: u16 = 167;
472/// Cyan Technology eCOG1X
473pub const EM_ECOG1X: u16 = 168;
474/// Dallas Semi. MAXQ30 mc
475pub const EM_MAXQ30: u16 = 169;
476/// New Japan Radio (NJR) 16-bit DSP
477pub const EM_XIMO16: u16 = 170;
478/// M2000 Reconfigurable RISC
479pub const EM_MANIK: u16 = 171;
480/// Cray NV2 vector architecture
481pub const EM_CRAYNV2: u16 = 172;
482/// Renesas RX
483pub const EM_RX: u16 = 173;
484/// Imagination Tech. META
485pub const EM_METAG: u16 = 174;
486/// MCST Elbrus
487pub const EM_MCST_ELBRUS: u16 = 175;
488/// Cyan Technology eCOG16
489pub const EM_ECOG16: u16 = 176;
490/// National Semi. CompactRISC CR16
491pub const EM_CR16: u16 = 177;
492/// Freescale Extended Time Processing Unit
493pub const EM_ETPU: u16 = 178;
494/// Infineon Tech. SLE9X
495pub const EM_SLE9X: u16 = 179;
496/// Intel L10M
497pub const EM_L10M: u16 = 180;
498/// Intel K10M
499pub const EM_K10M: u16 = 181;
500/// ARM AARCH64
501pub const EM_AARCH64: u16 = 183;
502/// Amtel 32-bit microprocessor
503pub const EM_AVR32: u16 = 185;
504/// STMicroelectronics STM8
505pub const EM_STM8: u16 = 186;
506/// Tileta TILE64
507pub const EM_TILE64: u16 = 187;
508/// Tilera TILEPro
509pub const EM_TILEPRO: u16 = 188;
510/// Xilinx MicroBlaze
511pub const EM_MICROBLAZE: u16 = 189;
512/// NVIDIA CUDA
513pub const EM_CUDA: u16 = 190;
514/// Tilera TILE-Gx
515pub const EM_TILEGX: u16 = 191;
516/// CloudShield
517pub const EM_CLOUDSHIELD: u16 = 192;
518/// KIPO-KAIST Core-A 1st gen.
519pub const EM_COREA_1ST: u16 = 193;
520/// KIPO-KAIST Core-A 2nd gen.
521pub const EM_COREA_2ND: u16 = 194;
522/// Synopsys ARCompact V2
523pub const EM_ARC_COMPACT2: u16 = 195;
524/// Open8 RISC
525pub const EM_OPEN8: u16 = 196;
526/// Renesas RL78
527pub const EM_RL78: u16 = 197;
528/// Broadcom VideoCore V
529pub const EM_VIDEOCORE5: u16 = 198;
530/// Renesas 78KOR
531pub const EM_78KOR: u16 = 199;
532/// Freescale 56800EX DSC
533pub const EM_56800EX: u16 = 200;
534/// Beyond BA1
535pub const EM_BA1: u16 = 201;
536/// Beyond BA2
537pub const EM_BA2: u16 = 202;
538/// XMOS xCORE
539pub const EM_XCORE: u16 = 203;
540/// Microchip 8-bit PIC(r)
541pub const EM_MCHP_PIC: u16 = 204;
542/// KM211 KM32
543pub const EM_KM32: u16 = 210;
544/// KM211 KMX32
545pub const EM_KMX32: u16 = 211;
546/// KM211 KMX16
547pub const EM_EMX16: u16 = 212;
548/// KM211 KMX8
549pub const EM_EMX8: u16 = 213;
550/// KM211 KVARC
551pub const EM_KVARC: u16 = 214;
552/// Paneve CDP
553pub const EM_CDP: u16 = 215;
554/// Cognitive Smart Memory Processor
555pub const EM_COGE: u16 = 216;
556/// Bluechip CoolEngine
557pub const EM_COOL: u16 = 217;
558/// Nanoradio Optimized RISC
559pub const EM_NORC: u16 = 218;
560/// CSR Kalimba
561pub const EM_CSR_KALIMBA: u16 = 219;
562/// Zilog Z80
563pub const EM_Z80: u16 = 220;
564/// Controls and Data Services VISIUMcore
565pub const EM_VISIUM: u16 = 221;
566/// FTDI Chip FT32
567pub const EM_FT32: u16 = 222;
568/// Moxie processor
569pub const EM_MOXIE: u16 = 223;
570/// AMD GPU
571pub const EM_AMDGPU: u16 = 224;
572/// RISC-V
573pub const EM_RISCV: u16 = 243;
574/// Linux BPF -- in-kernel virtual machine
575pub const EM_BPF: u16 = 247;
576/// C-SKY
577pub const EM_CSKY: u16 = 252;
578/// Loongson LoongArch
579pub const EM_LOONGARCH: u16 = 258;
580/// Solana Binary Format
581pub const EM_SBF: u16 = 263;
582/// Digital Alpha
583pub const EM_ALPHA: u16 = 0x9026;
584
585// Values for `FileHeader*::e_version` and `Ident::version`.
586/// Invalid ELF version.
587pub const EV_NONE: u8 = 0;
588/// Current ELF version.
589pub const EV_CURRENT: u8 = 1;
590
591/// Section header.
592#[derive(Debug, Clone, Copy)]
593#[repr(C)]
594pub struct SectionHeader32<E: Endian> {
595    /// Section name.
596    ///
597    /// This is an offset into the section header string table.
598    pub sh_name: U32<E>,
599    /// Section type. One of the `SHT_*` constants.
600    pub sh_type: U32<E>,
601    /// Section flags. A combination of the `SHF_*` constants.
602    pub sh_flags: U32<E>,
603    /// Section virtual address at execution.
604    pub sh_addr: U32<E>,
605    /// Section file offset.
606    pub sh_offset: U32<E>,
607    /// Section size in bytes.
608    pub sh_size: U32<E>,
609    /// Link to another section.
610    ///
611    /// The section relationship depends on the `sh_type` value.
612    pub sh_link: U32<E>,
613    /// Additional section information.
614    ///
615    /// The meaning of this field depends on the `sh_type` value.
616    pub sh_info: U32<E>,
617    /// Section alignment.
618    pub sh_addralign: U32<E>,
619    /// Entry size if the section holds a table.
620    pub sh_entsize: U32<E>,
621}
622
623/// Section header.
624#[derive(Debug, Clone, Copy)]
625#[repr(C)]
626pub struct SectionHeader64<E: Endian> {
627    /// Section name.
628    ///
629    /// This is an offset into the section header string table.
630    pub sh_name: U32<E>,
631    /// Section type. One of the `SHT_*` constants.
632    pub sh_type: U32<E>,
633    /// Section flags. A combination of the `SHF_*` constants.
634    pub sh_flags: U64<E>,
635    /// Section virtual address at execution.
636    pub sh_addr: U64<E>,
637    /// Section file offset.
638    pub sh_offset: U64<E>,
639    /// Section size in bytes.
640    pub sh_size: U64<E>,
641    /// Link to another section.
642    ///
643    /// The section relationship depends on the `sh_type` value.
644    pub sh_link: U32<E>,
645    /// Additional section information.
646    ///
647    /// The meaning of this field depends on the `sh_type` value.
648    pub sh_info: U32<E>,
649    /// Section alignment.
650    pub sh_addralign: U64<E>,
651    /// Entry size if the section holds a table.
652    pub sh_entsize: U64<E>,
653}
654
655// Special values for section indices.
656/// Undefined section.
657pub const SHN_UNDEF: u16 = 0;
658/// OS-specific range start.
659/// Start of reserved section indices.
660pub const SHN_LORESERVE: u16 = 0xff00;
661/// Start of processor-specific section indices.
662pub const SHN_LOPROC: u16 = 0xff00;
663/// End of processor-specific section indices.
664pub const SHN_HIPROC: u16 = 0xff1f;
665/// Start of OS-specific section indices.
666pub const SHN_LOOS: u16 = 0xff20;
667/// End of OS-specific section indices.
668pub const SHN_HIOS: u16 = 0xff3f;
669/// Associated symbol is absolute.
670pub const SHN_ABS: u16 = 0xfff1;
671/// Associated symbol is common.
672pub const SHN_COMMON: u16 = 0xfff2;
673/// Section index is in the `SHT_SYMTAB_SHNDX` section.
674pub const SHN_XINDEX: u16 = 0xffff;
675/// End of reserved section indices.
676pub const SHN_HIRESERVE: u16 = 0xffff;
677
678// Values for `SectionHeader*::sh_type`.
679/// Section header table entry is unused.
680pub const SHT_NULL: u32 = 0;
681/// Program data.
682pub const SHT_PROGBITS: u32 = 1;
683/// Symbol table.
684pub const SHT_SYMTAB: u32 = 2;
685/// String table.
686pub const SHT_STRTAB: u32 = 3;
687/// Relocation entries with explicit addends.
688pub const SHT_RELA: u32 = 4;
689/// Symbol hash table.
690pub const SHT_HASH: u32 = 5;
691/// Dynamic linking information.
692pub const SHT_DYNAMIC: u32 = 6;
693/// Notes.
694pub const SHT_NOTE: u32 = 7;
695/// Program space with no data (bss).
696pub const SHT_NOBITS: u32 = 8;
697/// Relocation entries without explicit addends.
698pub const SHT_REL: u32 = 9;
699/// Reserved section type.
700pub const SHT_SHLIB: u32 = 10;
701/// Dynamic linker symbol table.
702pub const SHT_DYNSYM: u32 = 11;
703/// Array of constructors.
704pub const SHT_INIT_ARRAY: u32 = 14;
705/// Array of destructors.
706pub const SHT_FINI_ARRAY: u32 = 15;
707/// Array of pre-constructors.
708pub const SHT_PREINIT_ARRAY: u32 = 16;
709/// Section group.
710pub const SHT_GROUP: u32 = 17;
711/// Extended section indices for a symbol table.
712pub const SHT_SYMTAB_SHNDX: u32 = 18;
713/// Relocation entries; only offsets.
714pub const SHT_RELR: u32 = 19;
715/// Experimental CREL relocations. LLVM will change the value and
716/// break compatibility in the future.
717pub const SHT_CREL: u32 = 0x40000014;
718/// Start of OS-specific section types.
719pub const SHT_LOOS: u32 = 0x6000_0000;
720/// Android-specific compressed version of `SHT_REL`.
721pub const SHT_ANDROID_REL: u32 = 0x60000001;
722/// Android-specific compressed version of `SHT_RELA`.
723pub const SHT_ANDROID_RELA: u32 = 0x60000002;
724/// LLVM-style dependent libraries.
725pub const SHT_LLVM_DEPENDENT_LIBRARIES: u32 = 0x6fff4c04;
726/// Android-specific precursor of `SHT_RELR`; differs only by constants and required API level.
727pub const SHT_ANDROID_RELR: u32 = 0x6fff_ff00;
728/// GNU SFrame stack trace format.
729pub const SHT_GNU_SFRAME: u32 = 0x6fff_fff4;
730/// Object attributes.
731pub const SHT_GNU_ATTRIBUTES: u32 = 0x6fff_fff5;
732/// GNU-style hash table.
733pub const SHT_GNU_HASH: u32 = 0x6fff_fff6;
734/// Prelink library list
735pub const SHT_GNU_LIBLIST: u32 = 0x6fff_fff7;
736/// Checksum for DSO content.
737pub const SHT_CHECKSUM: u32 = 0x6fff_fff8;
738/// Sun-specific low bound.
739pub const SHT_LOSUNW: u32 = 0x6fff_fffa;
740#[allow(non_upper_case_globals)]
741pub const SHT_SUNW_move: u32 = 0x6fff_fffa;
742pub const SHT_SUNW_COMDAT: u32 = 0x6fff_fffb;
743#[allow(non_upper_case_globals)]
744pub const SHT_SUNW_syminfo: u32 = 0x6fff_fffc;
745/// Version definition section.
746#[allow(non_upper_case_globals)]
747pub const SHT_GNU_VERDEF: u32 = 0x6fff_fffd;
748/// Version needs section.
749#[allow(non_upper_case_globals)]
750pub const SHT_GNU_VERNEED: u32 = 0x6fff_fffe;
751/// Version symbol table.
752#[allow(non_upper_case_globals)]
753pub const SHT_GNU_VERSYM: u32 = 0x6fff_ffff;
754/// Sun-specific high bound.
755pub const SHT_HISUNW: u32 = 0x6fff_ffff;
756/// End of OS-specific section types.
757pub const SHT_HIOS: u32 = 0x6fff_ffff;
758/// Start of processor-specific section types.
759pub const SHT_LOPROC: u32 = 0x7000_0000;
760/// End of processor-specific section types.
761pub const SHT_HIPROC: u32 = 0x7fff_ffff;
762/// Start of application-specific section types.
763pub const SHT_LOUSER: u32 = 0x8000_0000;
764/// End of application-specific section types.
765pub const SHT_HIUSER: u32 = 0x8fff_ffff;
766
767// Values for `SectionHeader*::sh_flags`.
768/// Section is writable.
769pub const SHF_WRITE: u32 = 1 << 0;
770/// Section occupies memory during execution.
771pub const SHF_ALLOC: u32 = 1 << 1;
772/// Section is executable.
773pub const SHF_EXECINSTR: u32 = 1 << 2;
774/// Section may be be merged to eliminate duplication.
775pub const SHF_MERGE: u32 = 1 << 4;
776/// Section contains nul-terminated strings.
777pub const SHF_STRINGS: u32 = 1 << 5;
778/// The `sh_info` field contains a section header table index.
779pub const SHF_INFO_LINK: u32 = 1 << 6;
780/// Section has special ordering requirements when combining sections.
781pub const SHF_LINK_ORDER: u32 = 1 << 7;
782/// Section requires special OS-specific handling.
783pub const SHF_OS_NONCONFORMING: u32 = 1 << 8;
784/// Section is a member of a group.
785pub const SHF_GROUP: u32 = 1 << 9;
786/// Section holds thread-local storage.
787pub const SHF_TLS: u32 = 1 << 10;
788/// Section is compressed.
789///
790/// Compressed sections begin with one of the `CompressionHeader*` headers.
791pub const SHF_COMPRESSED: u32 = 1 << 11;
792/// OS-specific section flags.
793pub const SHF_MASKOS: u32 = 0x0ff0_0000;
794/// Section should not be garbage collected by the linker.
795pub const SHF_GNU_RETAIN: u32 = 1 << 21;
796/// Mbind section.
797pub const SHF_GNU_MBIND: u32 = 1 << 24;
798/// Processor-specific section flags.
799pub const SHF_MASKPROC: u32 = 0xf000_0000;
800/// This section is excluded from the final executable or shared library.
801pub const SHF_EXCLUDE: u32 = 0x8000_0000;
802
803/// Section compression header.
804///
805/// Used when `SHF_COMPRESSED` is set.
806///
807/// Note: this type currently allows for misaligned headers, but that may be
808/// changed in a future version.
809#[derive(Debug, Default, Clone, Copy)]
810#[repr(C)]
811pub struct CompressionHeader32<E: Endian> {
812    /// Compression format. One of the `ELFCOMPRESS_*` values.
813    pub ch_type: U32<E>,
814    /// Uncompressed data size.
815    pub ch_size: U32<E>,
816    /// Uncompressed data alignment.
817    pub ch_addralign: U32<E>,
818}
819
820/// Section compression header.
821///
822/// Used when `SHF_COMPRESSED` is set.
823///
824/// Note: this type currently allows for misaligned headers, but that may be
825/// changed in a future version.
826#[derive(Debug, Default, Clone, Copy)]
827#[repr(C)]
828pub struct CompressionHeader64<E: Endian> {
829    /// Compression format. One of the `ELFCOMPRESS_*` values.
830    pub ch_type: U32<E>,
831    /// Reserved.
832    pub ch_reserved: U32<E>,
833    /// Uncompressed data size.
834    pub ch_size: U64<E>,
835    /// Uncompressed data alignment.
836    pub ch_addralign: U64<E>,
837}
838
839/// ZLIB/DEFLATE algorithm.
840pub const ELFCOMPRESS_ZLIB: u32 = 1;
841/// Zstandard algorithm.
842pub const ELFCOMPRESS_ZSTD: u32 = 2;
843/// Start of OS-specific compression types.
844pub const ELFCOMPRESS_LOOS: u32 = 0x6000_0000;
845/// End of OS-specific compression types.
846pub const ELFCOMPRESS_HIOS: u32 = 0x6fff_ffff;
847/// Start of processor-specific compression types.
848pub const ELFCOMPRESS_LOPROC: u32 = 0x7000_0000;
849/// End of processor-specific compression types.
850pub const ELFCOMPRESS_HIPROC: u32 = 0x7fff_ffff;
851
852// Values for the flag entry for section groups.
853/// Mark group as COMDAT.
854pub const GRP_COMDAT: u32 = 1;
855
856/// Symbol table entry.
857#[derive(Debug, Default, Clone, Copy)]
858#[repr(C)]
859pub struct Sym32<E: Endian> {
860    /// Symbol name.
861    ///
862    /// This is an offset into the symbol string table.
863    pub st_name: U32<E>,
864    /// Symbol value.
865    pub st_value: U32<E>,
866    /// Symbol size.
867    pub st_size: U32<E>,
868    /// Symbol type and binding.
869    ///
870    /// Use the `st_type` and `st_bind` methods to access this value.
871    pub st_info: u8,
872    /// Symbol visibility.
873    ///
874    /// Use the `st_visibility` method to access this value.
875    pub st_other: u8,
876    /// Section index or one of the `SHN_*` values.
877    pub st_shndx: U16<E>,
878}
879
880impl<E: Endian> Sym32<E> {
881    /// Get the `st_bind` component of the `st_info` field.
882    #[inline]
883    pub fn st_bind(&self) -> u8 {
884        self.st_info >> 4
885    }
886
887    /// Get the `st_type` component of the `st_info` field.
888    #[inline]
889    pub fn st_type(&self) -> u8 {
890        self.st_info & 0xf
891    }
892
893    /// Set the `st_info` field given the `st_bind` and `st_type` components.
894    #[inline]
895    pub fn set_st_info(&mut self, st_bind: u8, st_type: u8) {
896        self.st_info = (st_bind << 4) + (st_type & 0xf);
897    }
898
899    /// Get the `st_visibility` component of the `st_info` field.
900    #[inline]
901    pub fn st_visibility(&self) -> u8 {
902        self.st_other & 0x3
903    }
904}
905
906/// Symbol table entry.
907#[derive(Debug, Default, Clone, Copy)]
908#[repr(C)]
909pub struct Sym64<E: Endian> {
910    /// Symbol name.
911    ///
912    /// This is an offset into the symbol string table.
913    pub st_name: U32<E>,
914    /// Symbol type and binding.
915    ///
916    /// Use the `st_bind` and `st_type` methods to access this value.
917    pub st_info: u8,
918    /// Symbol visibility.
919    ///
920    /// Use the `st_visibility` method to access this value.
921    pub st_other: u8,
922    /// Section index or one of the `SHN_*` values.
923    pub st_shndx: U16<E>,
924    /// Symbol value.
925    pub st_value: U64<E>,
926    /// Symbol size.
927    pub st_size: U64<E>,
928}
929
930impl<E: Endian> Sym64<E> {
931    /// Get the `st_bind` component of the `st_info` field.
932    #[inline]
933    pub fn st_bind(&self) -> u8 {
934        self.st_info >> 4
935    }
936
937    /// Get the `st_type` component of the `st_info` field.
938    #[inline]
939    pub fn st_type(&self) -> u8 {
940        self.st_info & 0xf
941    }
942
943    /// Set the `st_info` field given the `st_bind` and `st_type` components.
944    #[inline]
945    pub fn set_st_info(&mut self, st_bind: u8, st_type: u8) {
946        self.st_info = (st_bind << 4) + (st_type & 0xf);
947    }
948
949    /// Get the `st_visibility` component of the `st_info` field.
950    #[inline]
951    pub fn st_visibility(&self) -> u8 {
952        self.st_other & 0x3
953    }
954}
955
956/// Additional information about a `Sym32`.
957#[derive(Debug, Clone, Copy)]
958#[repr(C)]
959pub struct Syminfo32<E: Endian> {
960    /// Direct bindings, symbol bound to.
961    pub si_boundto: U16<E>,
962    /// Per symbol flags.
963    pub si_flags: U16<E>,
964}
965
966/// Additional information about a `Sym64`.
967#[derive(Debug, Clone, Copy)]
968#[repr(C)]
969pub struct Syminfo64<E: Endian> {
970    /// Direct bindings, symbol bound to.
971    pub si_boundto: U16<E>,
972    /// Per symbol flags.
973    pub si_flags: U16<E>,
974}
975
976// Values for `Syminfo*::si_boundto`.
977/// Symbol bound to self
978pub const SYMINFO_BT_SELF: u16 = 0xffff;
979/// Symbol bound to parent
980pub const SYMINFO_BT_PARENT: u16 = 0xfffe;
981/// Beginning of reserved entries
982pub const SYMINFO_BT_LOWRESERVE: u16 = 0xff00;
983
984// Values for `Syminfo*::si_flags`.
985/// Direct bound symbol
986pub const SYMINFO_FLG_DIRECT: u16 = 0x0001;
987/// Pass-thru symbol for translator
988pub const SYMINFO_FLG_PASSTHRU: u16 = 0x0002;
989/// Symbol is a copy-reloc
990pub const SYMINFO_FLG_COPY: u16 = 0x0004;
991/// Symbol bound to object to be lazy loaded
992pub const SYMINFO_FLG_LAZYLOAD: u16 = 0x0008;
993
994// Syminfo version values.
995pub const SYMINFO_NONE: u16 = 0;
996pub const SYMINFO_CURRENT: u16 = 1;
997pub const SYMINFO_NUM: u16 = 2;
998
999// Values for bind component of `Sym*::st_info`.
1000/// Local symbol.
1001pub const STB_LOCAL: u8 = 0;
1002/// Global symbol.
1003pub const STB_GLOBAL: u8 = 1;
1004/// Weak symbol.
1005pub const STB_WEAK: u8 = 2;
1006/// Start of OS-specific symbol binding.
1007pub const STB_LOOS: u8 = 10;
1008/// Unique symbol.
1009pub const STB_GNU_UNIQUE: u8 = 10;
1010/// End of OS-specific symbol binding.
1011pub const STB_HIOS: u8 = 12;
1012/// Start of processor-specific symbol binding.
1013pub const STB_LOPROC: u8 = 13;
1014/// End of processor-specific symbol binding.
1015pub const STB_HIPROC: u8 = 15;
1016
1017// Values for type component of `Sym*::st_info`.
1018/// Symbol type is unspecified.
1019pub const STT_NOTYPE: u8 = 0;
1020/// Symbol is a data object.
1021pub const STT_OBJECT: u8 = 1;
1022/// Symbol is a code object.
1023pub const STT_FUNC: u8 = 2;
1024/// Symbol is associated with a section.
1025pub const STT_SECTION: u8 = 3;
1026/// Symbol's name is a file name.
1027pub const STT_FILE: u8 = 4;
1028/// Symbol is a common data object.
1029pub const STT_COMMON: u8 = 5;
1030/// Symbol is a thread-local storage object.
1031pub const STT_TLS: u8 = 6;
1032/// Start of OS-specific symbol types.
1033pub const STT_LOOS: u8 = 10;
1034/// Symbol is an indirect code object.
1035pub const STT_GNU_IFUNC: u8 = 10;
1036/// End of OS-specific symbol types.
1037pub const STT_HIOS: u8 = 12;
1038/// Start of processor-specific symbol types.
1039pub const STT_LOPROC: u8 = 13;
1040/// End of processor-specific symbol types.
1041pub const STT_HIPROC: u8 = 15;
1042
1043// Values for visibility component of `Symbol*::st_other`.
1044/// Default symbol visibility rules.
1045pub const STV_DEFAULT: u8 = 0;
1046/// Processor specific hidden class.
1047pub const STV_INTERNAL: u8 = 1;
1048/// Symbol is not visible to other components.
1049pub const STV_HIDDEN: u8 = 2;
1050/// Symbol is visible to other components, but is not preemptible.
1051pub const STV_PROTECTED: u8 = 3;
1052
1053/// Relocation table entry without explicit addend.
1054#[derive(Debug, Clone, Copy)]
1055#[repr(C)]
1056pub struct Rel32<E: Endian> {
1057    /// Relocation address.
1058    pub r_offset: U32<E>,
1059    /// Relocation type and symbol index.
1060    pub r_info: U32<E>,
1061}
1062
1063impl<E: Endian> Rel32<E> {
1064    /// Get the `r_sym` component of the `r_info` field.
1065    #[inline]
1066    pub fn r_sym(&self, endian: E) -> u32 {
1067        self.r_info.get(endian) >> 8
1068    }
1069
1070    /// Get the `r_type` component of the `r_info` field.
1071    #[inline]
1072    pub fn r_type(&self, endian: E) -> u32 {
1073        self.r_info.get(endian) & 0xff
1074    }
1075
1076    /// Calculate the `r_info` field given the `r_sym` and `r_type` components.
1077    pub fn r_info(endian: E, r_sym: u32, r_type: u8) -> U32<E> {
1078        U32::new(endian, (r_sym << 8) | u32::from(r_type))
1079    }
1080
1081    /// Set the `r_info` field given the `r_sym` and `r_type` components.
1082    pub fn set_r_info(&mut self, endian: E, r_sym: u32, r_type: u8) {
1083        self.r_info = Self::r_info(endian, r_sym, r_type)
1084    }
1085}
1086
1087/// Relocation table entry with explicit addend.
1088#[derive(Debug, Clone, Copy)]
1089#[repr(C)]
1090pub struct Rela32<E: Endian> {
1091    /// Relocation address.
1092    pub r_offset: U32<E>,
1093    /// Relocation type and symbol index.
1094    pub r_info: U32<E>,
1095    /// Explicit addend.
1096    pub r_addend: I32<E>,
1097}
1098
1099impl<E: Endian> Rela32<E> {
1100    /// Get the `r_sym` component of the `r_info` field.
1101    #[inline]
1102    pub fn r_sym(&self, endian: E) -> u32 {
1103        self.r_info.get(endian) >> 8
1104    }
1105
1106    /// Get the `r_type` component of the `r_info` field.
1107    #[inline]
1108    pub fn r_type(&self, endian: E) -> u32 {
1109        self.r_info.get(endian) & 0xff
1110    }
1111
1112    /// Calculate the `r_info` field given the `r_sym` and `r_type` components.
1113    pub fn r_info(endian: E, r_sym: u32, r_type: u8) -> U32<E> {
1114        U32::new(endian, (r_sym << 8) | u32::from(r_type))
1115    }
1116
1117    /// Set the `r_info` field given the `r_sym` and `r_type` components.
1118    pub fn set_r_info(&mut self, endian: E, r_sym: u32, r_type: u8) {
1119        self.r_info = Self::r_info(endian, r_sym, r_type)
1120    }
1121}
1122
1123impl<E: Endian> From<Rel32<E>> for Rela32<E> {
1124    fn from(rel: Rel32<E>) -> Self {
1125        Rela32 {
1126            r_offset: rel.r_offset,
1127            r_info: rel.r_info,
1128            r_addend: I32::default(),
1129        }
1130    }
1131}
1132
1133/// Relocation table entry without explicit addend.
1134#[derive(Debug, Clone, Copy)]
1135#[repr(C)]
1136pub struct Rel64<E: Endian> {
1137    /// Relocation address.
1138    pub r_offset: U64<E>,
1139    /// Relocation type and symbol index.
1140    pub r_info: U64<E>,
1141}
1142
1143impl<E: Endian> Rel64<E> {
1144    /// Get the `r_sym` component of the `r_info` field.
1145    #[inline]
1146    pub fn r_sym(&self, endian: E) -> u32 {
1147        (self.r_info.get(endian) >> 32) as u32
1148    }
1149
1150    /// Get the `r_type` component of the `r_info` field.
1151    #[inline]
1152    pub fn r_type(&self, endian: E) -> u32 {
1153        (self.r_info.get(endian) & 0xffff_ffff) as u32
1154    }
1155
1156    /// Calculate the `r_info` field given the `r_sym` and `r_type` components.
1157    pub fn r_info(endian: E, r_sym: u32, r_type: u32) -> U64<E> {
1158        U64::new(endian, (u64::from(r_sym) << 32) | u64::from(r_type))
1159    }
1160
1161    /// Set the `r_info` field given the `r_sym` and `r_type` components.
1162    pub fn set_r_info(&mut self, endian: E, r_sym: u32, r_type: u32) {
1163        self.r_info = Self::r_info(endian, r_sym, r_type)
1164    }
1165}
1166
1167impl<E: Endian> From<Rel64<E>> for Rela64<E> {
1168    fn from(rel: Rel64<E>) -> Self {
1169        Rela64 {
1170            r_offset: rel.r_offset,
1171            r_info: rel.r_info,
1172            r_addend: I64::default(),
1173        }
1174    }
1175}
1176
1177/// Relocation table entry with explicit addend.
1178#[derive(Debug, Clone, Copy)]
1179#[repr(C)]
1180pub struct Rela64<E: Endian> {
1181    /// Relocation address.
1182    pub r_offset: U64<E>,
1183    /// Relocation type and symbol index.
1184    pub r_info: U64<E>,
1185    /// Explicit addend.
1186    pub r_addend: I64<E>,
1187}
1188
1189impl<E: Endian> Rela64<E> {
1190    pub(crate) fn get_r_info(&self, endian: E, is_mips64el: bool) -> u64 {
1191        let mut t = self.r_info.get(endian);
1192        if is_mips64el {
1193            t = (t << 32)
1194                | ((t >> 8) & 0xff000000)
1195                | ((t >> 24) & 0x00ff0000)
1196                | ((t >> 40) & 0x0000ff00)
1197                | ((t >> 56) & 0x000000ff);
1198        }
1199        t
1200    }
1201
1202    /// Get the `r_sym` component of the `r_info` field.
1203    #[inline]
1204    pub fn r_sym(&self, endian: E, is_mips64el: bool) -> u32 {
1205        (self.get_r_info(endian, is_mips64el) >> 32) as u32
1206    }
1207
1208    /// Get the `r_type` component of the `r_info` field.
1209    #[inline]
1210    pub fn r_type(&self, endian: E, is_mips64el: bool) -> u32 {
1211        (self.get_r_info(endian, is_mips64el) & 0xffff_ffff) as u32
1212    }
1213
1214    /// Calculate the `r_info` field given the `r_sym` and `r_type` components.
1215    pub fn r_info(endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) -> U64<E> {
1216        let mut t = (u64::from(r_sym) << 32) | u64::from(r_type);
1217        if is_mips64el {
1218            t = (t >> 32)
1219                | ((t & 0xff000000) << 8)
1220                | ((t & 0x00ff0000) << 24)
1221                | ((t & 0x0000ff00) << 40)
1222                | ((t & 0x000000ff) << 56);
1223        }
1224        U64::new(endian, t)
1225    }
1226
1227    /// Set the `r_info` field given the `r_sym` and `r_type` components.
1228    pub fn set_r_info(&mut self, endian: E, is_mips64el: bool, r_sym: u32, r_type: u32) {
1229        self.r_info = Self::r_info(endian, is_mips64el, r_sym, r_type);
1230    }
1231}
1232
1233/// 32-bit relative relocation table entry.
1234#[derive(Debug, Clone, Copy)]
1235#[repr(C)]
1236pub struct Relr32<E: Endian>(pub U32<E>);
1237
1238/// 64-bit relative relocation table entry.
1239#[derive(Debug, Clone, Copy)]
1240#[repr(C)]
1241pub struct Relr64<E: Endian>(pub U64<E>);
1242
1243/// Program segment header.
1244#[derive(Debug, Clone, Copy)]
1245#[repr(C)]
1246pub struct ProgramHeader32<E: Endian> {
1247    /// Segment type. One of the `PT_*` constants.
1248    pub p_type: U32<E>,
1249    /// Segment file offset.
1250    pub p_offset: U32<E>,
1251    /// Segment virtual address.
1252    pub p_vaddr: U32<E>,
1253    /// Segment physical address.
1254    pub p_paddr: U32<E>,
1255    /// Segment size in the file.
1256    pub p_filesz: U32<E>,
1257    /// Segment size in memory.
1258    pub p_memsz: U32<E>,
1259    /// Segment flags. A combination of the `PF_*` constants.
1260    pub p_flags: U32<E>,
1261    /// Segment alignment.
1262    pub p_align: U32<E>,
1263}
1264
1265/// Program segment header.
1266#[derive(Debug, Clone, Copy)]
1267#[repr(C)]
1268pub struct ProgramHeader64<E: Endian> {
1269    /// Segment type. One of the `PT_*` constants.
1270    pub p_type: U32<E>,
1271    /// Segment flags. A combination of the `PF_*` constants.
1272    pub p_flags: U32<E>,
1273    /// Segment file offset.
1274    pub p_offset: U64<E>,
1275    /// Segment virtual address.
1276    pub p_vaddr: U64<E>,
1277    /// Segment physical address.
1278    pub p_paddr: U64<E>,
1279    /// Segment size in the file.
1280    pub p_filesz: U64<E>,
1281    /// Segment size in memory.
1282    pub p_memsz: U64<E>,
1283    /// Segment alignment.
1284    pub p_align: U64<E>,
1285}
1286
1287/// Special value for `FileHeader*::e_phnum`.
1288///
1289/// This indicates that the real number of program headers is too large to fit into e_phnum.
1290/// Instead the real value is in the field `sh_info` of section 0.
1291pub const PN_XNUM: u16 = 0xffff;
1292
1293// Values for `ProgramHeader*::p_type`.
1294/// Program header table entry is unused.
1295pub const PT_NULL: u32 = 0;
1296/// Loadable program segment.
1297pub const PT_LOAD: u32 = 1;
1298/// Dynamic linking information.
1299pub const PT_DYNAMIC: u32 = 2;
1300/// Program interpreter.
1301pub const PT_INTERP: u32 = 3;
1302/// Auxiliary information.
1303pub const PT_NOTE: u32 = 4;
1304/// Reserved.
1305pub const PT_SHLIB: u32 = 5;
1306/// Segment contains the program header table.
1307pub const PT_PHDR: u32 = 6;
1308/// Thread-local storage segment.
1309pub const PT_TLS: u32 = 7;
1310/// Start of OS-specific segment types.
1311pub const PT_LOOS: u32 = 0x6000_0000;
1312/// GCC `.eh_frame_hdr` segment.
1313pub const PT_GNU_EH_FRAME: u32 = 0x6474_e550;
1314/// Indicates stack executability.
1315pub const PT_GNU_STACK: u32 = 0x6474_e551;
1316/// Read-only after relocation.
1317pub const PT_GNU_RELRO: u32 = 0x6474_e552;
1318/// Segment containing `.note.gnu.property` section.
1319pub const PT_GNU_PROPERTY: u32 = 0x6474_e553;
1320/// GNU SFrame stack trace format.
1321pub const PT_GNU_SFRAME: u32 = 0x6474_e554;
1322/// End of OS-specific segment types.
1323pub const PT_HIOS: u32 = 0x6fff_ffff;
1324/// Start of processor-specific segment types.
1325pub const PT_LOPROC: u32 = 0x7000_0000;
1326/// End of processor-specific segment types.
1327pub const PT_HIPROC: u32 = 0x7fff_ffff;
1328
1329// Values for `ProgramHeader*::p_flags`.
1330/// Segment is executable.
1331pub const PF_X: u32 = 1 << 0;
1332/// Segment is writable.
1333pub const PF_W: u32 = 1 << 1;
1334/// Segment is readable.
1335pub const PF_R: u32 = 1 << 2;
1336/// OS-specific segment flags.
1337pub const PF_MASKOS: u32 = 0x0ff0_0000;
1338/// Processor-specific segment flags.
1339pub const PF_MASKPROC: u32 = 0xf000_0000;
1340
1341/// Note name for core files.
1342pub const ELF_NOTE_CORE: &[u8] = b"CORE";
1343/// Note name for linux core files.
1344///
1345/// Notes in linux core files may also use `ELF_NOTE_CORE`.
1346pub const ELF_NOTE_LINUX: &[u8] = b"LINUX";
1347
1348// Values for `NoteHeader*::n_type` in core files.
1349//
1350/// Contains copy of prstatus struct.
1351pub const NT_PRSTATUS: u32 = 1;
1352/// Contains copy of fpregset struct.
1353pub const NT_PRFPREG: u32 = 2;
1354/// Contains copy of fpregset struct.
1355pub const NT_FPREGSET: u32 = 2;
1356/// Contains copy of prpsinfo struct.
1357pub const NT_PRPSINFO: u32 = 3;
1358/// Contains copy of prxregset struct.
1359pub const NT_PRXREG: u32 = 4;
1360/// Contains copy of task structure.
1361pub const NT_TASKSTRUCT: u32 = 4;
1362/// String from sysinfo(SI_PLATFORM).
1363pub const NT_PLATFORM: u32 = 5;
1364/// Contains copy of auxv array.
1365pub const NT_AUXV: u32 = 6;
1366/// Contains copy of gwindows struct.
1367pub const NT_GWINDOWS: u32 = 7;
1368/// Contains copy of asrset struct.
1369pub const NT_ASRS: u32 = 8;
1370/// Contains copy of pstatus struct.
1371pub const NT_PSTATUS: u32 = 10;
1372/// Contains copy of psinfo struct.
1373pub const NT_PSINFO: u32 = 13;
1374/// Contains copy of prcred struct.
1375pub const NT_PRCRED: u32 = 14;
1376/// Contains copy of utsname struct.
1377pub const NT_UTSNAME: u32 = 15;
1378/// Contains copy of lwpstatus struct.
1379pub const NT_LWPSTATUS: u32 = 16;
1380/// Contains copy of lwpinfo struct.
1381pub const NT_LWPSINFO: u32 = 17;
1382/// Contains copy of fprxregset struct.
1383pub const NT_PRFPXREG: u32 = 20;
1384/// Contains copy of siginfo_t, size might increase.
1385pub const NT_SIGINFO: u32 = 0x5349_4749;
1386/// Contains information about mapped files.
1387pub const NT_FILE: u32 = 0x4649_4c45;
1388/// Contains copy of user_fxsr_struct.
1389pub const NT_PRXFPREG: u32 = 0x46e6_2b7f;
1390/// PowerPC Altivec/VMX registers.
1391pub const NT_PPC_VMX: u32 = 0x100;
1392/// PowerPC SPE/EVR registers.
1393pub const NT_PPC_SPE: u32 = 0x101;
1394/// PowerPC VSX registers.
1395pub const NT_PPC_VSX: u32 = 0x102;
1396/// Target Address Register.
1397pub const NT_PPC_TAR: u32 = 0x103;
1398/// Program Priority Register.
1399pub const NT_PPC_PPR: u32 = 0x104;
1400/// Data Stream Control Register.
1401pub const NT_PPC_DSCR: u32 = 0x105;
1402/// Event Based Branch Registers.
1403pub const NT_PPC_EBB: u32 = 0x106;
1404/// Performance Monitor Registers.
1405pub const NT_PPC_PMU: u32 = 0x107;
1406/// TM checkpointed GPR Registers.
1407pub const NT_PPC_TM_CGPR: u32 = 0x108;
1408/// TM checkpointed FPR Registers.
1409pub const NT_PPC_TM_CFPR: u32 = 0x109;
1410/// TM checkpointed VMX Registers.
1411pub const NT_PPC_TM_CVMX: u32 = 0x10a;
1412/// TM checkpointed VSX Registers.
1413pub const NT_PPC_TM_CVSX: u32 = 0x10b;
1414/// TM Special Purpose Registers.
1415pub const NT_PPC_TM_SPR: u32 = 0x10c;
1416/// TM checkpointed Target Address Register.
1417pub const NT_PPC_TM_CTAR: u32 = 0x10d;
1418/// TM checkpointed Program Priority Register.
1419pub const NT_PPC_TM_CPPR: u32 = 0x10e;
1420/// TM checkpointed Data Stream Control Register.
1421pub const NT_PPC_TM_CDSCR: u32 = 0x10f;
1422/// Memory Protection Keys registers.
1423pub const NT_PPC_PKEY: u32 = 0x110;
1424/// i386 TLS slots (struct user_desc).
1425pub const NT_386_TLS: u32 = 0x200;
1426/// x86 io permission bitmap (1=deny).
1427pub const NT_386_IOPERM: u32 = 0x201;
1428/// x86 extended state using xsave.
1429pub const NT_X86_XSTATE: u32 = 0x202;
1430/// s390 upper register halves.
1431pub const NT_S390_HIGH_GPRS: u32 = 0x300;
1432/// s390 timer register.
1433pub const NT_S390_TIMER: u32 = 0x301;
1434/// s390 TOD clock comparator register.
1435pub const NT_S390_TODCMP: u32 = 0x302;
1436/// s390 TOD programmable register.
1437pub const NT_S390_TODPREG: u32 = 0x303;
1438/// s390 control registers.
1439pub const NT_S390_CTRS: u32 = 0x304;
1440/// s390 prefix register.
1441pub const NT_S390_PREFIX: u32 = 0x305;
1442/// s390 breaking event address.
1443pub const NT_S390_LAST_BREAK: u32 = 0x306;
1444/// s390 system call restart data.
1445pub const NT_S390_SYSTEM_CALL: u32 = 0x307;
1446/// s390 transaction diagnostic block.
1447pub const NT_S390_TDB: u32 = 0x308;
1448/// s390 vector registers 0-15 upper half.
1449pub const NT_S390_VXRS_LOW: u32 = 0x309;
1450/// s390 vector registers 16-31.
1451pub const NT_S390_VXRS_HIGH: u32 = 0x30a;
1452/// s390 guarded storage registers.
1453pub const NT_S390_GS_CB: u32 = 0x30b;
1454/// s390 guarded storage broadcast control block.
1455pub const NT_S390_GS_BC: u32 = 0x30c;
1456/// s390 runtime instrumentation.
1457pub const NT_S390_RI_CB: u32 = 0x30d;
1458/// ARM VFP/NEON registers.
1459pub const NT_ARM_VFP: u32 = 0x400;
1460/// ARM TLS register.
1461pub const NT_ARM_TLS: u32 = 0x401;
1462/// ARM hardware breakpoint registers.
1463pub const NT_ARM_HW_BREAK: u32 = 0x402;
1464/// ARM hardware watchpoint registers.
1465pub const NT_ARM_HW_WATCH: u32 = 0x403;
1466/// ARM system call number.
1467pub const NT_ARM_SYSTEM_CALL: u32 = 0x404;
1468/// ARM Scalable Vector Extension registers.
1469pub const NT_ARM_SVE: u32 = 0x405;
1470/// Vmcore Device Dump Note.
1471pub const NT_VMCOREDD: u32 = 0x700;
1472/// MIPS DSP ASE registers.
1473pub const NT_MIPS_DSP: u32 = 0x800;
1474/// MIPS floating-point mode.
1475pub const NT_MIPS_FP_MODE: u32 = 0x801;
1476
1477/// Note type for version string.
1478///
1479/// This note may appear in object files.
1480///
1481/// It must be handled as a special case because it has no descriptor, and instead
1482/// uses the note name as the version string.
1483pub const NT_VERSION: u32 = 1;
1484
1485/// Dynamic section entry.
1486#[derive(Debug, Clone, Copy)]
1487#[repr(C)]
1488pub struct Dyn32<E: Endian> {
1489    /// Dynamic entry type.
1490    pub d_tag: I32<E>,
1491    /// Value (integer or address).
1492    pub d_val: U32<E>,
1493}
1494
1495/// Dynamic section entry.
1496#[derive(Debug, Clone, Copy)]
1497#[repr(C)]
1498pub struct Dyn64<E: Endian> {
1499    /// Dynamic entry type.
1500    pub d_tag: I64<E>,
1501    /// Value (integer or address).
1502    pub d_val: U64<E>,
1503}
1504
1505// Values for `Dyn*::d_tag`.
1506
1507/// Marks end of dynamic section
1508pub const DT_NULL: i64 = 0;
1509/// Name of needed library
1510pub const DT_NEEDED: i64 = 1;
1511/// Size in bytes of PLT relocs
1512pub const DT_PLTRELSZ: i64 = 2;
1513/// Processor defined value
1514pub const DT_PLTGOT: i64 = 3;
1515/// Address of symbol hash table
1516pub const DT_HASH: i64 = 4;
1517/// Address of string table
1518pub const DT_STRTAB: i64 = 5;
1519/// Address of symbol table
1520pub const DT_SYMTAB: i64 = 6;
1521/// Address of Rela relocs
1522pub const DT_RELA: i64 = 7;
1523/// Total size of Rela relocs
1524pub const DT_RELASZ: i64 = 8;
1525/// Size of one Rela reloc
1526pub const DT_RELAENT: i64 = 9;
1527/// Size of string table
1528pub const DT_STRSZ: i64 = 10;
1529/// Size of one symbol table entry
1530pub const DT_SYMENT: i64 = 11;
1531/// Address of init function
1532pub const DT_INIT: i64 = 12;
1533/// Address of termination function
1534pub const DT_FINI: i64 = 13;
1535/// Name of shared object
1536pub const DT_SONAME: i64 = 14;
1537/// Library search path (deprecated)
1538pub const DT_RPATH: i64 = 15;
1539/// Start symbol search here
1540pub const DT_SYMBOLIC: i64 = 16;
1541/// Address of Rel relocs
1542pub const DT_REL: i64 = 17;
1543/// Total size of Rel relocs
1544pub const DT_RELSZ: i64 = 18;
1545/// Size of one Rel reloc
1546pub const DT_RELENT: i64 = 19;
1547/// Type of reloc in PLT
1548pub const DT_PLTREL: i64 = 20;
1549/// For debugging; unspecified
1550pub const DT_DEBUG: i64 = 21;
1551/// Reloc might modify .text
1552pub const DT_TEXTREL: i64 = 22;
1553/// Address of PLT relocs
1554pub const DT_JMPREL: i64 = 23;
1555/// Process relocations of object
1556pub const DT_BIND_NOW: i64 = 24;
1557/// Array with addresses of init fct
1558pub const DT_INIT_ARRAY: i64 = 25;
1559/// Array with addresses of fini fct
1560pub const DT_FINI_ARRAY: i64 = 26;
1561/// Size in bytes of DT_INIT_ARRAY
1562pub const DT_INIT_ARRAYSZ: i64 = 27;
1563/// Size in bytes of DT_FINI_ARRAY
1564pub const DT_FINI_ARRAYSZ: i64 = 28;
1565/// Library search path
1566pub const DT_RUNPATH: i64 = 29;
1567/// Flags for the object being loaded
1568pub const DT_FLAGS: i64 = 30;
1569/// Start of encoded range
1570pub const DT_ENCODING: i64 = 32;
1571/// Array with addresses of preinit fct
1572pub const DT_PREINIT_ARRAY: i64 = 32;
1573/// size in bytes of DT_PREINIT_ARRAY
1574pub const DT_PREINIT_ARRAYSZ: i64 = 33;
1575/// Address of SYMTAB_SHNDX section
1576pub const DT_SYMTAB_SHNDX: i64 = 34;
1577/// Address of Relr relocs
1578pub const DT_RELR: i64 = 36;
1579/// Total size of Relr relocs
1580pub const DT_RELRSZ: i64 = 35;
1581/// Size of one Relr reloc
1582pub const DT_RELRENT: i64 = 37;
1583/// Start of OS-specific
1584pub const DT_LOOS: i64 = 0x6000_000d;
1585/// Address of Android-specific compressed Rel relocs
1586pub const DT_ANDROID_REL: i64 = 0x6000000f;
1587/// Total size of Android-specific compressed Rel relocs
1588pub const DT_ANDROID_RELSZ: i64 = 0x60000010;
1589/// Address of Android-specific compressed Rela relocs
1590pub const DT_ANDROID_RELA: i64 = 0x60000011;
1591/// Total size of Android-specific compressed Rela relocs
1592pub const DT_ANDROID_RELASZ: i64 = 0x60000012;
1593/// Address of Android-specific Relr relocs
1594pub const DT_ANDROID_RELR: i64 = 0x6fff_e000;
1595/// Total size of Android-specific Relr relocs
1596pub const DT_ANDROID_RELRSZ: i64 = 0x6fff_e001;
1597/// Size of one Android-specific Relr reloc
1598pub const DT_ANDROID_RELRENT: i64 = 0x6fff_e003;
1599/// End of OS-specific
1600pub const DT_HIOS: i64 = 0x6fff_f000;
1601/// Start of processor-specific
1602pub const DT_LOPROC: i64 = 0x7000_0000;
1603/// End of processor-specific
1604pub const DT_HIPROC: i64 = 0x7fff_ffff;
1605
1606// `DT_*` entries between `DT_VALRNGHI` & `DT_VALRNGLO` use `d_val` as a value.
1607pub const DT_VALRNGLO: i64 = 0x6fff_fd00;
1608/// Prelinking timestamp
1609pub const DT_GNU_PRELINKED: i64 = 0x6fff_fdf5;
1610/// Size of conflict section
1611pub const DT_GNU_CONFLICTSZ: i64 = 0x6fff_fdf6;
1612/// Size of library list
1613pub const DT_GNU_LIBLISTSZ: i64 = 0x6fff_fdf7;
1614pub const DT_CHECKSUM: i64 = 0x6fff_fdf8;
1615pub const DT_PLTPADSZ: i64 = 0x6fff_fdf9;
1616pub const DT_MOVEENT: i64 = 0x6fff_fdfa;
1617pub const DT_MOVESZ: i64 = 0x6fff_fdfb;
1618/// Feature selection (DTF_*).
1619pub const DT_FEATURE_1: i64 = 0x6fff_fdfc;
1620/// Flags for DT_* entries, affecting the following DT_* entry.
1621pub const DT_POSFLAG_1: i64 = 0x6fff_fdfd;
1622/// Size of syminfo table (in bytes)
1623pub const DT_SYMINSZ: i64 = 0x6fff_fdfe;
1624/// Entry size of syminfo
1625pub const DT_SYMINENT: i64 = 0x6fff_fdff;
1626pub const DT_VALRNGHI: i64 = 0x6fff_fdff;
1627
1628// `DT_*` entries between `DT_ADDRRNGHI` & `DT_ADDRRNGLO` use `d_val` as an address.
1629//
1630// If any adjustment is made to the ELF object after it has been
1631// built these entries will need to be adjusted.
1632pub const DT_ADDRRNGLO: i64 = 0x6fff_fe00;
1633/// GNU-style hash table.
1634pub const DT_GNU_HASH: i64 = 0x6fff_fef5;
1635pub const DT_TLSDESC_PLT: i64 = 0x6fff_fef6;
1636pub const DT_TLSDESC_GOT: i64 = 0x6fff_fef7;
1637/// Start of conflict section
1638pub const DT_GNU_CONFLICT: i64 = 0x6fff_fef8;
1639/// Library list
1640pub const DT_GNU_LIBLIST: i64 = 0x6fff_fef9;
1641/// Configuration information.
1642pub const DT_CONFIG: i64 = 0x6fff_fefa;
1643/// Dependency auditing.
1644pub const DT_DEPAUDIT: i64 = 0x6fff_fefb;
1645/// Object auditing.
1646pub const DT_AUDIT: i64 = 0x6fff_fefc;
1647/// PLT padding.
1648pub const DT_PLTPAD: i64 = 0x6fff_fefd;
1649/// Move table.
1650pub const DT_MOVETAB: i64 = 0x6fff_fefe;
1651/// Syminfo table.
1652pub const DT_SYMINFO: i64 = 0x6fff_feff;
1653pub const DT_ADDRRNGHI: i64 = 0x6fff_feff;
1654
1655// The versioning entry types.  The next are defined as part of the
1656// GNU extension.
1657pub const DT_VERSYM: i64 = 0x6fff_fff0;
1658pub const DT_RELACOUNT: i64 = 0x6fff_fff9;
1659pub const DT_RELCOUNT: i64 = 0x6fff_fffa;
1660/// State flags, see DF_1_* below.
1661pub const DT_FLAGS_1: i64 = 0x6fff_fffb;
1662/// Address of version definition table
1663pub const DT_VERDEF: i64 = 0x6fff_fffc;
1664/// Number of version definitions
1665pub const DT_VERDEFNUM: i64 = 0x6fff_fffd;
1666/// Address of table with needed versions
1667pub const DT_VERNEED: i64 = 0x6fff_fffe;
1668/// Number of needed versions
1669pub const DT_VERNEEDNUM: i64 = 0x6fff_ffff;
1670
1671// Machine-independent extensions in the "processor-specific" range.
1672/// Shared object to load before self
1673pub const DT_AUXILIARY: i64 = 0x7fff_fffd;
1674/// Shared object to get values from
1675pub const DT_FILTER: i64 = 0x7fff_ffff;
1676
1677// Values of `Dyn*::d_val` in the `DT_FLAGS` entry.
1678/// Object may use DF_ORIGIN
1679pub const DF_ORIGIN: u32 = 0x0000_0001;
1680/// Symbol resolutions starts here
1681pub const DF_SYMBOLIC: u32 = 0x0000_0002;
1682/// Object contains text relocations
1683pub const DF_TEXTREL: u32 = 0x0000_0004;
1684/// No lazy binding for this object
1685pub const DF_BIND_NOW: u32 = 0x0000_0008;
1686/// Module uses the static TLS model
1687pub const DF_STATIC_TLS: u32 = 0x0000_0010;
1688
1689// Values of `Dyn*::d_val` in the `DT_FLAGS_1` entry.
1690/// Set RTLD_NOW for this object.
1691pub const DF_1_NOW: u32 = 0x0000_0001;
1692/// Set RTLD_GLOBAL for this object.
1693pub const DF_1_GLOBAL: u32 = 0x0000_0002;
1694/// Set RTLD_GROUP for this object.
1695pub const DF_1_GROUP: u32 = 0x0000_0004;
1696/// Set RTLD_NODELETE for this object.
1697pub const DF_1_NODELETE: u32 = 0x0000_0008;
1698/// Trigger filtee loading at runtime.
1699pub const DF_1_LOADFLTR: u32 = 0x0000_0010;
1700/// Set RTLD_INITFIRST for this object.
1701pub const DF_1_INITFIRST: u32 = 0x0000_0020;
1702/// Set RTLD_NOOPEN for this object.
1703pub const DF_1_NOOPEN: u32 = 0x0000_0040;
1704/// $ORIGIN must be handled.
1705pub const DF_1_ORIGIN: u32 = 0x0000_0080;
1706/// Direct binding enabled.
1707pub const DF_1_DIRECT: u32 = 0x0000_0100;
1708pub const DF_1_TRANS: u32 = 0x0000_0200;
1709/// Object is used to interpose.
1710pub const DF_1_INTERPOSE: u32 = 0x0000_0400;
1711/// Ignore default lib search path.
1712pub const DF_1_NODEFLIB: u32 = 0x0000_0800;
1713/// Object can't be dldump'ed.
1714pub const DF_1_NODUMP: u32 = 0x0000_1000;
1715/// Configuration alternative created.
1716pub const DF_1_CONFALT: u32 = 0x0000_2000;
1717/// Filtee terminates filters search.
1718pub const DF_1_ENDFILTEE: u32 = 0x0000_4000;
1719/// Disp reloc applied at build time.
1720pub const DF_1_DISPRELDNE: u32 = 0x0000_8000;
1721/// Disp reloc applied at run-time.
1722pub const DF_1_DISPRELPND: u32 = 0x0001_0000;
1723/// Object has no-direct binding.
1724pub const DF_1_NODIRECT: u32 = 0x0002_0000;
1725pub const DF_1_IGNMULDEF: u32 = 0x0004_0000;
1726pub const DF_1_NOKSYMS: u32 = 0x0008_0000;
1727pub const DF_1_NOHDR: u32 = 0x0010_0000;
1728/// Object is modified after built.
1729pub const DF_1_EDITED: u32 = 0x0020_0000;
1730pub const DF_1_NORELOC: u32 = 0x0040_0000;
1731/// Object has individual interposers.
1732pub const DF_1_SYMINTPOSE: u32 = 0x0080_0000;
1733/// Global auditing required.
1734pub const DF_1_GLOBAUDIT: u32 = 0x0100_0000;
1735/// Singleton symbols are used.
1736pub const DF_1_SINGLETON: u32 = 0x0200_0000;
1737pub const DF_1_STUB: u32 = 0x0400_0000;
1738pub const DF_1_PIE: u32 = 0x0800_0000;
1739
1740/// Version symbol information
1741#[derive(Debug, Clone, Copy)]
1742#[repr(C)]
1743pub struct Versym<E: Endian>(pub U16<E>);
1744
1745/// Symbol is hidden.
1746pub const VERSYM_HIDDEN: u16 = 0x8000;
1747/// Symbol version index.
1748pub const VERSYM_VERSION: u16 = 0x7fff;
1749
1750/// Version definition sections
1751#[derive(Debug, Clone, Copy)]
1752#[repr(C)]
1753pub struct Verdef<E: Endian> {
1754    /// Version revision
1755    pub vd_version: U16<E>,
1756    /// Version information
1757    pub vd_flags: U16<E>,
1758    /// Version Index
1759    pub vd_ndx: U16<E>,
1760    /// Number of associated aux entries
1761    pub vd_cnt: U16<E>,
1762    /// Version name hash value
1763    pub vd_hash: U32<E>,
1764    /// Offset in bytes to verdaux array
1765    pub vd_aux: U32<E>,
1766    /// Offset in bytes to next verdef entry
1767    pub vd_next: U32<E>,
1768}
1769
1770// Legal values for vd_version (version revision).
1771/// No version
1772pub const VER_DEF_NONE: u16 = 0;
1773/// Current version
1774pub const VER_DEF_CURRENT: u16 = 1;
1775
1776// Legal values for vd_flags (version information flags).
1777/// Version definition of file itself
1778pub const VER_FLG_BASE: u16 = 0x1;
1779// Legal values for vd_flags and vna_flags (version information flags).
1780/// Weak version identifier
1781pub const VER_FLG_WEAK: u16 = 0x2;
1782
1783// Versym symbol index values.
1784/// Symbol is local.
1785pub const VER_NDX_LOCAL: u16 = 0;
1786/// Symbol is global.
1787pub const VER_NDX_GLOBAL: u16 = 1;
1788
1789/// Auxiliary version information.
1790#[derive(Debug, Clone, Copy)]
1791#[repr(C)]
1792pub struct Verdaux<E: Endian> {
1793    /// Version or dependency names
1794    pub vda_name: U32<E>,
1795    /// Offset in bytes to next verdaux
1796    pub vda_next: U32<E>,
1797}
1798
1799/// Version dependency.
1800#[derive(Debug, Clone, Copy)]
1801#[repr(C)]
1802pub struct Verneed<E: Endian> {
1803    /// Version of structure
1804    pub vn_version: U16<E>,
1805    /// Number of associated aux entries
1806    pub vn_cnt: U16<E>,
1807    /// Offset of filename for this dependency
1808    pub vn_file: U32<E>,
1809    /// Offset in bytes to vernaux array
1810    pub vn_aux: U32<E>,
1811    /// Offset in bytes to next verneed entry
1812    pub vn_next: U32<E>,
1813}
1814
1815// Legal values for vn_version (version revision).
1816/// No version
1817pub const VER_NEED_NONE: u16 = 0;
1818/// Current version
1819pub const VER_NEED_CURRENT: u16 = 1;
1820
1821/// Auxiliary needed version information.
1822#[derive(Debug, Clone, Copy)]
1823#[repr(C)]
1824pub struct Vernaux<E: Endian> {
1825    /// Hash value of dependency name
1826    pub vna_hash: U32<E>,
1827    /// Dependency specific information
1828    pub vna_flags: U16<E>,
1829    /// Version Index
1830    pub vna_other: U16<E>,
1831    /// Dependency name string offset
1832    pub vna_name: U32<E>,
1833    /// Offset in bytes to next vernaux entry
1834    pub vna_next: U32<E>,
1835}
1836
1837// TODO: Elf*_auxv_t, AT_*
1838
1839/// Note section entry header.
1840///
1841/// A note consists of a header followed by a variable length name and descriptor.
1842#[derive(Debug, Clone, Copy)]
1843#[repr(C)]
1844pub struct NoteHeader32<E: Endian> {
1845    /// Length of the note's name.
1846    ///
1847    /// Some known names are defined by the `ELF_NOTE_*` constants.
1848    pub n_namesz: U32<E>,
1849    /// Length of the note's descriptor.
1850    ///
1851    /// The content of the descriptor depends on the note name and type.
1852    pub n_descsz: U32<E>,
1853    /// Type of the note.
1854    ///
1855    /// One of the `NT_*` constants. The note name determines which
1856    /// `NT_*` constants are valid.
1857    pub n_type: U32<E>,
1858}
1859
1860/// Note section entry header.
1861#[derive(Debug, Clone, Copy)]
1862#[repr(C)]
1863pub struct NoteHeader64<E: Endian> {
1864    /// Length of the note's name.
1865    ///
1866    /// Some known names are defined by the `ELF_NOTE_*` constants.
1867    pub n_namesz: U32<E>,
1868    /// Length of the note's descriptor.
1869    ///
1870    /// The content of the descriptor depends on the note name and type.
1871    pub n_descsz: U32<E>,
1872    /// Type of the note.
1873    ///
1874    /// One of the `NT_*` constants. The note name determines which
1875    /// `NT_*` constants are valid.
1876    pub n_type: U32<E>,
1877}
1878
1879/// Solaris entries in the note section have this name.
1880pub const ELF_NOTE_SOLARIS: &[u8] = b"SUNW Solaris";
1881
1882// Values for `n_type` when the name is `ELF_NOTE_SOLARIS`.
1883/// Desired pagesize for the binary.
1884pub const NT_SOLARIS_PAGESIZE_HINT: u32 = 1;
1885
1886/// GNU entries in the note section have this name.
1887pub const ELF_NOTE_GNU: &[u8] = b"GNU";
1888
1889/// Go entries in the note section have this name.
1890// See https://go-review.googlesource.com/9520 and https://go-review.googlesource.com/10704.
1891pub const ELF_NOTE_GO: &[u8] = b"Go";
1892
1893// Note types for `ELF_NOTE_GNU`.
1894
1895/// ABI information.
1896///
1897/// The descriptor consists of words:
1898/// - word 0: OS descriptor
1899/// - word 1: major version of the ABI
1900/// - word 2: minor version of the ABI
1901/// - word 3: subminor version of the ABI
1902pub const NT_GNU_ABI_TAG: u32 = 1;
1903
1904/// OS descriptor for `NT_GNU_ABI_TAG`.
1905pub const ELF_NOTE_OS_LINUX: u32 = 0;
1906/// OS descriptor for `NT_GNU_ABI_TAG`.
1907pub const ELF_NOTE_OS_GNU: u32 = 1;
1908/// OS descriptor for `NT_GNU_ABI_TAG`.
1909pub const ELF_NOTE_OS_SOLARIS2: u32 = 2;
1910/// OS descriptor for `NT_GNU_ABI_TAG`.
1911pub const ELF_NOTE_OS_FREEBSD: u32 = 3;
1912
1913/// Synthetic hwcap information.
1914///
1915/// The descriptor begins with two words:
1916/// - word 0: number of entries
1917/// - word 1: bitmask of enabled entries
1918///
1919/// Then follow variable-length entries, one byte followed by a
1920/// '\0'-terminated hwcap name string.  The byte gives the bit
1921/// number to test if enabled, (1U << bit) & bitmask.  */
1922pub const NT_GNU_HWCAP: u32 = 2;
1923
1924/// Build ID bits as generated by `ld --build-id`.
1925///
1926/// The descriptor consists of any nonzero number of bytes.
1927pub const NT_GNU_BUILD_ID: u32 = 3;
1928
1929/// Build ID bits as generated by Go's gc compiler.
1930///
1931/// The descriptor consists of any nonzero number of bytes.
1932// See https://go-review.googlesource.com/10707.
1933pub const NT_GO_BUILD_ID: u32 = 4;
1934
1935/// Version note generated by GNU gold containing a version string.
1936pub const NT_GNU_GOLD_VERSION: u32 = 4;
1937
1938/// Program property.
1939pub const NT_GNU_PROPERTY_TYPE_0: u32 = 5;
1940
1941// Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0).
1942
1943/// Stack size.
1944pub const GNU_PROPERTY_STACK_SIZE: u32 = 1;
1945/// No copy relocation on protected data symbol.
1946pub const GNU_PROPERTY_NO_COPY_ON_PROTECTED: u32 = 2;
1947
1948// A 4-byte unsigned integer property: A bit is set if it is set in all
1949// relocatable inputs.
1950pub const GNU_PROPERTY_UINT32_AND_LO: u32 = 0xb0000000;
1951pub const GNU_PROPERTY_UINT32_AND_HI: u32 = 0xb0007fff;
1952
1953// A 4-byte unsigned integer property: A bit is set if it is set in any
1954// relocatable inputs.
1955pub const GNU_PROPERTY_UINT32_OR_LO: u32 = 0xb0008000;
1956pub const GNU_PROPERTY_UINT32_OR_HI: u32 = 0xb000ffff;
1957
1958/// The needed properties by the object file.  */
1959pub const GNU_PROPERTY_1_NEEDED: u32 = GNU_PROPERTY_UINT32_OR_LO;
1960
1961/// Set if the object file requires canonical function pointers and
1962/// cannot be used with copy relocation.
1963pub const GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS: u32 = 1 << 0;
1964
1965/// Processor-specific semantics, lo
1966pub const GNU_PROPERTY_LOPROC: u32 = 0xc0000000;
1967/// Processor-specific semantics, hi
1968pub const GNU_PROPERTY_HIPROC: u32 = 0xdfffffff;
1969/// Application-specific semantics, lo
1970pub const GNU_PROPERTY_LOUSER: u32 = 0xe0000000;
1971/// Application-specific semantics, hi
1972pub const GNU_PROPERTY_HIUSER: u32 = 0xffffffff;
1973
1974/// AArch64 specific GNU properties.
1975pub const GNU_PROPERTY_AARCH64_FEATURE_1_AND: u32 = 0xc0000000;
1976pub const GNU_PROPERTY_AARCH64_FEATURE_PAUTH: u32 = 0xc0000001;
1977
1978pub const GNU_PROPERTY_AARCH64_FEATURE_1_BTI: u32 = 1 << 0;
1979pub const GNU_PROPERTY_AARCH64_FEATURE_1_PAC: u32 = 1 << 1;
1980
1981// A 4-byte unsigned integer property: A bit is set if it is set in all
1982// relocatable inputs.
1983pub const GNU_PROPERTY_X86_UINT32_AND_LO: u32 = 0xc0000002;
1984pub const GNU_PROPERTY_X86_UINT32_AND_HI: u32 = 0xc0007fff;
1985
1986// A 4-byte unsigned integer property: A bit is set if it is set in any
1987// relocatable inputs.
1988pub const GNU_PROPERTY_X86_UINT32_OR_LO: u32 = 0xc0008000;
1989pub const GNU_PROPERTY_X86_UINT32_OR_HI: u32 = 0xc000ffff;
1990
1991// A 4-byte unsigned integer property: A bit is set if it is set in any
1992// relocatable inputs and the property is present in all relocatable
1993// inputs.
1994pub const GNU_PROPERTY_X86_UINT32_OR_AND_LO: u32 = 0xc0010000;
1995pub const GNU_PROPERTY_X86_UINT32_OR_AND_HI: u32 = 0xc0017fff;
1996
1997/// The x86 instruction sets indicated by the corresponding bits are
1998/// used in program.  Their support in the hardware is optional.
1999pub const GNU_PROPERTY_X86_ISA_1_USED: u32 = 0xc0010002;
2000/// The x86 instruction sets indicated by the corresponding bits are
2001/// used in program and they must be supported by the hardware.
2002pub const GNU_PROPERTY_X86_ISA_1_NEEDED: u32 = 0xc0008002;
2003/// X86 processor-specific features used in program.
2004pub const GNU_PROPERTY_X86_FEATURE_1_AND: u32 = 0xc0000002;
2005
2006/// GNU_PROPERTY_X86_ISA_1_BASELINE: CMOV, CX8 (cmpxchg8b), FPU (fld),
2007/// MMX, OSFXSR (fxsave), SCE (syscall), SSE and SSE2.
2008pub const GNU_PROPERTY_X86_ISA_1_BASELINE: u32 = 1 << 0;
2009/// GNU_PROPERTY_X86_ISA_1_V2: GNU_PROPERTY_X86_ISA_1_BASELINE,
2010/// CMPXCHG16B (cmpxchg16b), LAHF-SAHF (lahf), POPCNT (popcnt), SSE3,
2011/// SSSE3, SSE4.1 and SSE4.2.
2012pub const GNU_PROPERTY_X86_ISA_1_V2: u32 = 1 << 1;
2013/// GNU_PROPERTY_X86_ISA_1_V3: GNU_PROPERTY_X86_ISA_1_V2, AVX, AVX2, BMI1,
2014/// BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE.
2015pub const GNU_PROPERTY_X86_ISA_1_V3: u32 = 1 << 2;
2016/// GNU_PROPERTY_X86_ISA_1_V4: GNU_PROPERTY_X86_ISA_1_V3, AVX512F,
2017/// AVX512BW, AVX512CD, AVX512DQ and AVX512VL.
2018pub const GNU_PROPERTY_X86_ISA_1_V4: u32 = 1 << 3;
2019
2020/// This indicates that all executable sections are compatible with IBT.
2021pub const GNU_PROPERTY_X86_FEATURE_1_IBT: u32 = 1 << 0;
2022/// This indicates that all executable sections are compatible with SHSTK.
2023pub const GNU_PROPERTY_X86_FEATURE_1_SHSTK: u32 = 1 << 1;
2024
2025// TODO: Elf*_Move
2026
2027/// Header of `SHT_HASH` section.
2028#[derive(Debug, Clone, Copy)]
2029#[repr(C)]
2030pub struct HashHeader<E: Endian> {
2031    /// The number of hash buckets.
2032    pub bucket_count: U32<E>,
2033    /// The number of chain values.
2034    pub chain_count: U32<E>,
2035    // Array of hash bucket start indices.
2036    // buckets: U32<E>[bucket_count]
2037    // Array of hash chain links. An index of 0 terminates the chain.
2038    // chains: U32<E>[chain_count]
2039}
2040
2041/// Calculate the SysV hash for a symbol name.
2042///
2043/// Used for `SHT_HASH`.
2044pub fn hash(name: &[u8]) -> u32 {
2045    let mut hash = 0u32;
2046    for byte in name {
2047        hash = hash.wrapping_mul(16).wrapping_add(u32::from(*byte));
2048        hash ^= (hash >> 24) & 0xf0;
2049    }
2050    hash & 0xfff_ffff
2051}
2052
2053/// Header of `SHT_GNU_HASH` section.
2054#[derive(Debug, Clone, Copy)]
2055#[repr(C)]
2056pub struct GnuHashHeader<E: Endian> {
2057    /// The number of hash buckets.
2058    pub bucket_count: U32<E>,
2059    /// The symbol table index of the first symbol in the hash.
2060    pub symbol_base: U32<E>,
2061    /// The number of words in the bloom filter.
2062    ///
2063    /// Must be a non-zero power of 2.
2064    pub bloom_count: U32<E>,
2065    /// The bit shift count for the bloom filter.
2066    pub bloom_shift: U32<E>,
2067    // Array of bloom filter words.
2068    // bloom_filters: U32<E>[bloom_count] or U64<E>[bloom_count]
2069    // Array of hash bucket start indices.
2070    // buckets: U32<E>[bucket_count]
2071    // Array of hash values, one for each symbol starting at symbol_base.
2072    // values: U32<E>[symbol_count]
2073}
2074
2075/// Calculate the GNU hash for a symbol name.
2076///
2077/// Used for `SHT_GNU_HASH`.
2078pub fn gnu_hash(name: &[u8]) -> u32 {
2079    let mut hash = 5381u32;
2080    for byte in name {
2081        hash = hash.wrapping_mul(33).wrapping_add(u32::from(*byte));
2082    }
2083    hash
2084}
2085
2086// Motorola 68k specific definitions.
2087
2088// m68k values for `Rel*::r_type`.
2089
2090/// No reloc
2091pub const R_68K_NONE: u32 = 0;
2092/// Direct 32 bit
2093pub const R_68K_32: u32 = 1;
2094/// Direct 16 bit
2095pub const R_68K_16: u32 = 2;
2096/// Direct 8 bit
2097pub const R_68K_8: u32 = 3;
2098/// PC relative 32 bit
2099pub const R_68K_PC32: u32 = 4;
2100/// PC relative 16 bit
2101pub const R_68K_PC16: u32 = 5;
2102/// PC relative 8 bit
2103pub const R_68K_PC8: u32 = 6;
2104/// 32 bit PC relative GOT entry
2105pub const R_68K_GOT32: u32 = 7;
2106/// 16 bit PC relative GOT entry
2107pub const R_68K_GOT16: u32 = 8;
2108/// 8 bit PC relative GOT entry
2109pub const R_68K_GOT8: u32 = 9;
2110/// 32 bit GOT offset
2111pub const R_68K_GOT32O: u32 = 10;
2112/// 16 bit GOT offset
2113pub const R_68K_GOT16O: u32 = 11;
2114/// 8 bit GOT offset
2115pub const R_68K_GOT8O: u32 = 12;
2116/// 32 bit PC relative PLT address
2117pub const R_68K_PLT32: u32 = 13;
2118/// 16 bit PC relative PLT address
2119pub const R_68K_PLT16: u32 = 14;
2120/// 8 bit PC relative PLT address
2121pub const R_68K_PLT8: u32 = 15;
2122/// 32 bit PLT offset
2123pub const R_68K_PLT32O: u32 = 16;
2124/// 16 bit PLT offset
2125pub const R_68K_PLT16O: u32 = 17;
2126/// 8 bit PLT offset
2127pub const R_68K_PLT8O: u32 = 18;
2128/// Copy symbol at runtime
2129pub const R_68K_COPY: u32 = 19;
2130/// Create GOT entry
2131pub const R_68K_GLOB_DAT: u32 = 20;
2132/// Create PLT entry
2133pub const R_68K_JMP_SLOT: u32 = 21;
2134/// Adjust by program base
2135pub const R_68K_RELATIVE: u32 = 22;
2136/// 32 bit GOT offset for GD
2137pub const R_68K_TLS_GD32: u32 = 25;
2138/// 16 bit GOT offset for GD
2139pub const R_68K_TLS_GD16: u32 = 26;
2140/// 8 bit GOT offset for GD
2141pub const R_68K_TLS_GD8: u32 = 27;
2142/// 32 bit GOT offset for LDM
2143pub const R_68K_TLS_LDM32: u32 = 28;
2144/// 16 bit GOT offset for LDM
2145pub const R_68K_TLS_LDM16: u32 = 29;
2146/// 8 bit GOT offset for LDM
2147pub const R_68K_TLS_LDM8: u32 = 30;
2148/// 32 bit module-relative offset
2149pub const R_68K_TLS_LDO32: u32 = 31;
2150/// 16 bit module-relative offset
2151pub const R_68K_TLS_LDO16: u32 = 32;
2152/// 8 bit module-relative offset
2153pub const R_68K_TLS_LDO8: u32 = 33;
2154/// 32 bit GOT offset for IE
2155pub const R_68K_TLS_IE32: u32 = 34;
2156/// 16 bit GOT offset for IE
2157pub const R_68K_TLS_IE16: u32 = 35;
2158/// 8 bit GOT offset for IE
2159pub const R_68K_TLS_IE8: u32 = 36;
2160/// 32 bit offset relative to static TLS block
2161pub const R_68K_TLS_LE32: u32 = 37;
2162/// 16 bit offset relative to static TLS block
2163pub const R_68K_TLS_LE16: u32 = 38;
2164/// 8 bit offset relative to static TLS block
2165pub const R_68K_TLS_LE8: u32 = 39;
2166/// 32 bit module number
2167pub const R_68K_TLS_DTPMOD32: u32 = 40;
2168/// 32 bit module-relative offset
2169pub const R_68K_TLS_DTPREL32: u32 = 41;
2170/// 32 bit TP-relative offset
2171pub const R_68K_TLS_TPREL32: u32 = 42;
2172
2173// Intel 80386 specific definitions.
2174
2175// i386 values for `Rel*::r_type`.
2176
2177/// No reloc
2178pub const R_386_NONE: u32 = 0;
2179/// Direct 32 bit
2180pub const R_386_32: u32 = 1;
2181/// PC relative 32 bit
2182pub const R_386_PC32: u32 = 2;
2183/// 32 bit GOT entry
2184pub const R_386_GOT32: u32 = 3;
2185/// 32 bit PLT address
2186pub const R_386_PLT32: u32 = 4;
2187/// Copy symbol at runtime
2188pub const R_386_COPY: u32 = 5;
2189/// Create GOT entry
2190pub const R_386_GLOB_DAT: u32 = 6;
2191/// Create PLT entry
2192pub const R_386_JMP_SLOT: u32 = 7;
2193/// Adjust by program base
2194pub const R_386_RELATIVE: u32 = 8;
2195/// 32 bit offset to GOT
2196pub const R_386_GOTOFF: u32 = 9;
2197/// 32 bit PC relative offset to GOT
2198pub const R_386_GOTPC: u32 = 10;
2199/// Direct 32 bit PLT address
2200pub const R_386_32PLT: u32 = 11;
2201/// Offset in static TLS block
2202pub const R_386_TLS_TPOFF: u32 = 14;
2203/// Address of GOT entry for static TLS block offset
2204pub const R_386_TLS_IE: u32 = 15;
2205/// GOT entry for static TLS block offset
2206pub const R_386_TLS_GOTIE: u32 = 16;
2207/// Offset relative to static TLS block
2208pub const R_386_TLS_LE: u32 = 17;
2209/// Direct 32 bit for GNU version of general dynamic thread local data
2210pub const R_386_TLS_GD: u32 = 18;
2211/// Direct 32 bit for GNU version of local dynamic thread local data in LE code
2212pub const R_386_TLS_LDM: u32 = 19;
2213/// Direct 16 bit
2214pub const R_386_16: u32 = 20;
2215/// PC relative 16 bit
2216pub const R_386_PC16: u32 = 21;
2217/// Direct 8 bit
2218pub const R_386_8: u32 = 22;
2219/// PC relative 8 bit
2220pub const R_386_PC8: u32 = 23;
2221/// Direct 32 bit for general dynamic thread local data
2222pub const R_386_TLS_GD_32: u32 = 24;
2223/// Tag for pushl in GD TLS code
2224pub const R_386_TLS_GD_PUSH: u32 = 25;
2225/// Relocation for call to __tls_get_addr()
2226pub const R_386_TLS_GD_CALL: u32 = 26;
2227/// Tag for popl in GD TLS code
2228pub const R_386_TLS_GD_POP: u32 = 27;
2229/// Direct 32 bit for local dynamic thread local data in LE code
2230pub const R_386_TLS_LDM_32: u32 = 28;
2231/// Tag for pushl in LDM TLS code
2232pub const R_386_TLS_LDM_PUSH: u32 = 29;
2233/// Relocation for call to __tls_get_addr() in LDM code
2234pub const R_386_TLS_LDM_CALL: u32 = 30;
2235/// Tag for popl in LDM TLS code
2236pub const R_386_TLS_LDM_POP: u32 = 31;
2237/// Offset relative to TLS block
2238pub const R_386_TLS_LDO_32: u32 = 32;
2239/// GOT entry for negated static TLS block offset
2240pub const R_386_TLS_IE_32: u32 = 33;
2241/// Negated offset relative to static TLS block
2242pub const R_386_TLS_LE_32: u32 = 34;
2243/// ID of module containing symbol
2244pub const R_386_TLS_DTPMOD32: u32 = 35;
2245/// Offset in TLS block
2246pub const R_386_TLS_DTPOFF32: u32 = 36;
2247/// Negated offset in static TLS block
2248pub const R_386_TLS_TPOFF32: u32 = 37;
2249/// 32-bit symbol size
2250pub const R_386_SIZE32: u32 = 38;
2251/// GOT offset for TLS descriptor.
2252pub const R_386_TLS_GOTDESC: u32 = 39;
2253/// Marker of call through TLS descriptor for relaxation.
2254pub const R_386_TLS_DESC_CALL: u32 = 40;
2255/// TLS descriptor containing pointer to code and to argument, returning the TLS offset for the symbol.
2256pub const R_386_TLS_DESC: u32 = 41;
2257/// Adjust indirectly by program base
2258pub const R_386_IRELATIVE: u32 = 42;
2259/// Load from 32 bit GOT entry, relaxable.
2260pub const R_386_GOT32X: u32 = 43;
2261
2262// ADI SHARC specific definitions
2263
2264// SHARC values for `Rel*::r_type`
2265
2266/// 24-bit absolute address in bits 23:0 of a 48-bit instr
2267///
2268/// Targets:
2269///
2270/// * Type 25a (PC_DIRECT)
2271pub const R_SHARC_ADDR24_V3: u32 = 0x0b;
2272
2273/// 32-bit absolute address in bits 31:0 of a 48-bit instr
2274///
2275/// Targets:
2276///
2277/// * Type 14a
2278/// * Type 14d
2279/// * Type 15a
2280/// * Type 16a
2281/// * Type 17a
2282/// * Type 18a
2283/// * Type 19a
2284pub const R_SHARC_ADDR32_V3: u32 = 0x0c;
2285
2286/// 32-bit absolute address in bits 31:0 of a 32-bit data location
2287///
2288/// Represented with `RelocationEncoding::Generic`
2289pub const R_SHARC_ADDR_VAR_V3: u32 = 0x0d;
2290
2291/// 6-bit PC-relative address in bits 32:27 of a 48-bit instr
2292///
2293/// Targets:
2294///
2295/// * Type 9a
2296/// * Type 10a
2297pub const R_SHARC_PCRSHORT_V3: u32 = 0x0e;
2298
2299/// 24-bit PC-relative address in bits 23:0 of a 48-bit instr
2300///
2301/// Targets:
2302///
2303/// * Type 8a
2304/// * Type 12a (truncated to 23 bits after relocation)
2305/// * Type 13a (truncated to 23 bits after relocation)
2306/// * Type 25a (PC Relative)
2307pub const R_SHARC_PCRLONG_V3: u32 = 0x0f;
2308
2309/// 6-bit absolute address in bits 32:27 of a 48-bit instr
2310///
2311/// Targets:
2312///
2313/// * Type 4a
2314/// * Type 4b
2315/// * Type 4d
2316pub const R_SHARC_DATA6_V3: u32 = 0x10;
2317
2318/// 16-bit absolute address in bits 39:24 of a 48-bit instr
2319///
2320/// Targets:
2321///
2322/// * Type 12a
2323pub const R_SHARC_DATA16_V3: u32 = 0x11;
2324
2325/// 6-bit absolute address into bits 16:11 of a 32-bit instr
2326///
2327/// Targets:
2328///
2329/// * Type 4b
2330pub const R_SHARC_DATA6_VISA_V3: u32 = 0x12;
2331
2332/// 7-bit absolute address into bits 6:0 of a 32-bit instr
2333pub const R_SHARC_DATA7_VISA_V3: u32 = 0x13;
2334
2335/// 16-bit absolute address into bits 15:0 of a 32-bit instr
2336pub const R_SHARC_DATA16_VISA_V3: u32 = 0x14;
2337
2338/// 6-bit PC-relative address into bits 16:11 of a Type B
2339///
2340/// Targets:
2341///
2342/// * Type 9b
2343pub const R_SHARC_PCR6_VISA_V3: u32 = 0x17;
2344
2345/// 16-bit absolute address into bits 15:0 of a 16-bit location.
2346///
2347/// Represented with `RelocationEncoding::Generic`
2348pub const R_SHARC_ADDR_VAR16_V3: u32 = 0x19;
2349
2350pub const R_SHARC_CALC_PUSH_ADDR: u32 = 0xe0;
2351pub const R_SHARC_CALC_PUSH_ADDEND: u32 = 0xe1;
2352pub const R_SHARC_CALC_ADD: u32 = 0xe2;
2353pub const R_SHARC_CALC_SUB: u32 = 0xe3;
2354pub const R_SHARC_CALC_MUL: u32 = 0xe4;
2355pub const R_SHARC_CALC_DIV: u32 = 0xe5;
2356pub const R_SHARC_CALC_MOD: u32 = 0xe6;
2357pub const R_SHARC_CALC_LSHIFT: u32 = 0xe7;
2358pub const R_SHARC_CALC_RSHIFT: u32 = 0xe8;
2359pub const R_SHARC_CALC_AND: u32 = 0xe9;
2360pub const R_SHARC_CALC_OR: u32 = 0xea;
2361pub const R_SHARC_CALC_XOR: u32 = 0xeb;
2362pub const R_SHARC_CALC_PUSH_LEN: u32 = 0xec;
2363pub const R_SHARC_CALC_NOT: u32 = 0xf6;
2364
2365// SHARC values for `SectionHeader*::sh_type`.
2366
2367/// .adi.attributes
2368pub const SHT_SHARC_ADI_ATTRIBUTES: u32 = SHT_LOPROC + 0x2;
2369
2370// SUN SPARC specific definitions.
2371
2372// SPARC values for `st_type` component of `Sym*::st_info`.
2373
2374/// Global register reserved to app.
2375pub const STT_SPARC_REGISTER: u8 = 13;
2376
2377// SPARC values for `FileHeader64::e_flags`.
2378
2379pub const EF_SPARCV9_MM: u32 = 3;
2380pub const EF_SPARCV9_TSO: u32 = 0;
2381pub const EF_SPARCV9_PSO: u32 = 1;
2382pub const EF_SPARCV9_RMO: u32 = 2;
2383/// little endian data
2384pub const EF_SPARC_LEDATA: u32 = 0x80_0000;
2385pub const EF_SPARC_EXT_MASK: u32 = 0xFF_FF00;
2386/// generic V8+ features
2387pub const EF_SPARC_32PLUS: u32 = 0x00_0100;
2388/// Sun UltraSPARC1 extensions
2389pub const EF_SPARC_SUN_US1: u32 = 0x00_0200;
2390/// HAL R1 extensions
2391pub const EF_SPARC_HAL_R1: u32 = 0x00_0400;
2392/// Sun UltraSPARCIII extensions
2393pub const EF_SPARC_SUN_US3: u32 = 0x00_0800;
2394
2395// SPARC values for `Rel*::r_type`.
2396
2397/// No reloc
2398pub const R_SPARC_NONE: u32 = 0;
2399/// Direct 8 bit
2400pub const R_SPARC_8: u32 = 1;
2401/// Direct 16 bit
2402pub const R_SPARC_16: u32 = 2;
2403/// Direct 32 bit
2404pub const R_SPARC_32: u32 = 3;
2405/// PC relative 8 bit
2406pub const R_SPARC_DISP8: u32 = 4;
2407/// PC relative 16 bit
2408pub const R_SPARC_DISP16: u32 = 5;
2409/// PC relative 32 bit
2410pub const R_SPARC_DISP32: u32 = 6;
2411/// PC relative 30 bit shifted
2412pub const R_SPARC_WDISP30: u32 = 7;
2413/// PC relative 22 bit shifted
2414pub const R_SPARC_WDISP22: u32 = 8;
2415/// High 22 bit
2416pub const R_SPARC_HI22: u32 = 9;
2417/// Direct 22 bit
2418pub const R_SPARC_22: u32 = 10;
2419/// Direct 13 bit
2420pub const R_SPARC_13: u32 = 11;
2421/// Truncated 10 bit
2422pub const R_SPARC_LO10: u32 = 12;
2423/// Truncated 10 bit GOT entry
2424pub const R_SPARC_GOT10: u32 = 13;
2425/// 13 bit GOT entry
2426pub const R_SPARC_GOT13: u32 = 14;
2427/// 22 bit GOT entry shifted
2428pub const R_SPARC_GOT22: u32 = 15;
2429/// PC relative 10 bit truncated
2430pub const R_SPARC_PC10: u32 = 16;
2431/// PC relative 22 bit shifted
2432pub const R_SPARC_PC22: u32 = 17;
2433/// 30 bit PC relative PLT address
2434pub const R_SPARC_WPLT30: u32 = 18;
2435/// Copy symbol at runtime
2436pub const R_SPARC_COPY: u32 = 19;
2437/// Create GOT entry
2438pub const R_SPARC_GLOB_DAT: u32 = 20;
2439/// Create PLT entry
2440pub const R_SPARC_JMP_SLOT: u32 = 21;
2441/// Adjust by program base
2442pub const R_SPARC_RELATIVE: u32 = 22;
2443/// Direct 32 bit unaligned
2444pub const R_SPARC_UA32: u32 = 23;
2445
2446// Sparc64 values for `Rel*::r_type`.
2447
2448/// Direct 32 bit ref to PLT entry
2449pub const R_SPARC_PLT32: u32 = 24;
2450/// High 22 bit PLT entry
2451pub const R_SPARC_HIPLT22: u32 = 25;
2452/// Truncated 10 bit PLT entry
2453pub const R_SPARC_LOPLT10: u32 = 26;
2454/// PC rel 32 bit ref to PLT entry
2455pub const R_SPARC_PCPLT32: u32 = 27;
2456/// PC rel high 22 bit PLT entry
2457pub const R_SPARC_PCPLT22: u32 = 28;
2458/// PC rel trunc 10 bit PLT entry
2459pub const R_SPARC_PCPLT10: u32 = 29;
2460/// Direct 10 bit
2461pub const R_SPARC_10: u32 = 30;
2462/// Direct 11 bit
2463pub const R_SPARC_11: u32 = 31;
2464/// Direct 64 bit
2465pub const R_SPARC_64: u32 = 32;
2466/// 10bit with secondary 13bit addend
2467pub const R_SPARC_OLO10: u32 = 33;
2468/// Top 22 bits of direct 64 bit
2469pub const R_SPARC_HH22: u32 = 34;
2470/// High middle 10 bits of ...
2471pub const R_SPARC_HM10: u32 = 35;
2472/// Low middle 22 bits of ...
2473pub const R_SPARC_LM22: u32 = 36;
2474/// Top 22 bits of pc rel 64 bit
2475pub const R_SPARC_PC_HH22: u32 = 37;
2476/// High middle 10 bit of ...
2477pub const R_SPARC_PC_HM10: u32 = 38;
2478/// Low miggle 22 bits of ...
2479pub const R_SPARC_PC_LM22: u32 = 39;
2480/// PC relative 16 bit shifted
2481pub const R_SPARC_WDISP16: u32 = 40;
2482/// PC relative 19 bit shifted
2483pub const R_SPARC_WDISP19: u32 = 41;
2484/// was part of v9 ABI but was removed
2485pub const R_SPARC_GLOB_JMP: u32 = 42;
2486/// Direct 7 bit
2487pub const R_SPARC_7: u32 = 43;
2488/// Direct 5 bit
2489pub const R_SPARC_5: u32 = 44;
2490/// Direct 6 bit
2491pub const R_SPARC_6: u32 = 45;
2492/// PC relative 64 bit
2493pub const R_SPARC_DISP64: u32 = 46;
2494/// Direct 64 bit ref to PLT entry
2495pub const R_SPARC_PLT64: u32 = 47;
2496/// High 22 bit complemented
2497pub const R_SPARC_HIX22: u32 = 48;
2498/// Truncated 11 bit complemented
2499pub const R_SPARC_LOX10: u32 = 49;
2500/// Direct high 12 of 44 bit
2501pub const R_SPARC_H44: u32 = 50;
2502/// Direct mid 22 of 44 bit
2503pub const R_SPARC_M44: u32 = 51;
2504/// Direct low 10 of 44 bit
2505pub const R_SPARC_L44: u32 = 52;
2506/// Global register usage
2507pub const R_SPARC_REGISTER: u32 = 53;
2508/// Direct 64 bit unaligned
2509pub const R_SPARC_UA64: u32 = 54;
2510/// Direct 16 bit unaligned
2511pub const R_SPARC_UA16: u32 = 55;
2512pub const R_SPARC_TLS_GD_HI22: u32 = 56;
2513pub const R_SPARC_TLS_GD_LO10: u32 = 57;
2514pub const R_SPARC_TLS_GD_ADD: u32 = 58;
2515pub const R_SPARC_TLS_GD_CALL: u32 = 59;
2516pub const R_SPARC_TLS_LDM_HI22: u32 = 60;
2517pub const R_SPARC_TLS_LDM_LO10: u32 = 61;
2518pub const R_SPARC_TLS_LDM_ADD: u32 = 62;
2519pub const R_SPARC_TLS_LDM_CALL: u32 = 63;
2520pub const R_SPARC_TLS_LDO_HIX22: u32 = 64;
2521pub const R_SPARC_TLS_LDO_LOX10: u32 = 65;
2522pub const R_SPARC_TLS_LDO_ADD: u32 = 66;
2523pub const R_SPARC_TLS_IE_HI22: u32 = 67;
2524pub const R_SPARC_TLS_IE_LO10: u32 = 68;
2525pub const R_SPARC_TLS_IE_LD: u32 = 69;
2526pub const R_SPARC_TLS_IE_LDX: u32 = 70;
2527pub const R_SPARC_TLS_IE_ADD: u32 = 71;
2528pub const R_SPARC_TLS_LE_HIX22: u32 = 72;
2529pub const R_SPARC_TLS_LE_LOX10: u32 = 73;
2530pub const R_SPARC_TLS_DTPMOD32: u32 = 74;
2531pub const R_SPARC_TLS_DTPMOD64: u32 = 75;
2532pub const R_SPARC_TLS_DTPOFF32: u32 = 76;
2533pub const R_SPARC_TLS_DTPOFF64: u32 = 77;
2534pub const R_SPARC_TLS_TPOFF32: u32 = 78;
2535pub const R_SPARC_TLS_TPOFF64: u32 = 79;
2536pub const R_SPARC_GOTDATA_HIX22: u32 = 80;
2537pub const R_SPARC_GOTDATA_LOX10: u32 = 81;
2538pub const R_SPARC_GOTDATA_OP_HIX22: u32 = 82;
2539pub const R_SPARC_GOTDATA_OP_LOX10: u32 = 83;
2540pub const R_SPARC_GOTDATA_OP: u32 = 84;
2541pub const R_SPARC_H34: u32 = 85;
2542pub const R_SPARC_SIZE32: u32 = 86;
2543pub const R_SPARC_SIZE64: u32 = 87;
2544pub const R_SPARC_WDISP10: u32 = 88;
2545pub const R_SPARC_JMP_IREL: u32 = 248;
2546pub const R_SPARC_IRELATIVE: u32 = 249;
2547pub const R_SPARC_GNU_VTINHERIT: u32 = 250;
2548pub const R_SPARC_GNU_VTENTRY: u32 = 251;
2549pub const R_SPARC_REV32: u32 = 252;
2550
2551// Sparc64 values for `Dyn32::d_tag`.
2552
2553pub const DT_SPARC_REGISTER: i64 = 0x7000_0001;
2554
2555// MIPS R3000 specific definitions.
2556
2557// MIPS values for `FileHeader32::e_flags`.
2558
2559/// A .noreorder directive was used.
2560pub const EF_MIPS_NOREORDER: u32 = 1;
2561/// Contains PIC code.
2562pub const EF_MIPS_PIC: u32 = 2;
2563/// Uses PIC calling sequence.
2564pub const EF_MIPS_CPIC: u32 = 4;
2565pub const EF_MIPS_XGOT: u32 = 8;
2566pub const EF_MIPS_64BIT_WHIRL: u32 = 16;
2567pub const EF_MIPS_ABI2: u32 = 32;
2568pub const EF_MIPS_ABI_ON32: u32 = 64;
2569/// Uses FP64 (12 callee-saved).
2570pub const EF_MIPS_FP64: u32 = 512;
2571/// Uses IEEE 754-2008 NaN encoding.
2572pub const EF_MIPS_NAN2008: u32 = 1024;
2573/// MIPS architecture level.
2574pub const EF_MIPS_ARCH: u32 = 0xf000_0000;
2575
2576/// The first MIPS 32 bit ABI
2577pub const EF_MIPS_ABI_O32: u32 = 0x0000_1000;
2578/// O32 ABI extended for 64-bit architectures
2579pub const EF_MIPS_ABI_O64: u32 = 0x0000_2000;
2580/// EABI in 32-bit mode
2581pub const EF_MIPS_ABI_EABI32: u32 = 0x0000_3000;
2582/// EABI in 64-bit mode
2583pub const EF_MIPS_ABI_EABI64: u32 = 0x0000_4000;
2584/// Mask for selecting EF_MIPS_ABI_ variant
2585pub const EF_MIPS_ABI: u32 = 0x0000_f000;
2586
2587// Legal values for MIPS architecture level.
2588
2589/// -mips1 code.
2590pub const EF_MIPS_ARCH_1: u32 = 0x0000_0000;
2591/// -mips2 code.
2592pub const EF_MIPS_ARCH_2: u32 = 0x1000_0000;
2593/// -mips3 code.
2594pub const EF_MIPS_ARCH_3: u32 = 0x2000_0000;
2595/// -mips4 code.
2596pub const EF_MIPS_ARCH_4: u32 = 0x3000_0000;
2597/// -mips5 code.
2598pub const EF_MIPS_ARCH_5: u32 = 0x4000_0000;
2599/// MIPS32 code.
2600pub const EF_MIPS_ARCH_32: u32 = 0x5000_0000;
2601/// MIPS64 code.
2602pub const EF_MIPS_ARCH_64: u32 = 0x6000_0000;
2603/// MIPS32r2 code.
2604pub const EF_MIPS_ARCH_32R2: u32 = 0x7000_0000;
2605/// MIPS64r2 code.
2606pub const EF_MIPS_ARCH_64R2: u32 = 0x8000_0000;
2607/// MIPS32r6 code
2608pub const EF_MIPS_ARCH_32R6: u32 = 0x9000_0000;
2609/// MIPS64r6 code
2610pub const EF_MIPS_ARCH_64R6: u32 = 0xa000_0000;
2611
2612// MIPS values for `Sym32::st_shndx`.
2613
2614/// Allocated common symbols.
2615pub const SHN_MIPS_ACOMMON: u16 = 0xff00;
2616/// Allocated test symbols.
2617pub const SHN_MIPS_TEXT: u16 = 0xff01;
2618/// Allocated data symbols.
2619pub const SHN_MIPS_DATA: u16 = 0xff02;
2620/// Small common symbols.
2621pub const SHN_MIPS_SCOMMON: u16 = 0xff03;
2622/// Small undefined symbols.
2623pub const SHN_MIPS_SUNDEFINED: u16 = 0xff04;
2624
2625// MIPS values for `SectionHeader32::sh_type`.
2626
2627/// Shared objects used in link.
2628pub const SHT_MIPS_LIBLIST: u32 = 0x7000_0000;
2629pub const SHT_MIPS_MSYM: u32 = 0x7000_0001;
2630/// Conflicting symbols.
2631pub const SHT_MIPS_CONFLICT: u32 = 0x7000_0002;
2632/// Global data area sizes.
2633pub const SHT_MIPS_GPTAB: u32 = 0x7000_0003;
2634/// Reserved for SGI/MIPS compilers
2635pub const SHT_MIPS_UCODE: u32 = 0x7000_0004;
2636/// MIPS ECOFF debugging info.
2637pub const SHT_MIPS_DEBUG: u32 = 0x7000_0005;
2638/// Register usage information.
2639pub const SHT_MIPS_REGINFO: u32 = 0x7000_0006;
2640pub const SHT_MIPS_PACKAGE: u32 = 0x7000_0007;
2641pub const SHT_MIPS_PACKSYM: u32 = 0x7000_0008;
2642pub const SHT_MIPS_RELD: u32 = 0x7000_0009;
2643pub const SHT_MIPS_IFACE: u32 = 0x7000_000b;
2644pub const SHT_MIPS_CONTENT: u32 = 0x7000_000c;
2645/// Miscellaneous options.
2646pub const SHT_MIPS_OPTIONS: u32 = 0x7000_000d;
2647pub const SHT_MIPS_SHDR: u32 = 0x7000_0010;
2648pub const SHT_MIPS_FDESC: u32 = 0x7000_0011;
2649pub const SHT_MIPS_EXTSYM: u32 = 0x7000_0012;
2650pub const SHT_MIPS_DENSE: u32 = 0x7000_0013;
2651pub const SHT_MIPS_PDESC: u32 = 0x7000_0014;
2652pub const SHT_MIPS_LOCSYM: u32 = 0x7000_0015;
2653pub const SHT_MIPS_AUXSYM: u32 = 0x7000_0016;
2654pub const SHT_MIPS_OPTSYM: u32 = 0x7000_0017;
2655pub const SHT_MIPS_LOCSTR: u32 = 0x7000_0018;
2656pub const SHT_MIPS_LINE: u32 = 0x7000_0019;
2657pub const SHT_MIPS_RFDESC: u32 = 0x7000_001a;
2658pub const SHT_MIPS_DELTASYM: u32 = 0x7000_001b;
2659pub const SHT_MIPS_DELTAINST: u32 = 0x7000_001c;
2660pub const SHT_MIPS_DELTACLASS: u32 = 0x7000_001d;
2661/// DWARF debugging information.
2662pub const SHT_MIPS_DWARF: u32 = 0x7000_001e;
2663pub const SHT_MIPS_DELTADECL: u32 = 0x7000_001f;
2664pub const SHT_MIPS_SYMBOL_LIB: u32 = 0x7000_0020;
2665/// Event section.
2666pub const SHT_MIPS_EVENTS: u32 = 0x7000_0021;
2667pub const SHT_MIPS_TRANSLATE: u32 = 0x7000_0022;
2668pub const SHT_MIPS_PIXIE: u32 = 0x7000_0023;
2669pub const SHT_MIPS_XLATE: u32 = 0x7000_0024;
2670pub const SHT_MIPS_XLATE_DEBUG: u32 = 0x7000_0025;
2671pub const SHT_MIPS_WHIRL: u32 = 0x7000_0026;
2672pub const SHT_MIPS_EH_REGION: u32 = 0x7000_0027;
2673pub const SHT_MIPS_XLATE_OLD: u32 = 0x7000_0028;
2674pub const SHT_MIPS_PDR_EXCEPTION: u32 = 0x7000_0029;
2675
2676// MIPS values for `SectionHeader32::sh_flags`.
2677
2678/// Must be in global data area.
2679pub const SHF_MIPS_GPREL: u32 = 0x1000_0000;
2680pub const SHF_MIPS_MERGE: u32 = 0x2000_0000;
2681pub const SHF_MIPS_ADDR: u32 = 0x4000_0000;
2682pub const SHF_MIPS_STRINGS: u32 = 0x8000_0000;
2683pub const SHF_MIPS_NOSTRIP: u32 = 0x0800_0000;
2684pub const SHF_MIPS_LOCAL: u32 = 0x0400_0000;
2685pub const SHF_MIPS_NAMES: u32 = 0x0200_0000;
2686pub const SHF_MIPS_NODUPE: u32 = 0x0100_0000;
2687
2688// MIPS values for `Sym32::st_other`.
2689
2690pub const STO_MIPS_PLT: u8 = 0x8;
2691/// Only valid for `STB_MIPS_SPLIT_COMMON`.
2692pub const STO_MIPS_SC_ALIGN_UNUSED: u8 = 0xff;
2693
2694// MIPS values for `Sym32::st_info'.
2695pub const STB_MIPS_SPLIT_COMMON: u8 = 13;
2696
2697// Entries found in sections of type `SHT_MIPS_GPTAB`.
2698
2699// TODO: Elf32_gptab, Elf32_RegInfo, Elf_Options
2700
2701// Values for `Elf_Options::kind`.
2702
2703/// Undefined.
2704pub const ODK_NULL: u32 = 0;
2705/// Register usage information.
2706pub const ODK_REGINFO: u32 = 1;
2707/// Exception processing options.
2708pub const ODK_EXCEPTIONS: u32 = 2;
2709/// Section padding options.
2710pub const ODK_PAD: u32 = 3;
2711/// Hardware workarounds performed
2712pub const ODK_HWPATCH: u32 = 4;
2713/// record the fill value used by the linker.
2714pub const ODK_FILL: u32 = 5;
2715/// reserve space for desktop tools to write.
2716pub const ODK_TAGS: u32 = 6;
2717/// HW workarounds.  'AND' bits when merging.
2718pub const ODK_HWAND: u32 = 7;
2719/// HW workarounds.  'OR' bits when merging.
2720pub const ODK_HWOR: u32 = 8;
2721
2722// Values for `Elf_Options::info` for `ODK_EXCEPTIONS` entries.
2723
2724/// FPE's which MUST be enabled.
2725pub const OEX_FPU_MIN: u32 = 0x1f;
2726/// FPE's which MAY be enabled.
2727pub const OEX_FPU_MAX: u32 = 0x1f00;
2728/// page zero must be mapped.
2729pub const OEX_PAGE0: u32 = 0x10000;
2730/// Force sequential memory mode?
2731pub const OEX_SMM: u32 = 0x20000;
2732/// Force floating point debug mode?
2733pub const OEX_FPDBUG: u32 = 0x40000;
2734pub const OEX_PRECISEFP: u32 = OEX_FPDBUG;
2735/// Dismiss invalid address faults?
2736pub const OEX_DISMISS: u32 = 0x80000;
2737
2738pub const OEX_FPU_INVAL: u32 = 0x10;
2739pub const OEX_FPU_DIV0: u32 = 0x08;
2740pub const OEX_FPU_OFLO: u32 = 0x04;
2741pub const OEX_FPU_UFLO: u32 = 0x02;
2742pub const OEX_FPU_INEX: u32 = 0x01;
2743
2744// Masks for `Elf_Options::info` for an `ODK_HWPATCH` entry.  */
2745/// R4000 end-of-page patch.
2746pub const OHW_R4KEOP: u32 = 0x1;
2747/// may need R8000 prefetch patch.
2748pub const OHW_R8KPFETCH: u32 = 0x2;
2749/// R5000 end-of-page patch.
2750pub const OHW_R5KEOP: u32 = 0x4;
2751/// R5000 cvt.\[ds\].l bug.  clean=1.
2752pub const OHW_R5KCVTL: u32 = 0x8;
2753
2754pub const OPAD_PREFIX: u32 = 0x1;
2755pub const OPAD_POSTFIX: u32 = 0x2;
2756pub const OPAD_SYMBOL: u32 = 0x4;
2757
2758// Entries found in sections of type `SHT_MIPS_OPTIONS`.
2759
2760// TODO: Elf_Options_Hw
2761
2762// Masks for `ElfOptions::info` for `ODK_HWAND` and `ODK_HWOR` entries.
2763
2764pub const OHWA0_R4KEOP_CHECKED: u32 = 0x0000_0001;
2765pub const OHWA1_R4KEOP_CLEAN: u32 = 0x0000_0002;
2766
2767// MIPS values for `Rel*::r_type`.
2768
2769/// No reloc
2770pub const R_MIPS_NONE: u32 = 0;
2771/// Direct 16 bit
2772pub const R_MIPS_16: u32 = 1;
2773/// Direct 32 bit
2774pub const R_MIPS_32: u32 = 2;
2775/// PC relative 32 bit
2776pub const R_MIPS_REL32: u32 = 3;
2777/// Direct 26 bit shifted
2778pub const R_MIPS_26: u32 = 4;
2779/// High 16 bit
2780pub const R_MIPS_HI16: u32 = 5;
2781/// Low 16 bit
2782pub const R_MIPS_LO16: u32 = 6;
2783/// GP relative 16 bit
2784pub const R_MIPS_GPREL16: u32 = 7;
2785/// 16 bit literal entry
2786pub const R_MIPS_LITERAL: u32 = 8;
2787/// 16 bit GOT entry
2788pub const R_MIPS_GOT16: u32 = 9;
2789/// PC relative 16 bit
2790pub const R_MIPS_PC16: u32 = 10;
2791/// 16 bit GOT entry for function
2792pub const R_MIPS_CALL16: u32 = 11;
2793/// GP relative 32 bit
2794pub const R_MIPS_GPREL32: u32 = 12;
2795
2796pub const R_MIPS_SHIFT5: u32 = 16;
2797pub const R_MIPS_SHIFT6: u32 = 17;
2798pub const R_MIPS_64: u32 = 18;
2799pub const R_MIPS_GOT_DISP: u32 = 19;
2800pub const R_MIPS_GOT_PAGE: u32 = 20;
2801pub const R_MIPS_GOT_OFST: u32 = 21;
2802pub const R_MIPS_GOT_HI16: u32 = 22;
2803pub const R_MIPS_GOT_LO16: u32 = 23;
2804pub const R_MIPS_SUB: u32 = 24;
2805pub const R_MIPS_INSERT_A: u32 = 25;
2806pub const R_MIPS_INSERT_B: u32 = 26;
2807pub const R_MIPS_DELETE: u32 = 27;
2808pub const R_MIPS_HIGHER: u32 = 28;
2809pub const R_MIPS_HIGHEST: u32 = 29;
2810pub const R_MIPS_CALL_HI16: u32 = 30;
2811pub const R_MIPS_CALL_LO16: u32 = 31;
2812pub const R_MIPS_SCN_DISP: u32 = 32;
2813pub const R_MIPS_REL16: u32 = 33;
2814pub const R_MIPS_ADD_IMMEDIATE: u32 = 34;
2815pub const R_MIPS_PJUMP: u32 = 35;
2816pub const R_MIPS_RELGOT: u32 = 36;
2817pub const R_MIPS_JALR: u32 = 37;
2818/// Module number 32 bit
2819pub const R_MIPS_TLS_DTPMOD32: u32 = 38;
2820/// Module-relative offset 32 bit
2821pub const R_MIPS_TLS_DTPREL32: u32 = 39;
2822/// Module number 64 bit
2823pub const R_MIPS_TLS_DTPMOD64: u32 = 40;
2824/// Module-relative offset 64 bit
2825pub const R_MIPS_TLS_DTPREL64: u32 = 41;
2826/// 16 bit GOT offset for GD
2827pub const R_MIPS_TLS_GD: u32 = 42;
2828/// 16 bit GOT offset for LDM
2829pub const R_MIPS_TLS_LDM: u32 = 43;
2830/// Module-relative offset, high 16 bits
2831pub const R_MIPS_TLS_DTPREL_HI16: u32 = 44;
2832/// Module-relative offset, low 16 bits
2833pub const R_MIPS_TLS_DTPREL_LO16: u32 = 45;
2834/// 16 bit GOT offset for IE
2835pub const R_MIPS_TLS_GOTTPREL: u32 = 46;
2836/// TP-relative offset, 32 bit
2837pub const R_MIPS_TLS_TPREL32: u32 = 47;
2838/// TP-relative offset, 64 bit
2839pub const R_MIPS_TLS_TPREL64: u32 = 48;
2840/// TP-relative offset, high 16 bits
2841pub const R_MIPS_TLS_TPREL_HI16: u32 = 49;
2842/// TP-relative offset, low 16 bits
2843pub const R_MIPS_TLS_TPREL_LO16: u32 = 50;
2844pub const R_MIPS_GLOB_DAT: u32 = 51;
2845pub const R_MIPS_COPY: u32 = 126;
2846pub const R_MIPS_JUMP_SLOT: u32 = 127;
2847
2848// MIPS values for `ProgramHeader32::p_type`.
2849
2850/// Register usage information.
2851pub const PT_MIPS_REGINFO: u32 = 0x7000_0000;
2852/// Runtime procedure table.
2853pub const PT_MIPS_RTPROC: u32 = 0x7000_0001;
2854pub const PT_MIPS_OPTIONS: u32 = 0x7000_0002;
2855/// FP mode requirement.
2856pub const PT_MIPS_ABIFLAGS: u32 = 0x7000_0003;
2857
2858// MIPS values for `ProgramHeader32::p_flags`.
2859
2860pub const PF_MIPS_LOCAL: u32 = 0x1000_0000;
2861
2862// MIPS values for `Dyn32::d_tag`.
2863
2864/// Runtime linker interface version
2865pub const DT_MIPS_RLD_VERSION: i64 = 0x7000_0001;
2866/// Timestamp
2867pub const DT_MIPS_TIME_STAMP: i64 = 0x7000_0002;
2868/// Checksum
2869pub const DT_MIPS_ICHECKSUM: i64 = 0x7000_0003;
2870/// Version string (string tbl index)
2871pub const DT_MIPS_IVERSION: i64 = 0x7000_0004;
2872/// Flags
2873pub const DT_MIPS_FLAGS: i64 = 0x7000_0005;
2874/// Base address
2875pub const DT_MIPS_BASE_ADDRESS: i64 = 0x7000_0006;
2876pub const DT_MIPS_MSYM: i64 = 0x7000_0007;
2877/// Address of CONFLICT section
2878pub const DT_MIPS_CONFLICT: i64 = 0x7000_0008;
2879/// Address of LIBLIST section
2880pub const DT_MIPS_LIBLIST: i64 = 0x7000_0009;
2881/// Number of local GOT entries
2882pub const DT_MIPS_LOCAL_GOTNO: i64 = 0x7000_000a;
2883/// Number of CONFLICT entries
2884pub const DT_MIPS_CONFLICTNO: i64 = 0x7000_000b;
2885/// Number of LIBLIST entries
2886pub const DT_MIPS_LIBLISTNO: i64 = 0x7000_0010;
2887/// Number of DYNSYM entries
2888pub const DT_MIPS_SYMTABNO: i64 = 0x7000_0011;
2889/// First external DYNSYM
2890pub const DT_MIPS_UNREFEXTNO: i64 = 0x7000_0012;
2891/// First GOT entry in DYNSYM
2892pub const DT_MIPS_GOTSYM: i64 = 0x7000_0013;
2893/// Number of GOT page table entries
2894pub const DT_MIPS_HIPAGENO: i64 = 0x7000_0014;
2895/// Address of run time loader map.
2896pub const DT_MIPS_RLD_MAP: i64 = 0x7000_0016;
2897/// Delta C++ class definition.
2898pub const DT_MIPS_DELTA_CLASS: i64 = 0x7000_0017;
2899/// Number of entries in DT_MIPS_DELTA_CLASS.
2900pub const DT_MIPS_DELTA_CLASS_NO: i64 = 0x7000_0018;
2901/// Delta C++ class instances.
2902pub const DT_MIPS_DELTA_INSTANCE: i64 = 0x7000_0019;
2903/// Number of entries in DT_MIPS_DELTA_INSTANCE.
2904pub const DT_MIPS_DELTA_INSTANCE_NO: i64 = 0x7000_001a;
2905/// Delta relocations.
2906pub const DT_MIPS_DELTA_RELOC: i64 = 0x7000_001b;
2907/// Number of entries in DT_MIPS_DELTA_RELOC.
2908pub const DT_MIPS_DELTA_RELOC_NO: i64 = 0x7000_001c;
2909/// Delta symbols that Delta relocations refer to.
2910pub const DT_MIPS_DELTA_SYM: i64 = 0x7000_001d;
2911/// Number of entries in DT_MIPS_DELTA_SYM.
2912pub const DT_MIPS_DELTA_SYM_NO: i64 = 0x7000_001e;
2913/// Delta symbols that hold the class declaration.
2914pub const DT_MIPS_DELTA_CLASSSYM: i64 = 0x7000_0020;
2915/// Number of entries in DT_MIPS_DELTA_CLASSSYM.
2916pub const DT_MIPS_DELTA_CLASSSYM_NO: i64 = 0x7000_0021;
2917/// Flags indicating for C++ flavor.
2918pub const DT_MIPS_CXX_FLAGS: i64 = 0x7000_0022;
2919pub const DT_MIPS_PIXIE_INIT: i64 = 0x7000_0023;
2920pub const DT_MIPS_SYMBOL_LIB: i64 = 0x7000_0024;
2921pub const DT_MIPS_LOCALPAGE_GOTIDX: i64 = 0x7000_0025;
2922pub const DT_MIPS_LOCAL_GOTIDX: i64 = 0x7000_0026;
2923pub const DT_MIPS_HIDDEN_GOTIDX: i64 = 0x7000_0027;
2924pub const DT_MIPS_PROTECTED_GOTIDX: i64 = 0x7000_0028;
2925/// Address of .options.
2926pub const DT_MIPS_OPTIONS: i64 = 0x7000_0029;
2927/// Address of .interface.
2928pub const DT_MIPS_INTERFACE: i64 = 0x7000_002a;
2929pub const DT_MIPS_DYNSTR_ALIGN: i64 = 0x7000_002b;
2930/// Size of the .interface section.
2931pub const DT_MIPS_INTERFACE_SIZE: i64 = 0x7000_002c;
2932/// Address of rld_text_rsolve function stored in GOT.
2933pub const DT_MIPS_RLD_TEXT_RESOLVE_ADDR: i64 = 0x7000_002d;
2934/// Default suffix of dso to be added by rld on dlopen() calls.
2935pub const DT_MIPS_PERF_SUFFIX: i64 = 0x7000_002e;
2936/// (O32)Size of compact rel section.
2937pub const DT_MIPS_COMPACT_SIZE: i64 = 0x7000_002f;
2938/// GP value for aux GOTs.
2939pub const DT_MIPS_GP_VALUE: i64 = 0x7000_0030;
2940/// Address of aux .dynamic.
2941pub const DT_MIPS_AUX_DYNAMIC: i64 = 0x7000_0031;
2942/// The address of .got.plt in an executable using the new non-PIC ABI.
2943pub const DT_MIPS_PLTGOT: i64 = 0x7000_0032;
2944/// The base of the PLT in an executable using the new non-PIC ABI if that PLT is writable.  For a non-writable PLT, this is omitted or has a zero value.
2945pub const DT_MIPS_RWPLT: i64 = 0x7000_0034;
2946/// An alternative description of the classic MIPS RLD_MAP that is usable in a PIE as it stores a relative offset from the address of the tag rather than an absolute address.
2947pub const DT_MIPS_RLD_MAP_REL: i64 = 0x7000_0035;
2948
2949// Values for `DT_MIPS_FLAGS` `Dyn32` entry.
2950
2951/// No flags
2952pub const RHF_NONE: u32 = 0;
2953/// Use quickstart
2954pub const RHF_QUICKSTART: u32 = 1 << 0;
2955/// Hash size not power of 2
2956pub const RHF_NOTPOT: u32 = 1 << 1;
2957/// Ignore LD_LIBRARY_PATH
2958pub const RHF_NO_LIBRARY_REPLACEMENT: u32 = 1 << 2;
2959pub const RHF_NO_MOVE: u32 = 1 << 3;
2960pub const RHF_SGI_ONLY: u32 = 1 << 4;
2961pub const RHF_GUARANTEE_INIT: u32 = 1 << 5;
2962pub const RHF_DELTA_C_PLUS_PLUS: u32 = 1 << 6;
2963pub const RHF_GUARANTEE_START_INIT: u32 = 1 << 7;
2964pub const RHF_PIXIE: u32 = 1 << 8;
2965pub const RHF_DEFAULT_DELAY_LOAD: u32 = 1 << 9;
2966pub const RHF_REQUICKSTART: u32 = 1 << 10;
2967pub const RHF_REQUICKSTARTED: u32 = 1 << 11;
2968pub const RHF_CORD: u32 = 1 << 12;
2969pub const RHF_NO_UNRES_UNDEF: u32 = 1 << 13;
2970pub const RHF_RLD_ORDER_SAFE: u32 = 1 << 14;
2971
2972// Entries found in sections of type `SHT_MIPS_LIBLIST`.
2973
2974// TODO: Elf32_Lib, Elf64_Lib
2975
2976// Values for `Lib*::l_flags`.
2977
2978pub const LL_NONE: u32 = 0;
2979/// Require exact match
2980pub const LL_EXACT_MATCH: u32 = 1 << 0;
2981/// Ignore interface version
2982pub const LL_IGNORE_INT_VER: u32 = 1 << 1;
2983pub const LL_REQUIRE_MINOR: u32 = 1 << 2;
2984pub const LL_EXPORTS: u32 = 1 << 3;
2985pub const LL_DELAY_LOAD: u32 = 1 << 4;
2986pub const LL_DELTA: u32 = 1 << 5;
2987
2988// TODO: MIPS ABI flags
2989
2990// PA-RISC specific definitions.
2991
2992// PA-RISC values for `FileHeader32::e_flags`.
2993
2994/// Trap nil pointer dereference.
2995pub const EF_PARISC_TRAPNIL: u32 = 0x0001_0000;
2996/// Program uses arch. extensions.
2997pub const EF_PARISC_EXT: u32 = 0x0002_0000;
2998/// Program expects little endian.
2999pub const EF_PARISC_LSB: u32 = 0x0004_0000;
3000/// Program expects wide mode.
3001pub const EF_PARISC_WIDE: u32 = 0x0008_0000;
3002/// No kernel assisted branch prediction.
3003pub const EF_PARISC_NO_KABP: u32 = 0x0010_0000;
3004/// Allow lazy swapping.
3005pub const EF_PARISC_LAZYSWAP: u32 = 0x0040_0000;
3006/// Architecture version.
3007pub const EF_PARISC_ARCH: u32 = 0x0000_ffff;
3008
3009// Values for `EF_PARISC_ARCH'.
3010
3011/// PA-RISC 1.0 big-endian.
3012pub const EFA_PARISC_1_0: u32 = 0x020b;
3013/// PA-RISC 1.1 big-endian.
3014pub const EFA_PARISC_1_1: u32 = 0x0210;
3015/// PA-RISC 2.0 big-endian.
3016pub const EFA_PARISC_2_0: u32 = 0x0214;
3017
3018// PA-RISC values for `Sym*::st_shndx`.
3019
3020/// Section for tentatively declared symbols in ANSI C.
3021pub const SHN_PARISC_ANSI_COMMON: u16 = 0xff00;
3022/// Common blocks in huge model.
3023pub const SHN_PARISC_HUGE_COMMON: u16 = 0xff01;
3024
3025// PA-RISC values for `SectionHeader32::sh_type`.
3026
3027/// Contains product specific ext.
3028pub const SHT_PARISC_EXT: u32 = 0x7000_0000;
3029/// Unwind information.
3030pub const SHT_PARISC_UNWIND: u32 = 0x7000_0001;
3031/// Debug info for optimized code.
3032pub const SHT_PARISC_DOC: u32 = 0x7000_0002;
3033
3034// PA-RISC values for `SectionHeader32::sh_flags`.
3035
3036/// Section with short addressing.
3037pub const SHF_PARISC_SHORT: u32 = 0x2000_0000;
3038/// Section far from gp.
3039pub const SHF_PARISC_HUGE: u32 = 0x4000_0000;
3040/// Static branch prediction code.
3041pub const SHF_PARISC_SBP: u32 = 0x8000_0000;
3042
3043// PA-RISC values for `st_type` component of `Sym32::st_info`.
3044
3045/// Millicode function entry point.
3046pub const STT_PARISC_MILLICODE: u8 = 13;
3047
3048pub const STT_HP_OPAQUE: u8 = STT_LOOS + 0x1;
3049pub const STT_HP_STUB: u8 = STT_LOOS + 0x2;
3050
3051// PA-RISC values for `Rel*::r_type`.
3052
3053/// No reloc.
3054pub const R_PARISC_NONE: u32 = 0;
3055/// Direct 32-bit reference.
3056pub const R_PARISC_DIR32: u32 = 1;
3057/// Left 21 bits of eff. address.
3058pub const R_PARISC_DIR21L: u32 = 2;
3059/// Right 17 bits of eff. address.
3060pub const R_PARISC_DIR17R: u32 = 3;
3061/// 17 bits of eff. address.
3062pub const R_PARISC_DIR17F: u32 = 4;
3063/// Right 14 bits of eff. address.
3064pub const R_PARISC_DIR14R: u32 = 6;
3065/// 32-bit rel. address.
3066pub const R_PARISC_PCREL32: u32 = 9;
3067/// Left 21 bits of rel. address.
3068pub const R_PARISC_PCREL21L: u32 = 10;
3069/// Right 17 bits of rel. address.
3070pub const R_PARISC_PCREL17R: u32 = 11;
3071/// 17 bits of rel. address.
3072pub const R_PARISC_PCREL17F: u32 = 12;
3073/// Right 14 bits of rel. address.
3074pub const R_PARISC_PCREL14R: u32 = 14;
3075/// Left 21 bits of rel. address.
3076pub const R_PARISC_DPREL21L: u32 = 18;
3077/// Right 14 bits of rel. address.
3078pub const R_PARISC_DPREL14R: u32 = 22;
3079/// GP-relative, left 21 bits.
3080pub const R_PARISC_GPREL21L: u32 = 26;
3081/// GP-relative, right 14 bits.
3082pub const R_PARISC_GPREL14R: u32 = 30;
3083/// LT-relative, left 21 bits.
3084pub const R_PARISC_LTOFF21L: u32 = 34;
3085/// LT-relative, right 14 bits.
3086pub const R_PARISC_LTOFF14R: u32 = 38;
3087/// 32 bits section rel. address.
3088pub const R_PARISC_SECREL32: u32 = 41;
3089/// No relocation, set segment base.
3090pub const R_PARISC_SEGBASE: u32 = 48;
3091/// 32 bits segment rel. address.
3092pub const R_PARISC_SEGREL32: u32 = 49;
3093/// PLT rel. address, left 21 bits.
3094pub const R_PARISC_PLTOFF21L: u32 = 50;
3095/// PLT rel. address, right 14 bits.
3096pub const R_PARISC_PLTOFF14R: u32 = 54;
3097/// 32 bits LT-rel. function pointer.
3098pub const R_PARISC_LTOFF_FPTR32: u32 = 57;
3099/// LT-rel. fct ptr, left 21 bits.
3100pub const R_PARISC_LTOFF_FPTR21L: u32 = 58;
3101/// LT-rel. fct ptr, right 14 bits.
3102pub const R_PARISC_LTOFF_FPTR14R: u32 = 62;
3103/// 64 bits function address.
3104pub const R_PARISC_FPTR64: u32 = 64;
3105/// 32 bits function address.
3106pub const R_PARISC_PLABEL32: u32 = 65;
3107/// Left 21 bits of fdesc address.
3108pub const R_PARISC_PLABEL21L: u32 = 66;
3109/// Right 14 bits of fdesc address.
3110pub const R_PARISC_PLABEL14R: u32 = 70;
3111/// 64 bits PC-rel. address.
3112pub const R_PARISC_PCREL64: u32 = 72;
3113/// 22 bits PC-rel. address.
3114pub const R_PARISC_PCREL22F: u32 = 74;
3115/// PC-rel. address, right 14 bits.
3116pub const R_PARISC_PCREL14WR: u32 = 75;
3117/// PC rel. address, right 14 bits.
3118pub const R_PARISC_PCREL14DR: u32 = 76;
3119/// 16 bits PC-rel. address.
3120pub const R_PARISC_PCREL16F: u32 = 77;
3121/// 16 bits PC-rel. address.
3122pub const R_PARISC_PCREL16WF: u32 = 78;
3123/// 16 bits PC-rel. address.
3124pub const R_PARISC_PCREL16DF: u32 = 79;
3125/// 64 bits of eff. address.
3126pub const R_PARISC_DIR64: u32 = 80;
3127/// 14 bits of eff. address.
3128pub const R_PARISC_DIR14WR: u32 = 83;
3129/// 14 bits of eff. address.
3130pub const R_PARISC_DIR14DR: u32 = 84;
3131/// 16 bits of eff. address.
3132pub const R_PARISC_DIR16F: u32 = 85;
3133/// 16 bits of eff. address.
3134pub const R_PARISC_DIR16WF: u32 = 86;
3135/// 16 bits of eff. address.
3136pub const R_PARISC_DIR16DF: u32 = 87;
3137/// 64 bits of GP-rel. address.
3138pub const R_PARISC_GPREL64: u32 = 88;
3139/// GP-rel. address, right 14 bits.
3140pub const R_PARISC_GPREL14WR: u32 = 91;
3141/// GP-rel. address, right 14 bits.
3142pub const R_PARISC_GPREL14DR: u32 = 92;
3143/// 16 bits GP-rel. address.
3144pub const R_PARISC_GPREL16F: u32 = 93;
3145/// 16 bits GP-rel. address.
3146pub const R_PARISC_GPREL16WF: u32 = 94;
3147/// 16 bits GP-rel. address.
3148pub const R_PARISC_GPREL16DF: u32 = 95;
3149/// 64 bits LT-rel. address.
3150pub const R_PARISC_LTOFF64: u32 = 96;
3151/// LT-rel. address, right 14 bits.
3152pub const R_PARISC_LTOFF14WR: u32 = 99;
3153/// LT-rel. address, right 14 bits.
3154pub const R_PARISC_LTOFF14DR: u32 = 100;
3155/// 16 bits LT-rel. address.
3156pub const R_PARISC_LTOFF16F: u32 = 101;
3157/// 16 bits LT-rel. address.
3158pub const R_PARISC_LTOFF16WF: u32 = 102;
3159/// 16 bits LT-rel. address.
3160pub const R_PARISC_LTOFF16DF: u32 = 103;
3161/// 64 bits section rel. address.
3162pub const R_PARISC_SECREL64: u32 = 104;
3163/// 64 bits segment rel. address.
3164pub const R_PARISC_SEGREL64: u32 = 112;
3165/// PLT-rel. address, right 14 bits.
3166pub const R_PARISC_PLTOFF14WR: u32 = 115;
3167/// PLT-rel. address, right 14 bits.
3168pub const R_PARISC_PLTOFF14DR: u32 = 116;
3169/// 16 bits LT-rel. address.
3170pub const R_PARISC_PLTOFF16F: u32 = 117;
3171/// 16 bits PLT-rel. address.
3172pub const R_PARISC_PLTOFF16WF: u32 = 118;
3173/// 16 bits PLT-rel. address.
3174pub const R_PARISC_PLTOFF16DF: u32 = 119;
3175/// 64 bits LT-rel. function ptr.
3176pub const R_PARISC_LTOFF_FPTR64: u32 = 120;
3177/// LT-rel. fct. ptr., right 14 bits.
3178pub const R_PARISC_LTOFF_FPTR14WR: u32 = 123;
3179/// LT-rel. fct. ptr., right 14 bits.
3180pub const R_PARISC_LTOFF_FPTR14DR: u32 = 124;
3181/// 16 bits LT-rel. function ptr.
3182pub const R_PARISC_LTOFF_FPTR16F: u32 = 125;
3183/// 16 bits LT-rel. function ptr.
3184pub const R_PARISC_LTOFF_FPTR16WF: u32 = 126;
3185/// 16 bits LT-rel. function ptr.
3186pub const R_PARISC_LTOFF_FPTR16DF: u32 = 127;
3187pub const R_PARISC_LORESERVE: u32 = 128;
3188/// Copy relocation.
3189pub const R_PARISC_COPY: u32 = 128;
3190/// Dynamic reloc, imported PLT
3191pub const R_PARISC_IPLT: u32 = 129;
3192/// Dynamic reloc, exported PLT
3193pub const R_PARISC_EPLT: u32 = 130;
3194/// 32 bits TP-rel. address.
3195pub const R_PARISC_TPREL32: u32 = 153;
3196/// TP-rel. address, left 21 bits.
3197pub const R_PARISC_TPREL21L: u32 = 154;
3198/// TP-rel. address, right 14 bits.
3199pub const R_PARISC_TPREL14R: u32 = 158;
3200/// LT-TP-rel. address, left 21 bits.
3201pub const R_PARISC_LTOFF_TP21L: u32 = 162;
3202/// LT-TP-rel. address, right 14 bits.
3203pub const R_PARISC_LTOFF_TP14R: u32 = 166;
3204/// 14 bits LT-TP-rel. address.
3205pub const R_PARISC_LTOFF_TP14F: u32 = 167;
3206/// 64 bits TP-rel. address.
3207pub const R_PARISC_TPREL64: u32 = 216;
3208/// TP-rel. address, right 14 bits.
3209pub const R_PARISC_TPREL14WR: u32 = 219;
3210/// TP-rel. address, right 14 bits.
3211pub const R_PARISC_TPREL14DR: u32 = 220;
3212/// 16 bits TP-rel. address.
3213pub const R_PARISC_TPREL16F: u32 = 221;
3214/// 16 bits TP-rel. address.
3215pub const R_PARISC_TPREL16WF: u32 = 222;
3216/// 16 bits TP-rel. address.
3217pub const R_PARISC_TPREL16DF: u32 = 223;
3218/// 64 bits LT-TP-rel. address.
3219pub const R_PARISC_LTOFF_TP64: u32 = 224;
3220/// LT-TP-rel. address, right 14 bits.
3221pub const R_PARISC_LTOFF_TP14WR: u32 = 227;
3222/// LT-TP-rel. address, right 14 bits.
3223pub const R_PARISC_LTOFF_TP14DR: u32 = 228;
3224/// 16 bits LT-TP-rel. address.
3225pub const R_PARISC_LTOFF_TP16F: u32 = 229;
3226/// 16 bits LT-TP-rel. address.
3227pub const R_PARISC_LTOFF_TP16WF: u32 = 230;
3228/// 16 bits LT-TP-rel. address.
3229pub const R_PARISC_LTOFF_TP16DF: u32 = 231;
3230pub const R_PARISC_GNU_VTENTRY: u32 = 232;
3231pub const R_PARISC_GNU_VTINHERIT: u32 = 233;
3232/// GD 21-bit left.
3233pub const R_PARISC_TLS_GD21L: u32 = 234;
3234/// GD 14-bit right.
3235pub const R_PARISC_TLS_GD14R: u32 = 235;
3236/// GD call to __t_g_a.
3237pub const R_PARISC_TLS_GDCALL: u32 = 236;
3238/// LD module 21-bit left.
3239pub const R_PARISC_TLS_LDM21L: u32 = 237;
3240/// LD module 14-bit right.
3241pub const R_PARISC_TLS_LDM14R: u32 = 238;
3242/// LD module call to __t_g_a.
3243pub const R_PARISC_TLS_LDMCALL: u32 = 239;
3244/// LD offset 21-bit left.
3245pub const R_PARISC_TLS_LDO21L: u32 = 240;
3246/// LD offset 14-bit right.
3247pub const R_PARISC_TLS_LDO14R: u32 = 241;
3248/// DTP module 32-bit.
3249pub const R_PARISC_TLS_DTPMOD32: u32 = 242;
3250/// DTP module 64-bit.
3251pub const R_PARISC_TLS_DTPMOD64: u32 = 243;
3252/// DTP offset 32-bit.
3253pub const R_PARISC_TLS_DTPOFF32: u32 = 244;
3254/// DTP offset 32-bit.
3255pub const R_PARISC_TLS_DTPOFF64: u32 = 245;
3256pub const R_PARISC_TLS_LE21L: u32 = R_PARISC_TPREL21L;
3257pub const R_PARISC_TLS_LE14R: u32 = R_PARISC_TPREL14R;
3258pub const R_PARISC_TLS_IE21L: u32 = R_PARISC_LTOFF_TP21L;
3259pub const R_PARISC_TLS_IE14R: u32 = R_PARISC_LTOFF_TP14R;
3260pub const R_PARISC_TLS_TPREL32: u32 = R_PARISC_TPREL32;
3261pub const R_PARISC_TLS_TPREL64: u32 = R_PARISC_TPREL64;
3262pub const R_PARISC_HIRESERVE: u32 = 255;
3263
3264// PA-RISC values for `ProgramHeader*::p_type`.
3265
3266pub const PT_HP_TLS: u32 = PT_LOOS + 0x0;
3267pub const PT_HP_CORE_NONE: u32 = PT_LOOS + 0x1;
3268pub const PT_HP_CORE_VERSION: u32 = PT_LOOS + 0x2;
3269pub const PT_HP_CORE_KERNEL: u32 = PT_LOOS + 0x3;
3270pub const PT_HP_CORE_COMM: u32 = PT_LOOS + 0x4;
3271pub const PT_HP_CORE_PROC: u32 = PT_LOOS + 0x5;
3272pub const PT_HP_CORE_LOADABLE: u32 = PT_LOOS + 0x6;
3273pub const PT_HP_CORE_STACK: u32 = PT_LOOS + 0x7;
3274pub const PT_HP_CORE_SHM: u32 = PT_LOOS + 0x8;
3275pub const PT_HP_CORE_MMF: u32 = PT_LOOS + 0x9;
3276pub const PT_HP_PARALLEL: u32 = PT_LOOS + 0x10;
3277pub const PT_HP_FASTBIND: u32 = PT_LOOS + 0x11;
3278pub const PT_HP_OPT_ANNOT: u32 = PT_LOOS + 0x12;
3279pub const PT_HP_HSL_ANNOT: u32 = PT_LOOS + 0x13;
3280pub const PT_HP_STACK: u32 = PT_LOOS + 0x14;
3281
3282pub const PT_PARISC_ARCHEXT: u32 = 0x7000_0000;
3283pub const PT_PARISC_UNWIND: u32 = 0x7000_0001;
3284
3285// PA-RISC values for `ProgramHeader*::p_flags`.
3286
3287pub const PF_PARISC_SBP: u32 = 0x0800_0000;
3288
3289pub const PF_HP_PAGE_SIZE: u32 = 0x0010_0000;
3290pub const PF_HP_FAR_SHARED: u32 = 0x0020_0000;
3291pub const PF_HP_NEAR_SHARED: u32 = 0x0040_0000;
3292pub const PF_HP_CODE: u32 = 0x0100_0000;
3293pub const PF_HP_MODIFY: u32 = 0x0200_0000;
3294pub const PF_HP_LAZYSWAP: u32 = 0x0400_0000;
3295pub const PF_HP_SBP: u32 = 0x0800_0000;
3296
3297// Alpha specific definitions.
3298
3299// Alpha values for `FileHeader64::e_flags`.
3300
3301/// All addresses must be < 2GB.
3302pub const EF_ALPHA_32BIT: u32 = 1;
3303/// Relocations for relaxing exist.
3304pub const EF_ALPHA_CANRELAX: u32 = 2;
3305
3306// Alpha values for `SectionHeader64::sh_type`.
3307
3308// These two are primerily concerned with ECOFF debugging info.
3309pub const SHT_ALPHA_DEBUG: u32 = 0x7000_0001;
3310pub const SHT_ALPHA_REGINFO: u32 = 0x7000_0002;
3311
3312// Alpha values for `SectionHeader64::sh_flags`.
3313
3314pub const SHF_ALPHA_GPREL: u32 = 0x1000_0000;
3315
3316// Alpha values for `Sym64::st_other`.
3317/// No PV required.
3318pub const STO_ALPHA_NOPV: u8 = 0x80;
3319/// PV only used for initial ldgp.
3320pub const STO_ALPHA_STD_GPLOAD: u8 = 0x88;
3321
3322// Alpha values for `Rel64::r_type`.
3323
3324/// No reloc
3325pub const R_ALPHA_NONE: u32 = 0;
3326/// Direct 32 bit
3327pub const R_ALPHA_REFLONG: u32 = 1;
3328/// Direct 64 bit
3329pub const R_ALPHA_REFQUAD: u32 = 2;
3330/// GP relative 32 bit
3331pub const R_ALPHA_GPREL32: u32 = 3;
3332/// GP relative 16 bit w/optimization
3333pub const R_ALPHA_LITERAL: u32 = 4;
3334/// Optimization hint for LITERAL
3335pub const R_ALPHA_LITUSE: u32 = 5;
3336/// Add displacement to GP
3337pub const R_ALPHA_GPDISP: u32 = 6;
3338/// PC+4 relative 23 bit shifted
3339pub const R_ALPHA_BRADDR: u32 = 7;
3340/// PC+4 relative 16 bit shifted
3341pub const R_ALPHA_HINT: u32 = 8;
3342/// PC relative 16 bit
3343pub const R_ALPHA_SREL16: u32 = 9;
3344/// PC relative 32 bit
3345pub const R_ALPHA_SREL32: u32 = 10;
3346/// PC relative 64 bit
3347pub const R_ALPHA_SREL64: u32 = 11;
3348/// GP relative 32 bit, high 16 bits
3349pub const R_ALPHA_GPRELHIGH: u32 = 17;
3350/// GP relative 32 bit, low 16 bits
3351pub const R_ALPHA_GPRELLOW: u32 = 18;
3352/// GP relative 16 bit
3353pub const R_ALPHA_GPREL16: u32 = 19;
3354/// Copy symbol at runtime
3355pub const R_ALPHA_COPY: u32 = 24;
3356/// Create GOT entry
3357pub const R_ALPHA_GLOB_DAT: u32 = 25;
3358/// Create PLT entry
3359pub const R_ALPHA_JMP_SLOT: u32 = 26;
3360/// Adjust by program base
3361pub const R_ALPHA_RELATIVE: u32 = 27;
3362pub const R_ALPHA_TLS_GD_HI: u32 = 28;
3363pub const R_ALPHA_TLSGD: u32 = 29;
3364pub const R_ALPHA_TLS_LDM: u32 = 30;
3365pub const R_ALPHA_DTPMOD64: u32 = 31;
3366pub const R_ALPHA_GOTDTPREL: u32 = 32;
3367pub const R_ALPHA_DTPREL64: u32 = 33;
3368pub const R_ALPHA_DTPRELHI: u32 = 34;
3369pub const R_ALPHA_DTPRELLO: u32 = 35;
3370pub const R_ALPHA_DTPREL16: u32 = 36;
3371pub const R_ALPHA_GOTTPREL: u32 = 37;
3372pub const R_ALPHA_TPREL64: u32 = 38;
3373pub const R_ALPHA_TPRELHI: u32 = 39;
3374pub const R_ALPHA_TPRELLO: u32 = 40;
3375pub const R_ALPHA_TPREL16: u32 = 41;
3376
3377// Magic values of the `R_ALPHA_LITUSE` relocation addend.
3378pub const LITUSE_ALPHA_ADDR: u32 = 0;
3379pub const LITUSE_ALPHA_BASE: u32 = 1;
3380pub const LITUSE_ALPHA_BYTOFF: u32 = 2;
3381pub const LITUSE_ALPHA_JSR: u32 = 3;
3382pub const LITUSE_ALPHA_TLS_GD: u32 = 4;
3383pub const LITUSE_ALPHA_TLS_LDM: u32 = 5;
3384
3385// Alpha values for `Dyn64::d_tag`.
3386pub const DT_ALPHA_PLTRO: i64 = DT_LOPROC + 0;
3387
3388// PowerPC specific declarations.
3389
3390// PowerPC values for `FileHeader*::e_flags`.
3391/// PowerPC embedded flag
3392pub const EF_PPC_EMB: u32 = 0x8000_0000;
3393
3394// Cygnus local bits below .
3395/// PowerPC -mrelocatable flag
3396pub const EF_PPC_RELOCATABLE: u32 = 0x0001_0000;
3397/// PowerPC -mrelocatable-lib flag
3398pub const EF_PPC_RELOCATABLE_LIB: u32 = 0x0000_8000;
3399
3400// PowerPC values for `Rel*::r_type` defined by the ABIs.
3401pub const R_PPC_NONE: u32 = 0;
3402/// 32bit absolute address
3403pub const R_PPC_ADDR32: u32 = 1;
3404/// 26bit address, 2 bits ignored.
3405pub const R_PPC_ADDR24: u32 = 2;
3406/// 16bit absolute address
3407pub const R_PPC_ADDR16: u32 = 3;
3408/// lower 16bit of absolute address
3409pub const R_PPC_ADDR16_LO: u32 = 4;
3410/// high 16bit of absolute address
3411pub const R_PPC_ADDR16_HI: u32 = 5;
3412/// adjusted high 16bit
3413pub const R_PPC_ADDR16_HA: u32 = 6;
3414/// 16bit address, 2 bits ignored
3415pub const R_PPC_ADDR14: u32 = 7;
3416pub const R_PPC_ADDR14_BRTAKEN: u32 = 8;
3417pub const R_PPC_ADDR14_BRNTAKEN: u32 = 9;
3418/// PC relative 26 bit
3419pub const R_PPC_REL24: u32 = 10;
3420/// PC relative 16 bit
3421pub const R_PPC_REL14: u32 = 11;
3422pub const R_PPC_REL14_BRTAKEN: u32 = 12;
3423pub const R_PPC_REL14_BRNTAKEN: u32 = 13;
3424pub const R_PPC_GOT16: u32 = 14;
3425pub const R_PPC_GOT16_LO: u32 = 15;
3426pub const R_PPC_GOT16_HI: u32 = 16;
3427pub const R_PPC_GOT16_HA: u32 = 17;
3428pub const R_PPC_PLTREL24: u32 = 18;
3429pub const R_PPC_COPY: u32 = 19;
3430pub const R_PPC_GLOB_DAT: u32 = 20;
3431pub const R_PPC_JMP_SLOT: u32 = 21;
3432pub const R_PPC_RELATIVE: u32 = 22;
3433pub const R_PPC_LOCAL24PC: u32 = 23;
3434pub const R_PPC_UADDR32: u32 = 24;
3435pub const R_PPC_UADDR16: u32 = 25;
3436pub const R_PPC_REL32: u32 = 26;
3437pub const R_PPC_PLT32: u32 = 27;
3438pub const R_PPC_PLTREL32: u32 = 28;
3439pub const R_PPC_PLT16_LO: u32 = 29;
3440pub const R_PPC_PLT16_HI: u32 = 30;
3441pub const R_PPC_PLT16_HA: u32 = 31;
3442pub const R_PPC_SDAREL16: u32 = 32;
3443pub const R_PPC_SECTOFF: u32 = 33;
3444pub const R_PPC_SECTOFF_LO: u32 = 34;
3445pub const R_PPC_SECTOFF_HI: u32 = 35;
3446pub const R_PPC_SECTOFF_HA: u32 = 36;
3447
3448// PowerPC values for `Rel*::r_type` defined for the TLS access ABI.
3449/// none    (sym+add)@tls
3450pub const R_PPC_TLS: u32 = 67;
3451/// word32  (sym+add)@dtpmod
3452pub const R_PPC_DTPMOD32: u32 = 68;
3453/// half16* (sym+add)@tprel
3454pub const R_PPC_TPREL16: u32 = 69;
3455/// half16  (sym+add)@tprel@l
3456pub const R_PPC_TPREL16_LO: u32 = 70;
3457/// half16  (sym+add)@tprel@h
3458pub const R_PPC_TPREL16_HI: u32 = 71;
3459/// half16  (sym+add)@tprel@ha
3460pub const R_PPC_TPREL16_HA: u32 = 72;
3461/// word32  (sym+add)@tprel
3462pub const R_PPC_TPREL32: u32 = 73;
3463/// half16*(sym+add)@dtprel
3464pub const R_PPC_DTPREL16: u32 = 74;
3465/// half16  (sym+add)@dtprel@l
3466pub const R_PPC_DTPREL16_LO: u32 = 75;
3467/// half16  (sym+add)@dtprel@h
3468pub const R_PPC_DTPREL16_HI: u32 = 76;
3469/// half16  (sym+add)@dtprel@ha
3470pub const R_PPC_DTPREL16_HA: u32 = 77;
3471/// word32  (sym+add)@dtprel
3472pub const R_PPC_DTPREL32: u32 = 78;
3473/// half16* (sym+add)@got@tlsgd
3474pub const R_PPC_GOT_TLSGD16: u32 = 79;
3475/// half16  (sym+add)@got@tlsgd@l
3476pub const R_PPC_GOT_TLSGD16_LO: u32 = 80;
3477/// half16  (sym+add)@got@tlsgd@h
3478pub const R_PPC_GOT_TLSGD16_HI: u32 = 81;
3479/// half16  (sym+add)@got@tlsgd@ha
3480pub const R_PPC_GOT_TLSGD16_HA: u32 = 82;
3481/// half16* (sym+add)@got@tlsld
3482pub const R_PPC_GOT_TLSLD16: u32 = 83;
3483/// half16  (sym+add)@got@tlsld@l
3484pub const R_PPC_GOT_TLSLD16_LO: u32 = 84;
3485/// half16  (sym+add)@got@tlsld@h
3486pub const R_PPC_GOT_TLSLD16_HI: u32 = 85;
3487/// half16  (sym+add)@got@tlsld@ha
3488pub const R_PPC_GOT_TLSLD16_HA: u32 = 86;
3489/// half16* (sym+add)@got@tprel
3490pub const R_PPC_GOT_TPREL16: u32 = 87;
3491/// half16  (sym+add)@got@tprel@l
3492pub const R_PPC_GOT_TPREL16_LO: u32 = 88;
3493/// half16  (sym+add)@got@tprel@h
3494pub const R_PPC_GOT_TPREL16_HI: u32 = 89;
3495/// half16  (sym+add)@got@tprel@ha
3496pub const R_PPC_GOT_TPREL16_HA: u32 = 90;
3497/// half16* (sym+add)@got@dtprel
3498pub const R_PPC_GOT_DTPREL16: u32 = 91;
3499/// half16* (sym+add)@got@dtprel@l
3500pub const R_PPC_GOT_DTPREL16_LO: u32 = 92;
3501/// half16* (sym+add)@got@dtprel@h
3502pub const R_PPC_GOT_DTPREL16_HI: u32 = 93;
3503/// half16* (sym+add)@got@dtprel@ha
3504pub const R_PPC_GOT_DTPREL16_HA: u32 = 94;
3505/// none    (sym+add)@tlsgd
3506pub const R_PPC_TLSGD: u32 = 95;
3507/// none    (sym+add)@tlsld
3508pub const R_PPC_TLSLD: u32 = 96;
3509
3510// PowerPC values for `Rel*::r_type` from the Embedded ELF ABI.
3511pub const R_PPC_EMB_NADDR32: u32 = 101;
3512pub const R_PPC_EMB_NADDR16: u32 = 102;
3513pub const R_PPC_EMB_NADDR16_LO: u32 = 103;
3514pub const R_PPC_EMB_NADDR16_HI: u32 = 104;
3515pub const R_PPC_EMB_NADDR16_HA: u32 = 105;
3516pub const R_PPC_EMB_SDAI16: u32 = 106;
3517pub const R_PPC_EMB_SDA2I16: u32 = 107;
3518pub const R_PPC_EMB_SDA2REL: u32 = 108;
3519/// 16 bit offset in SDA
3520pub const R_PPC_EMB_SDA21: u32 = 109;
3521pub const R_PPC_EMB_MRKREF: u32 = 110;
3522pub const R_PPC_EMB_RELSEC16: u32 = 111;
3523pub const R_PPC_EMB_RELST_LO: u32 = 112;
3524pub const R_PPC_EMB_RELST_HI: u32 = 113;
3525pub const R_PPC_EMB_RELST_HA: u32 = 114;
3526pub const R_PPC_EMB_BIT_FLD: u32 = 115;
3527/// 16 bit relative offset in SDA
3528pub const R_PPC_EMB_RELSDA: u32 = 116;
3529
3530// Diab tool values for `Rel*::r_type`.
3531/// like EMB_SDA21, but lower 16 bit
3532pub const R_PPC_DIAB_SDA21_LO: u32 = 180;
3533/// like EMB_SDA21, but high 16 bit
3534pub const R_PPC_DIAB_SDA21_HI: u32 = 181;
3535/// like EMB_SDA21, adjusted high 16
3536pub const R_PPC_DIAB_SDA21_HA: u32 = 182;
3537/// like EMB_RELSDA, but lower 16 bit
3538pub const R_PPC_DIAB_RELSDA_LO: u32 = 183;
3539/// like EMB_RELSDA, but high 16 bit
3540pub const R_PPC_DIAB_RELSDA_HI: u32 = 184;
3541/// like EMB_RELSDA, adjusted high 16
3542pub const R_PPC_DIAB_RELSDA_HA: u32 = 185;
3543
3544/// GNU extension to support local ifunc.
3545pub const R_PPC_IRELATIVE: u32 = 248;
3546
3547// GNU relocs used in PIC code sequences.
3548/// half16   (sym+add-.)
3549pub const R_PPC_REL16: u32 = 249;
3550/// half16   (sym+add-.)@l
3551pub const R_PPC_REL16_LO: u32 = 250;
3552/// half16   (sym+add-.)@h
3553pub const R_PPC_REL16_HI: u32 = 251;
3554/// half16   (sym+add-.)@ha
3555pub const R_PPC_REL16_HA: u32 = 252;
3556
3557/// This is a phony reloc to handle any old fashioned TOC16 references that may
3558/// still be in object files.
3559pub const R_PPC_TOC16: u32 = 255;
3560
3561// PowerPC specific values for `Dyn*::d_tag`.
3562pub const DT_PPC_GOT: i64 = DT_LOPROC + 0;
3563pub const DT_PPC_OPT: i64 = DT_LOPROC + 1;
3564
3565// PowerPC specific values for the `DT_PPC_OPT` entry.
3566pub const PPC_OPT_TLS: u32 = 1;
3567
3568// PowerPC64 values for `Rel*::r_type` defined by the ABIs.
3569pub const R_PPC64_NONE: u32 = R_PPC_NONE;
3570/// 32bit absolute address
3571pub const R_PPC64_ADDR32: u32 = R_PPC_ADDR32;
3572/// 26bit address, word aligned
3573pub const R_PPC64_ADDR24: u32 = R_PPC_ADDR24;
3574/// 16bit absolute address
3575pub const R_PPC64_ADDR16: u32 = R_PPC_ADDR16;
3576/// lower 16bits of address
3577pub const R_PPC64_ADDR16_LO: u32 = R_PPC_ADDR16_LO;
3578/// high 16bits of address.
3579pub const R_PPC64_ADDR16_HI: u32 = R_PPC_ADDR16_HI;
3580/// adjusted high 16bits.
3581pub const R_PPC64_ADDR16_HA: u32 = R_PPC_ADDR16_HA;
3582/// 16bit address, word aligned
3583pub const R_PPC64_ADDR14: u32 = R_PPC_ADDR14;
3584pub const R_PPC64_ADDR14_BRTAKEN: u32 = R_PPC_ADDR14_BRTAKEN;
3585pub const R_PPC64_ADDR14_BRNTAKEN: u32 = R_PPC_ADDR14_BRNTAKEN;
3586/// PC-rel. 26 bit, word aligned
3587pub const R_PPC64_REL24: u32 = R_PPC_REL24;
3588/// PC relative 16 bit
3589pub const R_PPC64_REL14: u32 = R_PPC_REL14;
3590pub const R_PPC64_REL14_BRTAKEN: u32 = R_PPC_REL14_BRTAKEN;
3591pub const R_PPC64_REL14_BRNTAKEN: u32 = R_PPC_REL14_BRNTAKEN;
3592pub const R_PPC64_GOT16: u32 = R_PPC_GOT16;
3593pub const R_PPC64_GOT16_LO: u32 = R_PPC_GOT16_LO;
3594pub const R_PPC64_GOT16_HI: u32 = R_PPC_GOT16_HI;
3595pub const R_PPC64_GOT16_HA: u32 = R_PPC_GOT16_HA;
3596
3597pub const R_PPC64_COPY: u32 = R_PPC_COPY;
3598pub const R_PPC64_GLOB_DAT: u32 = R_PPC_GLOB_DAT;
3599pub const R_PPC64_JMP_SLOT: u32 = R_PPC_JMP_SLOT;
3600pub const R_PPC64_RELATIVE: u32 = R_PPC_RELATIVE;
3601
3602pub const R_PPC64_UADDR32: u32 = R_PPC_UADDR32;
3603pub const R_PPC64_UADDR16: u32 = R_PPC_UADDR16;
3604pub const R_PPC64_REL32: u32 = R_PPC_REL32;
3605pub const R_PPC64_PLT32: u32 = R_PPC_PLT32;
3606pub const R_PPC64_PLTREL32: u32 = R_PPC_PLTREL32;
3607pub const R_PPC64_PLT16_LO: u32 = R_PPC_PLT16_LO;
3608pub const R_PPC64_PLT16_HI: u32 = R_PPC_PLT16_HI;
3609pub const R_PPC64_PLT16_HA: u32 = R_PPC_PLT16_HA;
3610
3611pub const R_PPC64_SECTOFF: u32 = R_PPC_SECTOFF;
3612pub const R_PPC64_SECTOFF_LO: u32 = R_PPC_SECTOFF_LO;
3613pub const R_PPC64_SECTOFF_HI: u32 = R_PPC_SECTOFF_HI;
3614pub const R_PPC64_SECTOFF_HA: u32 = R_PPC_SECTOFF_HA;
3615/// word30 (S + A - P) >> 2
3616pub const R_PPC64_ADDR30: u32 = 37;
3617/// doubleword64 S + A
3618pub const R_PPC64_ADDR64: u32 = 38;
3619/// half16 #higher(S + A)
3620pub const R_PPC64_ADDR16_HIGHER: u32 = 39;
3621/// half16 #highera(S + A)
3622pub const R_PPC64_ADDR16_HIGHERA: u32 = 40;
3623/// half16 #highest(S + A)
3624pub const R_PPC64_ADDR16_HIGHEST: u32 = 41;
3625/// half16 #highesta(S + A)
3626pub const R_PPC64_ADDR16_HIGHESTA: u32 = 42;
3627/// doubleword64 S + A
3628pub const R_PPC64_UADDR64: u32 = 43;
3629/// doubleword64 S + A - P
3630pub const R_PPC64_REL64: u32 = 44;
3631/// doubleword64 L + A
3632pub const R_PPC64_PLT64: u32 = 45;
3633/// doubleword64 L + A - P
3634pub const R_PPC64_PLTREL64: u32 = 46;
3635/// half16* S + A - .TOC
3636pub const R_PPC64_TOC16: u32 = 47;
3637/// half16 #lo(S + A - .TOC.)
3638pub const R_PPC64_TOC16_LO: u32 = 48;
3639/// half16 #hi(S + A - .TOC.)
3640pub const R_PPC64_TOC16_HI: u32 = 49;
3641/// half16 #ha(S + A - .TOC.)
3642pub const R_PPC64_TOC16_HA: u32 = 50;
3643/// doubleword64 .TOC
3644pub const R_PPC64_TOC: u32 = 51;
3645/// half16* M + A
3646pub const R_PPC64_PLTGOT16: u32 = 52;
3647/// half16 #lo(M + A)
3648pub const R_PPC64_PLTGOT16_LO: u32 = 53;
3649/// half16 #hi(M + A)
3650pub const R_PPC64_PLTGOT16_HI: u32 = 54;
3651/// half16 #ha(M + A)
3652pub const R_PPC64_PLTGOT16_HA: u32 = 55;
3653
3654/// half16ds* (S + A) >> 2
3655pub const R_PPC64_ADDR16_DS: u32 = 56;
3656/// half16ds  #lo(S + A) >> 2
3657pub const R_PPC64_ADDR16_LO_DS: u32 = 57;
3658/// half16ds* (G + A) >> 2
3659pub const R_PPC64_GOT16_DS: u32 = 58;
3660/// half16ds  #lo(G + A) >> 2
3661pub const R_PPC64_GOT16_LO_DS: u32 = 59;
3662/// half16ds  #lo(L + A) >> 2
3663pub const R_PPC64_PLT16_LO_DS: u32 = 60;
3664/// half16ds* (R + A) >> 2
3665pub const R_PPC64_SECTOFF_DS: u32 = 61;
3666/// half16ds  #lo(R + A) >> 2
3667pub const R_PPC64_SECTOFF_LO_DS: u32 = 62;
3668/// half16ds* (S + A - .TOC.) >> 2
3669pub const R_PPC64_TOC16_DS: u32 = 63;
3670/// half16ds  #lo(S + A - .TOC.) >> 2
3671pub const R_PPC64_TOC16_LO_DS: u32 = 64;
3672/// half16ds* (M + A) >> 2
3673pub const R_PPC64_PLTGOT16_DS: u32 = 65;
3674/// half16ds  #lo(M + A) >> 2
3675pub const R_PPC64_PLTGOT16_LO_DS: u32 = 66;
3676
3677// PowerPC64 values for `Rel*::r_type` defined for the TLS access ABI.
3678/// none    (sym+add)@tls
3679pub const R_PPC64_TLS: u32 = 67;
3680/// doubleword64 (sym+add)@dtpmod
3681pub const R_PPC64_DTPMOD64: u32 = 68;
3682/// half16* (sym+add)@tprel
3683pub const R_PPC64_TPREL16: u32 = 69;
3684/// half16  (sym+add)@tprel@l
3685pub const R_PPC64_TPREL16_LO: u32 = 70;
3686/// half16  (sym+add)@tprel@h
3687pub const R_PPC64_TPREL16_HI: u32 = 71;
3688/// half16  (sym+add)@tprel@ha
3689pub const R_PPC64_TPREL16_HA: u32 = 72;
3690/// doubleword64 (sym+add)@tprel
3691pub const R_PPC64_TPREL64: u32 = 73;
3692/// half16* (sym+add)@dtprel
3693pub const R_PPC64_DTPREL16: u32 = 74;
3694/// half16  (sym+add)@dtprel@l
3695pub const R_PPC64_DTPREL16_LO: u32 = 75;
3696/// half16  (sym+add)@dtprel@h
3697pub const R_PPC64_DTPREL16_HI: u32 = 76;
3698/// half16  (sym+add)@dtprel@ha
3699pub const R_PPC64_DTPREL16_HA: u32 = 77;
3700/// doubleword64 (sym+add)@dtprel
3701pub const R_PPC64_DTPREL64: u32 = 78;
3702/// half16* (sym+add)@got@tlsgd
3703pub const R_PPC64_GOT_TLSGD16: u32 = 79;
3704/// half16  (sym+add)@got@tlsgd@l
3705pub const R_PPC64_GOT_TLSGD16_LO: u32 = 80;
3706/// half16  (sym+add)@got@tlsgd@h
3707pub const R_PPC64_GOT_TLSGD16_HI: u32 = 81;
3708/// half16  (sym+add)@got@tlsgd@ha
3709pub const R_PPC64_GOT_TLSGD16_HA: u32 = 82;
3710/// half16* (sym+add)@got@tlsld
3711pub const R_PPC64_GOT_TLSLD16: u32 = 83;
3712/// half16  (sym+add)@got@tlsld@l
3713pub const R_PPC64_GOT_TLSLD16_LO: u32 = 84;
3714/// half16  (sym+add)@got@tlsld@h
3715pub const R_PPC64_GOT_TLSLD16_HI: u32 = 85;
3716/// half16  (sym+add)@got@tlsld@ha
3717pub const R_PPC64_GOT_TLSLD16_HA: u32 = 86;
3718/// half16ds* (sym+add)@got@tprel
3719pub const R_PPC64_GOT_TPREL16_DS: u32 = 87;
3720/// half16ds (sym+add)@got@tprel@l
3721pub const R_PPC64_GOT_TPREL16_LO_DS: u32 = 88;
3722/// half16  (sym+add)@got@tprel@h
3723pub const R_PPC64_GOT_TPREL16_HI: u32 = 89;
3724/// half16  (sym+add)@got@tprel@ha
3725pub const R_PPC64_GOT_TPREL16_HA: u32 = 90;
3726/// half16ds* (sym+add)@got@dtprel
3727pub const R_PPC64_GOT_DTPREL16_DS: u32 = 91;
3728/// half16ds (sym+add)@got@dtprel@l
3729pub const R_PPC64_GOT_DTPREL16_LO_DS: u32 = 92;
3730/// half16  (sym+add)@got@dtprel@h
3731pub const R_PPC64_GOT_DTPREL16_HI: u32 = 93;
3732/// half16  (sym+add)@got@dtprel@ha
3733pub const R_PPC64_GOT_DTPREL16_HA: u32 = 94;
3734/// half16ds* (sym+add)@tprel
3735pub const R_PPC64_TPREL16_DS: u32 = 95;
3736/// half16ds (sym+add)@tprel@l
3737pub const R_PPC64_TPREL16_LO_DS: u32 = 96;
3738/// half16  (sym+add)@tprel@higher
3739pub const R_PPC64_TPREL16_HIGHER: u32 = 97;
3740/// half16  (sym+add)@tprel@highera
3741pub const R_PPC64_TPREL16_HIGHERA: u32 = 98;
3742/// half16  (sym+add)@tprel@highest
3743pub const R_PPC64_TPREL16_HIGHEST: u32 = 99;
3744/// half16  (sym+add)@tprel@highesta
3745pub const R_PPC64_TPREL16_HIGHESTA: u32 = 100;
3746/// half16ds* (sym+add)@dtprel
3747pub const R_PPC64_DTPREL16_DS: u32 = 101;
3748/// half16ds (sym+add)@dtprel@l
3749pub const R_PPC64_DTPREL16_LO_DS: u32 = 102;
3750/// half16  (sym+add)@dtprel@higher
3751pub const R_PPC64_DTPREL16_HIGHER: u32 = 103;
3752/// half16  (sym+add)@dtprel@highera
3753pub const R_PPC64_DTPREL16_HIGHERA: u32 = 104;
3754/// half16  (sym+add)@dtprel@highest
3755pub const R_PPC64_DTPREL16_HIGHEST: u32 = 105;
3756/// half16  (sym+add)@dtprel@highesta
3757pub const R_PPC64_DTPREL16_HIGHESTA: u32 = 106;
3758/// none    (sym+add)@tlsgd
3759pub const R_PPC64_TLSGD: u32 = 107;
3760/// none    (sym+add)@tlsld
3761pub const R_PPC64_TLSLD: u32 = 108;
3762/// none
3763pub const R_PPC64_TOCSAVE: u32 = 109;
3764
3765// Added when HA and HI relocs were changed to report overflows.
3766pub const R_PPC64_ADDR16_HIGH: u32 = 110;
3767pub const R_PPC64_ADDR16_HIGHA: u32 = 111;
3768pub const R_PPC64_TPREL16_HIGH: u32 = 112;
3769pub const R_PPC64_TPREL16_HIGHA: u32 = 113;
3770pub const R_PPC64_DTPREL16_HIGH: u32 = 114;
3771pub const R_PPC64_DTPREL16_HIGHA: u32 = 115;
3772
3773/// GNU extension to support local ifunc.
3774pub const R_PPC64_JMP_IREL: u32 = 247;
3775/// GNU extension to support local ifunc.
3776pub const R_PPC64_IRELATIVE: u32 = 248;
3777/// half16   (sym+add-.)
3778pub const R_PPC64_REL16: u32 = 249;
3779/// half16   (sym+add-.)@l
3780pub const R_PPC64_REL16_LO: u32 = 250;
3781/// half16   (sym+add-.)@h
3782pub const R_PPC64_REL16_HI: u32 = 251;
3783/// half16   (sym+add-.)@ha
3784pub const R_PPC64_REL16_HA: u32 = 252;
3785
3786// PowerPC64 values for `FileHeader64::e_flags.
3787/// PowerPC64 bits specifying ABI.
3788///
3789/// 1 for original function descriptor using ABI,
3790/// 2 for revised ABI without function descriptors,
3791/// 0 for unspecified or not using any features affected by the differences.
3792pub const EF_PPC64_ABI: u32 = 3;
3793
3794// PowerPC64 values for `Dyn64::d_tag.
3795pub const DT_PPC64_GLINK: i64 = DT_LOPROC + 0;
3796pub const DT_PPC64_OPD: i64 = DT_LOPROC + 1;
3797pub const DT_PPC64_OPDSZ: i64 = DT_LOPROC + 2;
3798pub const DT_PPC64_OPT: i64 = DT_LOPROC + 3;
3799
3800// PowerPC64 bits for `DT_PPC64_OPT` entry.
3801pub const PPC64_OPT_TLS: u32 = 1;
3802pub const PPC64_OPT_MULTI_TOC: u32 = 2;
3803pub const PPC64_OPT_LOCALENTRY: u32 = 4;
3804
3805// PowerPC64 values for `Sym64::st_other.
3806pub const STO_PPC64_LOCAL_BIT: u8 = 5;
3807pub const STO_PPC64_LOCAL_MASK: u8 = 7 << STO_PPC64_LOCAL_BIT;
3808
3809// ARM specific declarations.
3810
3811// ARM values for `FileHeader*::e_flags`.
3812pub const EF_ARM_RELEXEC: u32 = 0x01;
3813pub const EF_ARM_HASENTRY: u32 = 0x02;
3814pub const EF_ARM_INTERWORK: u32 = 0x04;
3815pub const EF_ARM_APCS_26: u32 = 0x08;
3816pub const EF_ARM_APCS_FLOAT: u32 = 0x10;
3817pub const EF_ARM_PIC: u32 = 0x20;
3818/// 8-bit structure alignment is in use
3819pub const EF_ARM_ALIGN8: u32 = 0x40;
3820pub const EF_ARM_NEW_ABI: u32 = 0x80;
3821pub const EF_ARM_OLD_ABI: u32 = 0x100;
3822pub const EF_ARM_SOFT_FLOAT: u32 = 0x200;
3823pub const EF_ARM_VFP_FLOAT: u32 = 0x400;
3824pub const EF_ARM_MAVERICK_FLOAT: u32 = 0x800;
3825
3826/// NB conflicts with EF_ARM_SOFT_FLOAT
3827pub const EF_ARM_ABI_FLOAT_SOFT: u32 = 0x200;
3828/// NB conflicts with EF_ARM_VFP_FLOAT
3829pub const EF_ARM_ABI_FLOAT_HARD: u32 = 0x400;
3830
3831// Other constants defined in the ARM ELF spec. version B-01.
3832// NB. These conflict with values defined above.
3833pub const EF_ARM_SYMSARESORTED: u32 = 0x04;
3834pub const EF_ARM_DYNSYMSUSESEGIDX: u32 = 0x08;
3835pub const EF_ARM_MAPSYMSFIRST: u32 = 0x10;
3836
3837// Constants defined in AAELF.
3838pub const EF_ARM_BE8: u32 = 0x0080_0000;
3839pub const EF_ARM_LE8: u32 = 0x0040_0000;
3840
3841pub const EF_ARM_EABIMASK: u32 = 0xff00_0000;
3842pub const EF_ARM_EABI_UNKNOWN: u32 = 0x0000_0000;
3843pub const EF_ARM_EABI_VER1: u32 = 0x0100_0000;
3844pub const EF_ARM_EABI_VER2: u32 = 0x0200_0000;
3845pub const EF_ARM_EABI_VER3: u32 = 0x0300_0000;
3846pub const EF_ARM_EABI_VER4: u32 = 0x0400_0000;
3847pub const EF_ARM_EABI_VER5: u32 = 0x0500_0000;
3848
3849// ARM Thumb values for `st_type` component of `Sym*::st_info`.
3850/// A Thumb function.
3851pub const STT_ARM_TFUNC: u8 = STT_LOPROC;
3852/// A Thumb label.
3853pub const STT_ARM_16BIT: u8 = STT_HIPROC;
3854
3855// ARM values for `SectionHeader*::sh_flags`.
3856/// Section contains an entry point
3857pub const SHF_ARM_ENTRYSECT: u32 = 0x1000_0000;
3858/// Section may be multiply defined in the input to a link step.
3859pub const SHF_ARM_COMDEF: u32 = 0x8000_0000;
3860
3861// ARM values for `ProgramHeader*::p_flags`.
3862/// Segment contains the location addressed by the static base.
3863pub const PF_ARM_SB: u32 = 0x1000_0000;
3864/// Position-independent segment.
3865pub const PF_ARM_PI: u32 = 0x2000_0000;
3866/// Absolute segment.
3867pub const PF_ARM_ABS: u32 = 0x4000_0000;
3868
3869// ARM values for `ProgramHeader*::p_type`.
3870/// ARM unwind segment.
3871pub const PT_ARM_EXIDX: u32 = PT_LOPROC + 1;
3872
3873// ARM values for `SectionHeader*::sh_type`.
3874/// ARM unwind section.
3875pub const SHT_ARM_EXIDX: u32 = SHT_LOPROC + 1;
3876/// Preemption details.
3877pub const SHT_ARM_PREEMPTMAP: u32 = SHT_LOPROC + 2;
3878/// ARM attributes section.
3879pub const SHT_ARM_ATTRIBUTES: u32 = SHT_LOPROC + 3;
3880
3881// AArch64 values for `SectionHeader*::sh_type`.
3882/// AArch64 attributes section.
3883pub const SHT_AARCH64_ATTRIBUTES: u32 = SHT_LOPROC + 3;
3884
3885// AArch64 values for `Sym64::st_other`.
3886pub const STO_AARCH64_VARIANT_PCS: u8 = 0x80;
3887
3888// AArch64 values for `Dyn64::d_tag`.
3889pub const DT_AARCH64_BTI_PLT: i64 = DT_LOPROC + 1;
3890pub const DT_AARCH64_PAC_PLT: i64 = DT_LOPROC + 3;
3891pub const DT_AARCH64_VARIANT_PCS: i64 = DT_LOPROC + 5;
3892pub const DT_AARCH64_NUM: i64 = 6;
3893
3894// AArch64 values for `Rel*::r_type`.
3895
3896/// No relocation.
3897pub const R_AARCH64_NONE: u32 = 0;
3898
3899// ILP32 AArch64 relocs.
3900/// Direct 32 bit.
3901pub const R_AARCH64_P32_ABS32: u32 = 1;
3902/// Copy symbol at runtime.
3903pub const R_AARCH64_P32_COPY: u32 = 180;
3904/// Create GOT entry.
3905pub const R_AARCH64_P32_GLOB_DAT: u32 = 181;
3906/// Create PLT entry.
3907pub const R_AARCH64_P32_JUMP_SLOT: u32 = 182;
3908/// Adjust by program base.
3909pub const R_AARCH64_P32_RELATIVE: u32 = 183;
3910/// Module number, 32 bit.
3911pub const R_AARCH64_P32_TLS_DTPMOD: u32 = 184;
3912/// Module-relative offset, 32 bit.
3913pub const R_AARCH64_P32_TLS_DTPREL: u32 = 185;
3914/// TP-relative offset, 32 bit.
3915pub const R_AARCH64_P32_TLS_TPREL: u32 = 186;
3916/// TLS Descriptor.
3917pub const R_AARCH64_P32_TLSDESC: u32 = 187;
3918/// STT_GNU_IFUNC relocation.
3919pub const R_AARCH64_P32_IRELATIVE: u32 = 188;
3920
3921// LP64 AArch64 relocs.
3922/// Direct 64 bit.
3923pub const R_AARCH64_ABS64: u32 = 257;
3924/// Direct 32 bit.
3925pub const R_AARCH64_ABS32: u32 = 258;
3926/// Direct 16-bit.
3927pub const R_AARCH64_ABS16: u32 = 259;
3928/// PC-relative 64-bit.
3929pub const R_AARCH64_PREL64: u32 = 260;
3930/// PC-relative 32-bit.
3931pub const R_AARCH64_PREL32: u32 = 261;
3932/// PC-relative 16-bit.
3933pub const R_AARCH64_PREL16: u32 = 262;
3934/// Dir. MOVZ imm. from bits 15:0.
3935pub const R_AARCH64_MOVW_UABS_G0: u32 = 263;
3936/// Likewise for MOVK; no check.
3937pub const R_AARCH64_MOVW_UABS_G0_NC: u32 = 264;
3938/// Dir. MOVZ imm. from bits 31:16.
3939pub const R_AARCH64_MOVW_UABS_G1: u32 = 265;
3940/// Likewise for MOVK; no check.
3941pub const R_AARCH64_MOVW_UABS_G1_NC: u32 = 266;
3942/// Dir. MOVZ imm. from bits 47:32.
3943pub const R_AARCH64_MOVW_UABS_G2: u32 = 267;
3944/// Likewise for MOVK; no check.
3945pub const R_AARCH64_MOVW_UABS_G2_NC: u32 = 268;
3946/// Dir. MOV{K,Z} imm. from 63:48.
3947pub const R_AARCH64_MOVW_UABS_G3: u32 = 269;
3948/// Dir. MOV{N,Z} imm. from 15:0.
3949pub const R_AARCH64_MOVW_SABS_G0: u32 = 270;
3950/// Dir. MOV{N,Z} imm. from 31:16.
3951pub const R_AARCH64_MOVW_SABS_G1: u32 = 271;
3952/// Dir. MOV{N,Z} imm. from 47:32.
3953pub const R_AARCH64_MOVW_SABS_G2: u32 = 272;
3954/// PC-rel. LD imm. from bits 20:2.
3955pub const R_AARCH64_LD_PREL_LO19: u32 = 273;
3956/// PC-rel. ADR imm. from bits 20:0.
3957pub const R_AARCH64_ADR_PREL_LO21: u32 = 274;
3958/// Page-rel. ADRP imm. from 32:12.
3959pub const R_AARCH64_ADR_PREL_PG_HI21: u32 = 275;
3960/// Likewise; no overflow check.
3961pub const R_AARCH64_ADR_PREL_PG_HI21_NC: u32 = 276;
3962/// Dir. ADD imm. from bits 11:0.
3963pub const R_AARCH64_ADD_ABS_LO12_NC: u32 = 277;
3964/// Likewise for LD/ST; no check.
3965pub const R_AARCH64_LDST8_ABS_LO12_NC: u32 = 278;
3966/// PC-rel. TBZ/TBNZ imm. from 15:2.
3967pub const R_AARCH64_TSTBR14: u32 = 279;
3968/// PC-rel. cond. br. imm. from 20:2.
3969pub const R_AARCH64_CONDBR19: u32 = 280;
3970/// PC-rel. B imm. from bits 27:2.
3971pub const R_AARCH64_JUMP26: u32 = 282;
3972/// Likewise for CALL.
3973pub const R_AARCH64_CALL26: u32 = 283;
3974/// Dir. ADD imm. from bits 11:1.
3975pub const R_AARCH64_LDST16_ABS_LO12_NC: u32 = 284;
3976/// Likewise for bits 11:2.
3977pub const R_AARCH64_LDST32_ABS_LO12_NC: u32 = 285;
3978/// Likewise for bits 11:3.
3979pub const R_AARCH64_LDST64_ABS_LO12_NC: u32 = 286;
3980/// PC-rel. MOV{N,Z} imm. from 15:0.
3981pub const R_AARCH64_MOVW_PREL_G0: u32 = 287;
3982/// Likewise for MOVK; no check.
3983pub const R_AARCH64_MOVW_PREL_G0_NC: u32 = 288;
3984/// PC-rel. MOV{N,Z} imm. from 31:16.
3985pub const R_AARCH64_MOVW_PREL_G1: u32 = 289;
3986/// Likewise for MOVK; no check.
3987pub const R_AARCH64_MOVW_PREL_G1_NC: u32 = 290;
3988/// PC-rel. MOV{N,Z} imm. from 47:32.
3989pub const R_AARCH64_MOVW_PREL_G2: u32 = 291;
3990/// Likewise for MOVK; no check.
3991pub const R_AARCH64_MOVW_PREL_G2_NC: u32 = 292;
3992/// PC-rel. MOV{N,Z} imm. from 63:48.
3993pub const R_AARCH64_MOVW_PREL_G3: u32 = 293;
3994/// Dir. ADD imm. from bits 11:4.
3995pub const R_AARCH64_LDST128_ABS_LO12_NC: u32 = 299;
3996/// GOT-rel. off. MOV{N,Z} imm. 15:0.
3997pub const R_AARCH64_MOVW_GOTOFF_G0: u32 = 300;
3998/// Likewise for MOVK; no check.
3999pub const R_AARCH64_MOVW_GOTOFF_G0_NC: u32 = 301;
4000/// GOT-rel. o. MOV{N,Z} imm. 31:16.
4001pub const R_AARCH64_MOVW_GOTOFF_G1: u32 = 302;
4002/// Likewise for MOVK; no check.
4003pub const R_AARCH64_MOVW_GOTOFF_G1_NC: u32 = 303;
4004/// GOT-rel. o. MOV{N,Z} imm. 47:32.
4005pub const R_AARCH64_MOVW_GOTOFF_G2: u32 = 304;
4006/// Likewise for MOVK; no check.
4007pub const R_AARCH64_MOVW_GOTOFF_G2_NC: u32 = 305;
4008/// GOT-rel. o. MOV{N,Z} imm. 63:48.
4009pub const R_AARCH64_MOVW_GOTOFF_G3: u32 = 306;
4010/// GOT-relative 64-bit.
4011pub const R_AARCH64_GOTREL64: u32 = 307;
4012/// GOT-relative 32-bit.
4013pub const R_AARCH64_GOTREL32: u32 = 308;
4014/// PC-rel. GOT off. load imm. 20:2.
4015pub const R_AARCH64_GOT_LD_PREL19: u32 = 309;
4016/// GOT-rel. off. LD/ST imm. 14:3.
4017pub const R_AARCH64_LD64_GOTOFF_LO15: u32 = 310;
4018/// P-page-rel. GOT off. ADRP 32:12.
4019pub const R_AARCH64_ADR_GOT_PAGE: u32 = 311;
4020/// Dir. GOT off. LD/ST imm. 11:3.
4021pub const R_AARCH64_LD64_GOT_LO12_NC: u32 = 312;
4022/// GOT-page-rel. GOT off. LD/ST 14:3
4023pub const R_AARCH64_LD64_GOTPAGE_LO15: u32 = 313;
4024/// PC-relative 32-bit.
4025pub const R_AARCH64_PLT32: u32 = 314;
4026/// GOT-relative PC-relative.
4027pub const R_AARCH64_GOTPCREL32: u32 = 315;
4028/// PC-relative ADR imm. 20:0.
4029pub const R_AARCH64_TLSGD_ADR_PREL21: u32 = 512;
4030/// page-rel. ADRP imm. 32:12.
4031pub const R_AARCH64_TLSGD_ADR_PAGE21: u32 = 513;
4032/// direct ADD imm. from 11:0.
4033pub const R_AARCH64_TLSGD_ADD_LO12_NC: u32 = 514;
4034/// GOT-rel. MOV{N,Z} 31:16.
4035pub const R_AARCH64_TLSGD_MOVW_G1: u32 = 515;
4036/// GOT-rel. MOVK imm. 15:0.
4037pub const R_AARCH64_TLSGD_MOVW_G0_NC: u32 = 516;
4038/// Like 512; local dynamic model.
4039pub const R_AARCH64_TLSLD_ADR_PREL21: u32 = 517;
4040/// Like 513; local dynamic model.
4041pub const R_AARCH64_TLSLD_ADR_PAGE21: u32 = 518;
4042/// Like 514; local dynamic model.
4043pub const R_AARCH64_TLSLD_ADD_LO12_NC: u32 = 519;
4044/// Like 515; local dynamic model.
4045pub const R_AARCH64_TLSLD_MOVW_G1: u32 = 520;
4046/// Like 516; local dynamic model.
4047pub const R_AARCH64_TLSLD_MOVW_G0_NC: u32 = 521;
4048/// TLS PC-rel. load imm. 20:2.
4049pub const R_AARCH64_TLSLD_LD_PREL19: u32 = 522;
4050/// TLS DTP-rel. MOV{N,Z} 47:32.
4051pub const R_AARCH64_TLSLD_MOVW_DTPREL_G2: u32 = 523;
4052/// TLS DTP-rel. MOV{N,Z} 31:16.
4053pub const R_AARCH64_TLSLD_MOVW_DTPREL_G1: u32 = 524;
4054/// Likewise; MOVK; no check.
4055pub const R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC: u32 = 525;
4056/// TLS DTP-rel. MOV{N,Z} 15:0.
4057pub const R_AARCH64_TLSLD_MOVW_DTPREL_G0: u32 = 526;
4058/// Likewise; MOVK; no check.
4059pub const R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC: u32 = 527;
4060/// DTP-rel. ADD imm. from 23:12.
4061pub const R_AARCH64_TLSLD_ADD_DTPREL_HI12: u32 = 528;
4062/// DTP-rel. ADD imm. from 11:0.
4063pub const R_AARCH64_TLSLD_ADD_DTPREL_LO12: u32 = 529;
4064/// Likewise; no ovfl. check.
4065pub const R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC: u32 = 530;
4066/// DTP-rel. LD/ST imm. 11:0.
4067pub const R_AARCH64_TLSLD_LDST8_DTPREL_LO12: u32 = 531;
4068/// Likewise; no check.
4069pub const R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC: u32 = 532;
4070/// DTP-rel. LD/ST imm. 11:1.
4071pub const R_AARCH64_TLSLD_LDST16_DTPREL_LO12: u32 = 533;
4072/// Likewise; no check.
4073pub const R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC: u32 = 534;
4074/// DTP-rel. LD/ST imm. 11:2.
4075pub const R_AARCH64_TLSLD_LDST32_DTPREL_LO12: u32 = 535;
4076/// Likewise; no check.
4077pub const R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC: u32 = 536;
4078/// DTP-rel. LD/ST imm. 11:3.
4079pub const R_AARCH64_TLSLD_LDST64_DTPREL_LO12: u32 = 537;
4080/// Likewise; no check.
4081pub const R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC: u32 = 538;
4082/// GOT-rel. MOV{N,Z} 31:16.
4083pub const R_AARCH64_TLSIE_MOVW_GOTTPREL_G1: u32 = 539;
4084/// GOT-rel. MOVK 15:0.
4085pub const R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC: u32 = 540;
4086/// Page-rel. ADRP 32:12.
4087pub const R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: u32 = 541;
4088/// Direct LD off. 11:3.
4089pub const R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: u32 = 542;
4090/// PC-rel. load imm. 20:2.
4091pub const R_AARCH64_TLSIE_LD_GOTTPREL_PREL19: u32 = 543;
4092/// TLS TP-rel. MOV{N,Z} 47:32.
4093pub const R_AARCH64_TLSLE_MOVW_TPREL_G2: u32 = 544;
4094/// TLS TP-rel. MOV{N,Z} 31:16.
4095pub const R_AARCH64_TLSLE_MOVW_TPREL_G1: u32 = 545;
4096/// Likewise; MOVK; no check.
4097pub const R_AARCH64_TLSLE_MOVW_TPREL_G1_NC: u32 = 546;
4098/// TLS TP-rel. MOV{N,Z} 15:0.
4099pub const R_AARCH64_TLSLE_MOVW_TPREL_G0: u32 = 547;
4100/// Likewise; MOVK; no check.
4101pub const R_AARCH64_TLSLE_MOVW_TPREL_G0_NC: u32 = 548;
4102/// TP-rel. ADD imm. 23:12.
4103pub const R_AARCH64_TLSLE_ADD_TPREL_HI12: u32 = 549;
4104/// TP-rel. ADD imm. 11:0.
4105pub const R_AARCH64_TLSLE_ADD_TPREL_LO12: u32 = 550;
4106/// Likewise; no ovfl. check.
4107pub const R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: u32 = 551;
4108/// TP-rel. LD/ST off. 11:0.
4109pub const R_AARCH64_TLSLE_LDST8_TPREL_LO12: u32 = 552;
4110/// Likewise; no ovfl. check.
4111pub const R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC: u32 = 553;
4112/// TP-rel. LD/ST off. 11:1.
4113pub const R_AARCH64_TLSLE_LDST16_TPREL_LO12: u32 = 554;
4114/// Likewise; no check.
4115pub const R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC: u32 = 555;
4116/// TP-rel. LD/ST off. 11:2.
4117pub const R_AARCH64_TLSLE_LDST32_TPREL_LO12: u32 = 556;
4118/// Likewise; no check.
4119pub const R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC: u32 = 557;
4120/// TP-rel. LD/ST off. 11:3.
4121pub const R_AARCH64_TLSLE_LDST64_TPREL_LO12: u32 = 558;
4122/// Likewise; no check.
4123pub const R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC: u32 = 559;
4124/// PC-rel. load immediate 20:2.
4125pub const R_AARCH64_TLSDESC_LD_PREL19: u32 = 560;
4126/// PC-rel. ADR immediate 20:0.
4127pub const R_AARCH64_TLSDESC_ADR_PREL21: u32 = 561;
4128/// Page-rel. ADRP imm. 32:12.
4129pub const R_AARCH64_TLSDESC_ADR_PAGE21: u32 = 562;
4130/// Direct LD off. from 11:3.
4131pub const R_AARCH64_TLSDESC_LD64_LO12: u32 = 563;
4132/// Direct ADD imm. from 11:0.
4133pub const R_AARCH64_TLSDESC_ADD_LO12: u32 = 564;
4134/// GOT-rel. MOV{N,Z} imm. 31:16.
4135pub const R_AARCH64_TLSDESC_OFF_G1: u32 = 565;
4136/// GOT-rel. MOVK imm. 15:0; no ck.
4137pub const R_AARCH64_TLSDESC_OFF_G0_NC: u32 = 566;
4138/// Relax LDR.
4139pub const R_AARCH64_TLSDESC_LDR: u32 = 567;
4140/// Relax ADD.
4141pub const R_AARCH64_TLSDESC_ADD: u32 = 568;
4142/// Relax BLR.
4143pub const R_AARCH64_TLSDESC_CALL: u32 = 569;
4144/// TP-rel. LD/ST off. 11:4.
4145pub const R_AARCH64_TLSLE_LDST128_TPREL_LO12: u32 = 570;
4146/// Likewise; no check.
4147pub const R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC: u32 = 571;
4148/// DTP-rel. LD/ST imm. 11:4.
4149pub const R_AARCH64_TLSLD_LDST128_DTPREL_LO12: u32 = 572;
4150/// Likewise; no check.
4151pub const R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC: u32 = 573;
4152/// Copy symbol at runtime.
4153pub const R_AARCH64_COPY: u32 = 1024;
4154/// Create GOT entry.
4155pub const R_AARCH64_GLOB_DAT: u32 = 1025;
4156/// Create PLT entry.
4157pub const R_AARCH64_JUMP_SLOT: u32 = 1026;
4158/// Adjust by program base.
4159pub const R_AARCH64_RELATIVE: u32 = 1027;
4160/// Module number, 64 bit.
4161pub const R_AARCH64_TLS_DTPMOD: u32 = 1028;
4162/// Module-relative offset, 64 bit.
4163pub const R_AARCH64_TLS_DTPREL: u32 = 1029;
4164/// TP-relative offset, 64 bit.
4165pub const R_AARCH64_TLS_TPREL: u32 = 1030;
4166/// TLS Descriptor.
4167pub const R_AARCH64_TLSDESC: u32 = 1031;
4168/// STT_GNU_IFUNC relocation.
4169pub const R_AARCH64_IRELATIVE: u32 = 1032;
4170
4171// AVR values for `FileHeader*::e_flags`.
4172
4173/// Bitmask for `EF_AVR_ARCH_*`.
4174pub const EF_AVR_ARCH: u32 = 0x7F;
4175
4176/// If set, it is assumed that the elf file uses local symbols as reference
4177/// for the relocations so that linker relaxation is possible.
4178pub const EF_AVR_LINKRELAX_PREPARED: u32 = 0x80;
4179
4180pub const EF_AVR_ARCH_AVR1: u32 = 1;
4181pub const EF_AVR_ARCH_AVR2: u32 = 2;
4182pub const EF_AVR_ARCH_AVR25: u32 = 25;
4183pub const EF_AVR_ARCH_AVR3: u32 = 3;
4184pub const EF_AVR_ARCH_AVR31: u32 = 31;
4185pub const EF_AVR_ARCH_AVR35: u32 = 35;
4186pub const EF_AVR_ARCH_AVR4: u32 = 4;
4187pub const EF_AVR_ARCH_AVR5: u32 = 5;
4188pub const EF_AVR_ARCH_AVR51: u32 = 51;
4189pub const EF_AVR_ARCH_AVR6: u32 = 6;
4190pub const EF_AVR_ARCH_AVRTINY: u32 = 100;
4191pub const EF_AVR_ARCH_XMEGA1: u32 = 101;
4192pub const EF_AVR_ARCH_XMEGA2: u32 = 102;
4193pub const EF_AVR_ARCH_XMEGA3: u32 = 103;
4194pub const EF_AVR_ARCH_XMEGA4: u32 = 104;
4195pub const EF_AVR_ARCH_XMEGA5: u32 = 105;
4196pub const EF_AVR_ARCH_XMEGA6: u32 = 106;
4197pub const EF_AVR_ARCH_XMEGA7: u32 = 107;
4198
4199// AVR values for `Rel*::r_type`.
4200
4201pub const R_AVR_NONE: u32 = 0;
4202/// Direct 32 bit
4203pub const R_AVR_32: u32 = 1;
4204pub const R_AVR_7_PCREL: u32 = 2;
4205pub const R_AVR_13_PCREL: u32 = 3;
4206/// Direct 16 bit
4207pub const R_AVR_16: u32 = 4;
4208pub const R_AVR_16_PM: u32 = 5;
4209pub const R_AVR_LO8_LDI: u32 = 6;
4210pub const R_AVR_HI8_LDI: u32 = 7;
4211pub const R_AVR_HH8_LDI: u32 = 8;
4212pub const R_AVR_LO8_LDI_NEG: u32 = 9;
4213pub const R_AVR_HI8_LDI_NEG: u32 = 10;
4214pub const R_AVR_HH8_LDI_NEG: u32 = 11;
4215pub const R_AVR_LO8_LDI_PM: u32 = 12;
4216pub const R_AVR_HI8_LDI_PM: u32 = 13;
4217pub const R_AVR_HH8_LDI_PM: u32 = 14;
4218pub const R_AVR_LO8_LDI_PM_NEG: u32 = 15;
4219pub const R_AVR_HI8_LDI_PM_NEG: u32 = 16;
4220pub const R_AVR_HH8_LDI_PM_NEG: u32 = 17;
4221pub const R_AVR_CALL: u32 = 18;
4222pub const R_AVR_LDI: u32 = 19;
4223pub const R_AVR_6: u32 = 20;
4224pub const R_AVR_6_ADIW: u32 = 21;
4225pub const R_AVR_MS8_LDI: u32 = 22;
4226pub const R_AVR_MS8_LDI_NEG: u32 = 23;
4227pub const R_AVR_LO8_LDI_GS: u32 = 24;
4228pub const R_AVR_HI8_LDI_GS: u32 = 25;
4229pub const R_AVR_8: u32 = 26;
4230pub const R_AVR_8_LO8: u32 = 27;
4231pub const R_AVR_8_HI8: u32 = 28;
4232pub const R_AVR_8_HLO8: u32 = 29;
4233pub const R_AVR_DIFF8: u32 = 30;
4234pub const R_AVR_DIFF16: u32 = 31;
4235pub const R_AVR_DIFF32: u32 = 32;
4236pub const R_AVR_LDS_STS_16: u32 = 33;
4237pub const R_AVR_PORT6: u32 = 34;
4238pub const R_AVR_PORT5: u32 = 35;
4239pub const R_AVR_32_PCREL: u32 = 36;
4240
4241// MSP430 values for `Rel*::r_type`.
4242
4243/// No reloc
4244pub const R_MSP430_NONE: u32 = 0;
4245/// Direct 32 bit
4246pub const R_MSP430_32: u32 = 1;
4247/// Direct 16 bit
4248pub const R_MSP430_16_BYTE: u32 = 5;
4249
4250// Hexagon values for `Rel*::r_type`.
4251
4252/// No reloc
4253pub const R_HEX_NONE: u32 = 0;
4254/// Direct 32 bit
4255pub const R_HEX_32: u32 = 6;
4256
4257// ARM values for `Rel*::r_type`.
4258
4259/// No reloc
4260pub const R_ARM_NONE: u32 = 0;
4261/// Deprecated PC relative 26 bit branch.
4262pub const R_ARM_PC24: u32 = 1;
4263/// Direct 32 bit
4264pub const R_ARM_ABS32: u32 = 2;
4265/// PC relative 32 bit
4266pub const R_ARM_REL32: u32 = 3;
4267pub const R_ARM_PC13: u32 = 4;
4268/// Direct 16 bit
4269pub const R_ARM_ABS16: u32 = 5;
4270/// Direct 12 bit
4271pub const R_ARM_ABS12: u32 = 6;
4272/// Direct & 0x7C (`LDR`, `STR`).
4273pub const R_ARM_THM_ABS5: u32 = 7;
4274/// Direct 8 bit
4275pub const R_ARM_ABS8: u32 = 8;
4276pub const R_ARM_SBREL32: u32 = 9;
4277/// PC relative 24 bit (Thumb32 `BL`).
4278pub const R_ARM_THM_PC22: u32 = 10;
4279/// PC relative & 0x3FC (Thumb16 `LDR`, `ADD`, `ADR`).
4280pub const R_ARM_THM_PC8: u32 = 11;
4281pub const R_ARM_AMP_VCALL9: u32 = 12;
4282/// Obsolete static relocation.
4283pub const R_ARM_SWI24: u32 = 13;
4284/// Dynamic relocation.
4285pub const R_ARM_TLS_DESC: u32 = 13;
4286/// Reserved.
4287pub const R_ARM_THM_SWI8: u32 = 14;
4288/// Reserved.
4289pub const R_ARM_XPC25: u32 = 15;
4290/// Reserved.
4291pub const R_ARM_THM_XPC22: u32 = 16;
4292/// ID of module containing symbol
4293pub const R_ARM_TLS_DTPMOD32: u32 = 17;
4294/// Offset in TLS block
4295pub const R_ARM_TLS_DTPOFF32: u32 = 18;
4296/// Offset in static TLS block
4297pub const R_ARM_TLS_TPOFF32: u32 = 19;
4298/// Copy symbol at runtime
4299pub const R_ARM_COPY: u32 = 20;
4300/// Create GOT entry
4301pub const R_ARM_GLOB_DAT: u32 = 21;
4302/// Create PLT entry
4303pub const R_ARM_JUMP_SLOT: u32 = 22;
4304/// Adjust by program base
4305pub const R_ARM_RELATIVE: u32 = 23;
4306/// 32 bit offset to GOT
4307pub const R_ARM_GOTOFF: u32 = 24;
4308/// 32 bit PC relative offset to GOT
4309pub const R_ARM_GOTPC: u32 = 25;
4310/// 32 bit GOT entry
4311pub const R_ARM_GOT32: u32 = 26;
4312/// Deprecated, 32 bit PLT address.
4313pub const R_ARM_PLT32: u32 = 27;
4314/// PC relative 24 bit (`BL`, `BLX`).
4315pub const R_ARM_CALL: u32 = 28;
4316/// PC relative 24 bit (`B`, `BL<cond>`).
4317pub const R_ARM_JUMP24: u32 = 29;
4318/// PC relative 24 bit (Thumb32 `B.W`).
4319pub const R_ARM_THM_JUMP24: u32 = 30;
4320/// Adjust by program base.
4321pub const R_ARM_BASE_ABS: u32 = 31;
4322/// Obsolete.
4323pub const R_ARM_ALU_PCREL_7_0: u32 = 32;
4324/// Obsolete.
4325pub const R_ARM_ALU_PCREL_15_8: u32 = 33;
4326/// Obsolete.
4327pub const R_ARM_ALU_PCREL_23_15: u32 = 34;
4328/// Deprecated, prog. base relative.
4329pub const R_ARM_LDR_SBREL_11_0: u32 = 35;
4330/// Deprecated, prog. base relative.
4331pub const R_ARM_ALU_SBREL_19_12: u32 = 36;
4332/// Deprecated, prog. base relative.
4333pub const R_ARM_ALU_SBREL_27_20: u32 = 37;
4334pub const R_ARM_TARGET1: u32 = 38;
4335/// Program base relative.
4336pub const R_ARM_SBREL31: u32 = 39;
4337pub const R_ARM_V4BX: u32 = 40;
4338pub const R_ARM_TARGET2: u32 = 41;
4339/// 32 bit PC relative.
4340pub const R_ARM_PREL31: u32 = 42;
4341/// Direct 16-bit (`MOVW`).
4342pub const R_ARM_MOVW_ABS_NC: u32 = 43;
4343/// Direct high 16-bit (`MOVT`).
4344pub const R_ARM_MOVT_ABS: u32 = 44;
4345/// PC relative 16-bit (`MOVW`).
4346pub const R_ARM_MOVW_PREL_NC: u32 = 45;
4347/// PC relative (MOVT).
4348pub const R_ARM_MOVT_PREL: u32 = 46;
4349/// Direct 16 bit (Thumb32 `MOVW`).
4350pub const R_ARM_THM_MOVW_ABS_NC: u32 = 47;
4351/// Direct high 16 bit (Thumb32 `MOVT`).
4352pub const R_ARM_THM_MOVT_ABS: u32 = 48;
4353/// PC relative 16 bit (Thumb32 `MOVW`).
4354pub const R_ARM_THM_MOVW_PREL_NC: u32 = 49;
4355/// PC relative high 16 bit (Thumb32 `MOVT`).
4356pub const R_ARM_THM_MOVT_PREL: u32 = 50;
4357/// PC relative 20 bit (Thumb32 `B<cond>.W`).
4358pub const R_ARM_THM_JUMP19: u32 = 51;
4359/// PC relative X & 0x7E (Thumb16 `CBZ`, `CBNZ`).
4360pub const R_ARM_THM_JUMP6: u32 = 52;
4361/// PC relative 12 bit (Thumb32 `ADR.W`).
4362pub const R_ARM_THM_ALU_PREL_11_0: u32 = 53;
4363/// PC relative 12 bit (Thumb32 `LDR{D,SB,H,SH}`).
4364pub const R_ARM_THM_PC12: u32 = 54;
4365/// Direct 32-bit.
4366pub const R_ARM_ABS32_NOI: u32 = 55;
4367/// PC relative 32-bit.
4368pub const R_ARM_REL32_NOI: u32 = 56;
4369/// PC relative (`ADD`, `SUB`).
4370pub const R_ARM_ALU_PC_G0_NC: u32 = 57;
4371/// PC relative (`ADD`, `SUB`).
4372pub const R_ARM_ALU_PC_G0: u32 = 58;
4373/// PC relative (`ADD`, `SUB`).
4374pub const R_ARM_ALU_PC_G1_NC: u32 = 59;
4375/// PC relative (`ADD`, `SUB`).
4376pub const R_ARM_ALU_PC_G1: u32 = 60;
4377/// PC relative (`ADD`, `SUB`).
4378pub const R_ARM_ALU_PC_G2: u32 = 61;
4379/// PC relative (`LDR`,`STR`,`LDRB`,`STRB`).
4380pub const R_ARM_LDR_PC_G1: u32 = 62;
4381/// PC relative (`LDR`,`STR`,`LDRB`,`STRB`).
4382pub const R_ARM_LDR_PC_G2: u32 = 63;
4383/// PC relative (`STR{D,H}`, `LDR{D,SB,H,SH}`).
4384pub const R_ARM_LDRS_PC_G0: u32 = 64;
4385/// PC relative (`STR{D,H}`, `LDR{D,SB,H,SH}`).
4386pub const R_ARM_LDRS_PC_G1: u32 = 65;
4387/// PC relative (`STR{D,H}`, `LDR{D,SB,H,SH}`).
4388pub const R_ARM_LDRS_PC_G2: u32 = 66;
4389/// PC relative (`LDC`, `STC`).
4390pub const R_ARM_LDC_PC_G0: u32 = 67;
4391/// PC relative (`LDC`, `STC`).
4392pub const R_ARM_LDC_PC_G1: u32 = 68;
4393/// PC relative (`LDC`, `STC`).
4394pub const R_ARM_LDC_PC_G2: u32 = 69;
4395/// Program base relative (`ADD`,`SUB`).
4396pub const R_ARM_ALU_SB_G0_NC: u32 = 70;
4397/// Program base relative (`ADD`,`SUB`).
4398pub const R_ARM_ALU_SB_G0: u32 = 71;
4399/// Program base relative (`ADD`,`SUB`).
4400pub const R_ARM_ALU_SB_G1_NC: u32 = 72;
4401/// Program base relative (`ADD`,`SUB`).
4402pub const R_ARM_ALU_SB_G1: u32 = 73;
4403/// Program base relative (`ADD`,`SUB`).
4404pub const R_ARM_ALU_SB_G2: u32 = 74;
4405/// Program base relative (`LDR`, `STR`, `LDRB`, `STRB`).
4406pub const R_ARM_LDR_SB_G0: u32 = 75;
4407/// Program base relative (`LDR`, `STR`, `LDRB`, `STRB`).
4408pub const R_ARM_LDR_SB_G1: u32 = 76;
4409/// Program base relative (`LDR`, `STR`, `LDRB`, `STRB`).
4410pub const R_ARM_LDR_SB_G2: u32 = 77;
4411/// Program base relative (`LDR`, `STR`, `LDRB`, `STRB`).
4412pub const R_ARM_LDRS_SB_G0: u32 = 78;
4413/// Program base relative (`LDR`, `STR`, `LDRB`, `STRB`).
4414pub const R_ARM_LDRS_SB_G1: u32 = 79;
4415/// Program base relative (`LDR`, `STR`, `LDRB`, `STRB`).
4416pub const R_ARM_LDRS_SB_G2: u32 = 80;
4417/// Program base relative (`LDC`,`STC`).
4418pub const R_ARM_LDC_SB_G0: u32 = 81;
4419/// Program base relative (`LDC`,`STC`).
4420pub const R_ARM_LDC_SB_G1: u32 = 82;
4421/// Program base relative (`LDC`,`STC`).
4422pub const R_ARM_LDC_SB_G2: u32 = 83;
4423/// Program base relative 16 bit (`MOVW`).
4424pub const R_ARM_MOVW_BREL_NC: u32 = 84;
4425/// Program base relative high 16 bit (`MOVT`).
4426pub const R_ARM_MOVT_BREL: u32 = 85;
4427/// Program base relative 16 bit (`MOVW`).
4428pub const R_ARM_MOVW_BREL: u32 = 86;
4429/// Program base relative 16 bit (Thumb32 `MOVW`).
4430pub const R_ARM_THM_MOVW_BREL_NC: u32 = 87;
4431/// Program base relative high 16 bit (Thumb32 `MOVT`).
4432pub const R_ARM_THM_MOVT_BREL: u32 = 88;
4433/// Program base relative 16 bit (Thumb32 `MOVW`).
4434pub const R_ARM_THM_MOVW_BREL: u32 = 89;
4435pub const R_ARM_TLS_GOTDESC: u32 = 90;
4436pub const R_ARM_TLS_CALL: u32 = 91;
4437/// TLS relaxation.
4438pub const R_ARM_TLS_DESCSEQ: u32 = 92;
4439pub const R_ARM_THM_TLS_CALL: u32 = 93;
4440pub const R_ARM_PLT32_ABS: u32 = 94;
4441/// GOT entry.
4442pub const R_ARM_GOT_ABS: u32 = 95;
4443/// PC relative GOT entry.
4444pub const R_ARM_GOT_PREL: u32 = 96;
4445/// GOT entry relative to GOT origin (`LDR`).
4446pub const R_ARM_GOT_BREL12: u32 = 97;
4447/// 12 bit, GOT entry relative to GOT origin (`LDR`, `STR`).
4448pub const R_ARM_GOTOFF12: u32 = 98;
4449pub const R_ARM_GOTRELAX: u32 = 99;
4450pub const R_ARM_GNU_VTENTRY: u32 = 100;
4451pub const R_ARM_GNU_VTINHERIT: u32 = 101;
4452/// PC relative & 0xFFE (Thumb16 `B`).
4453pub const R_ARM_THM_PC11: u32 = 102;
4454/// PC relative & 0x1FE (Thumb16 `B`/`B<cond>`).
4455pub const R_ARM_THM_PC9: u32 = 103;
4456/// PC-rel 32 bit for global dynamic thread local data
4457pub const R_ARM_TLS_GD32: u32 = 104;
4458/// PC-rel 32 bit for local dynamic thread local data
4459pub const R_ARM_TLS_LDM32: u32 = 105;
4460/// 32 bit offset relative to TLS block
4461pub const R_ARM_TLS_LDO32: u32 = 106;
4462/// PC-rel 32 bit for GOT entry of static TLS block offset
4463pub const R_ARM_TLS_IE32: u32 = 107;
4464/// 32 bit offset relative to static TLS block
4465pub const R_ARM_TLS_LE32: u32 = 108;
4466/// 12 bit relative to TLS block (`LDR`, `STR`).
4467pub const R_ARM_TLS_LDO12: u32 = 109;
4468/// 12 bit relative to static TLS block (`LDR`, `STR`).
4469pub const R_ARM_TLS_LE12: u32 = 110;
4470/// 12 bit GOT entry relative to GOT origin (`LDR`).
4471pub const R_ARM_TLS_IE12GP: u32 = 111;
4472/// Obsolete.
4473pub const R_ARM_ME_TOO: u32 = 128;
4474pub const R_ARM_THM_TLS_DESCSEQ: u32 = 129;
4475pub const R_ARM_THM_TLS_DESCSEQ16: u32 = 129;
4476pub const R_ARM_THM_TLS_DESCSEQ32: u32 = 130;
4477/// GOT entry relative to GOT origin, 12 bit (Thumb32 `LDR`).
4478pub const R_ARM_THM_GOT_BREL12: u32 = 131;
4479pub const R_ARM_IRELATIVE: u32 = 160;
4480pub const R_ARM_RXPC25: u32 = 249;
4481pub const R_ARM_RSBREL32: u32 = 250;
4482pub const R_ARM_THM_RPC22: u32 = 251;
4483pub const R_ARM_RREL32: u32 = 252;
4484pub const R_ARM_RABS22: u32 = 253;
4485pub const R_ARM_RPC24: u32 = 254;
4486pub const R_ARM_RBASE: u32 = 255;
4487
4488// C-SKY values for `Rel*::r_type`.
4489/// no reloc
4490pub const R_CKCORE_NONE: u32 = 0;
4491/// direct 32 bit (S + A)
4492pub const R_CKCORE_ADDR32: u32 = 1;
4493/// disp ((S + A - P) >> 2) & 0xff
4494pub const R_CKCORE_PCRELIMM8BY4: u32 = 2;
4495/// disp ((S + A - P) >> 1) & 0x7ff
4496pub const R_CKCORE_PCRELIMM11BY2: u32 = 3;
4497/// 32-bit rel (S + A - P)
4498pub const R_CKCORE_PCREL32: u32 = 5;
4499/// disp ((S + A - P) >>1) & 0x7ff
4500pub const R_CKCORE_PCRELJSR_IMM11BY2: u32 = 6;
4501/// 32 bit adjust program base(B + A)
4502pub const R_CKCORE_RELATIVE: u32 = 9;
4503/// 32 bit adjust by program base
4504pub const R_CKCORE_COPY: u32 = 10;
4505/// off between got and sym (S)
4506pub const R_CKCORE_GLOB_DAT: u32 = 11;
4507/// PLT entry (S)
4508pub const R_CKCORE_JUMP_SLOT: u32 = 12;
4509/// offset to GOT (S + A - GOT)
4510pub const R_CKCORE_GOTOFF: u32 = 13;
4511/// PC offset to GOT (GOT + A - P)
4512pub const R_CKCORE_GOTPC: u32 = 14;
4513/// 32 bit GOT entry (G)
4514pub const R_CKCORE_GOT32: u32 = 15;
4515/// 32 bit PLT entry (G)
4516pub const R_CKCORE_PLT32: u32 = 16;
4517/// GOT entry in GLOB_DAT (GOT + G)
4518pub const R_CKCORE_ADDRGOT: u32 = 17;
4519/// PLT entry in GLOB_DAT (GOT + G)
4520pub const R_CKCORE_ADDRPLT: u32 = 18;
4521/// ((S + A - P) >> 1) & 0x3ff_ffff
4522pub const R_CKCORE_PCREL_IMM26BY2: u32 = 19;
4523/// disp ((S + A - P) >> 1) & 0xffff
4524pub const R_CKCORE_PCREL_IMM16BY2: u32 = 20;
4525/// disp ((S + A - P) >> 2) & 0xffff
4526pub const R_CKCORE_PCREL_IMM16BY4: u32 = 21;
4527/// disp ((S + A - P) >> 1) & 0x3ff
4528pub const R_CKCORE_PCREL_IMM10BY2: u32 = 22;
4529/// disp ((S + A - P) >> 2) & 0x3ff
4530pub const R_CKCORE_PCREL_IMM10BY4: u32 = 23;
4531/// high & low 16 bit ADDR, ((S + A) >> 16) & 0xffff
4532pub const R_CKCORE_ADDR_HI16: u32 = 24;
4533/// (S + A) & 0xffff
4534pub const R_CKCORE_ADDR_LO16: u32 = 25;
4535/// high & low 16 bit GOTPC, ((GOT + A - P) >> 16) & 0xffff
4536pub const R_CKCORE_GOTPC_HI16: u32 = 26;
4537/// (GOT + A - P) & 0xffff
4538pub const R_CKCORE_GOTPC_LO16: u32 = 27;
4539/// high & low 16 bit GOTOFF, ((S + A - GOT) >> 16) & 0xffff
4540pub const R_CKCORE_GOTOFF_HI16: u32 = 28;
4541/// (S + A - GOT) & 0xffff
4542pub const R_CKCORE_GOTOFF_LO16: u32 = 29;
4543/// 12 bit disp GOT entry (G)
4544pub const R_CKCORE_GOT12: u32 = 30;
4545/// high & low 16 bit GOT, (G >> 16) & 0xffff
4546pub const R_CKCORE_GOT_HI16: u32 = 31;
4547/// (G & 0xffff)
4548pub const R_CKCORE_GOT_LO16: u32 = 32;
4549/// 12 bit disp PLT entry (G)
4550pub const R_CKCORE_PLT12: u32 = 33;
4551/// high & low 16 bit PLT, (G >> 16) & 0xffff
4552pub const R_CKCORE_PLT_HI16: u32 = 34;
4553/// G & 0xffff
4554pub const R_CKCORE_PLT_LO16: u32 = 35;
4555/// high & low 16 bit ADDRGOT, (GOT + G * 4) & 0xffff
4556pub const R_CKCORE_ADDRGOT_HI16: u32 = 36;
4557/// (GOT + G * 4) & 0xffff
4558pub const R_CKCORE_ADDRGOT_LO16: u32 = 37;
4559/// high & low 16 bit ADDRPLT, ((GOT + G * 4) >> 16) & 0xFFFF
4560pub const R_CKCORE_ADDRPLT_HI16: u32 = 38;
4561/// (GOT+G*4) & 0xffff
4562pub const R_CKCORE_ADDRPLT_LO16: u32 = 39;
4563/// disp ((S+A-P) >>1) & x3ff_ffff
4564pub const R_CKCORE_PCREL_JSR_IMM26BY2: u32 = 40;
4565/// (S+A-BTEXT) & 0xffff
4566pub const R_CKCORE_TOFFSET_LO16: u32 = 41;
4567/// (S+A-BTEXT) & 0xffff
4568pub const R_CKCORE_DOFFSET_LO16: u32 = 42;
4569/// disp ((S+A-P) >>1) & 0x3ffff
4570pub const R_CKCORE_PCREL_IMM18BY2: u32 = 43;
4571/// disp (S+A-BDATA) & 0x3ffff
4572pub const R_CKCORE_DOFFSET_IMM18: u32 = 44;
4573/// disp ((S+A-BDATA)>>1) & 0x3ffff
4574pub const R_CKCORE_DOFFSET_IMM18BY2: u32 = 45;
4575/// disp ((S+A-BDATA)>>2) & 0x3ffff
4576pub const R_CKCORE_DOFFSET_IMM18BY4: u32 = 46;
4577/// disp (G >> 2)
4578pub const R_CKCORE_GOT_IMM18BY4: u32 = 48;
4579/// disp (G >> 2)
4580pub const R_CKCORE_PLT_IMM18BY4: u32 = 49;
4581/// disp ((S+A-P) >>2) & 0x7f
4582pub const R_CKCORE_PCREL_IMM7BY4: u32 = 50;
4583/// 32 bit offset to TLS block
4584pub const R_CKCORE_TLS_LE32: u32 = 51;
4585pub const R_CKCORE_TLS_IE32: u32 = 52;
4586pub const R_CKCORE_TLS_GD32: u32 = 53;
4587pub const R_CKCORE_TLS_LDM32: u32 = 54;
4588pub const R_CKCORE_TLS_LDO32: u32 = 55;
4589pub const R_CKCORE_TLS_DTPMOD32: u32 = 56;
4590pub const R_CKCORE_TLS_DTPOFF32: u32 = 57;
4591pub const R_CKCORE_TLS_TPOFF32: u32 = 58;
4592
4593// C-SKY values for `FileHeader*::e_flags`.
4594pub const EF_CSKY_ABIMASK: u32 = 0xF000_0000;
4595pub const EF_CSKY_OTHER: u32 = 0x0FFF_0000;
4596pub const EF_CSKY_PROCESSOR: u32 = 0x0000_FFFF;
4597
4598pub const EF_CSKY_ABIV1: u32 = 0x1000_0000;
4599pub const EF_CSKY_ABIV2: u32 = 0x2000_0000;
4600
4601// C-SKY values for `SectionHeader*::sh_type`.
4602/// C-SKY attributes section.
4603pub const SHT_CSKY_ATTRIBUTES: u32 = SHT_LOPROC + 1;
4604
4605// IA-64 specific declarations.
4606
4607// IA-64 values for `FileHeader64::e_flags`.
4608/// os-specific flags
4609pub const EF_IA_64_MASKOS: u32 = 0x0000_000f;
4610/// 64-bit ABI
4611pub const EF_IA_64_ABI64: u32 = 0x0000_0010;
4612/// arch. version mask
4613pub const EF_IA_64_ARCH: u32 = 0xff00_0000;
4614
4615// IA-64 values for `ProgramHeader64::p_type`.
4616/// arch extension bits
4617pub const PT_IA_64_ARCHEXT: u32 = PT_LOPROC + 0;
4618/// ia64 unwind bits
4619pub const PT_IA_64_UNWIND: u32 = PT_LOPROC + 1;
4620pub const PT_IA_64_HP_OPT_ANOT: u32 = PT_LOOS + 0x12;
4621pub const PT_IA_64_HP_HSL_ANOT: u32 = PT_LOOS + 0x13;
4622pub const PT_IA_64_HP_STACK: u32 = PT_LOOS + 0x14;
4623
4624// IA-64 values for `ProgramHeader64::p_flags`.
4625/// spec insns w/o recovery
4626pub const PF_IA_64_NORECOV: u32 = 0x8000_0000;
4627
4628// IA-64 values for `SectionHeader64::sh_type`.
4629/// extension bits
4630pub const SHT_IA_64_EXT: u32 = SHT_LOPROC + 0;
4631/// unwind bits
4632pub const SHT_IA_64_UNWIND: u32 = SHT_LOPROC + 1;
4633
4634// IA-64 values for `SectionHeader64::sh_flags`.
4635/// section near gp
4636pub const SHF_IA_64_SHORT: u32 = 0x1000_0000;
4637/// spec insns w/o recovery
4638pub const SHF_IA_64_NORECOV: u32 = 0x2000_0000;
4639
4640// IA-64 values for `Dyn64::d_tag`.
4641pub const DT_IA_64_PLT_RESERVE: i64 = DT_LOPROC + 0;
4642
4643// IA-64 values for `Rel*::r_type`.
4644/// none
4645pub const R_IA64_NONE: u32 = 0x00;
4646/// symbol + addend, add imm14
4647pub const R_IA64_IMM14: u32 = 0x21;
4648/// symbol + addend, add imm22
4649pub const R_IA64_IMM22: u32 = 0x22;
4650/// symbol + addend, mov imm64
4651pub const R_IA64_IMM64: u32 = 0x23;
4652/// symbol + addend, data4 MSB
4653pub const R_IA64_DIR32MSB: u32 = 0x24;
4654/// symbol + addend, data4 LSB
4655pub const R_IA64_DIR32LSB: u32 = 0x25;
4656/// symbol + addend, data8 MSB
4657pub const R_IA64_DIR64MSB: u32 = 0x26;
4658/// symbol + addend, data8 LSB
4659pub const R_IA64_DIR64LSB: u32 = 0x27;
4660/// @gprel(sym + add), add imm22
4661pub const R_IA64_GPREL22: u32 = 0x2a;
4662/// @gprel(sym + add), mov imm64
4663pub const R_IA64_GPREL64I: u32 = 0x2b;
4664/// @gprel(sym + add), data4 MSB
4665pub const R_IA64_GPREL32MSB: u32 = 0x2c;
4666/// @gprel(sym + add), data4 LSB
4667pub const R_IA64_GPREL32LSB: u32 = 0x2d;
4668/// @gprel(sym + add), data8 MSB
4669pub const R_IA64_GPREL64MSB: u32 = 0x2e;
4670/// @gprel(sym + add), data8 LSB
4671pub const R_IA64_GPREL64LSB: u32 = 0x2f;
4672/// @ltoff(sym + add), add imm22
4673pub const R_IA64_LTOFF22: u32 = 0x32;
4674/// @ltoff(sym + add), mov imm64
4675pub const R_IA64_LTOFF64I: u32 = 0x33;
4676/// @pltoff(sym + add), add imm22
4677pub const R_IA64_PLTOFF22: u32 = 0x3a;
4678/// @pltoff(sym + add), mov imm64
4679pub const R_IA64_PLTOFF64I: u32 = 0x3b;
4680/// @pltoff(sym + add), data8 MSB
4681pub const R_IA64_PLTOFF64MSB: u32 = 0x3e;
4682/// @pltoff(sym + add), data8 LSB
4683pub const R_IA64_PLTOFF64LSB: u32 = 0x3f;
4684/// @fptr(sym + add), mov imm64
4685pub const R_IA64_FPTR64I: u32 = 0x43;
4686/// @fptr(sym + add), data4 MSB
4687pub const R_IA64_FPTR32MSB: u32 = 0x44;
4688/// @fptr(sym + add), data4 LSB
4689pub const R_IA64_FPTR32LSB: u32 = 0x45;
4690/// @fptr(sym + add), data8 MSB
4691pub const R_IA64_FPTR64MSB: u32 = 0x46;
4692/// @fptr(sym + add), data8 LSB
4693pub const R_IA64_FPTR64LSB: u32 = 0x47;
4694/// @pcrel(sym + add), brl
4695pub const R_IA64_PCREL60B: u32 = 0x48;
4696/// @pcrel(sym + add), ptb, call
4697pub const R_IA64_PCREL21B: u32 = 0x49;
4698/// @pcrel(sym + add), chk.s
4699pub const R_IA64_PCREL21M: u32 = 0x4a;
4700/// @pcrel(sym + add), fchkf
4701pub const R_IA64_PCREL21F: u32 = 0x4b;
4702/// @pcrel(sym + add), data4 MSB
4703pub const R_IA64_PCREL32MSB: u32 = 0x4c;
4704/// @pcrel(sym + add), data4 LSB
4705pub const R_IA64_PCREL32LSB: u32 = 0x4d;
4706/// @pcrel(sym + add), data8 MSB
4707pub const R_IA64_PCREL64MSB: u32 = 0x4e;
4708/// @pcrel(sym + add), data8 LSB
4709pub const R_IA64_PCREL64LSB: u32 = 0x4f;
4710/// @ltoff(@fptr(s+a)), imm22
4711pub const R_IA64_LTOFF_FPTR22: u32 = 0x52;
4712/// @ltoff(@fptr(s+a)), imm64
4713pub const R_IA64_LTOFF_FPTR64I: u32 = 0x53;
4714/// @ltoff(@fptr(s+a)), data4 MSB
4715pub const R_IA64_LTOFF_FPTR32MSB: u32 = 0x54;
4716/// @ltoff(@fptr(s+a)), data4 LSB
4717pub const R_IA64_LTOFF_FPTR32LSB: u32 = 0x55;
4718/// @ltoff(@fptr(s+a)), data8 MSB
4719pub const R_IA64_LTOFF_FPTR64MSB: u32 = 0x56;
4720/// @ltoff(@fptr(s+a)), data8 LSB
4721pub const R_IA64_LTOFF_FPTR64LSB: u32 = 0x57;
4722/// @segrel(sym + add), data4 MSB
4723pub const R_IA64_SEGREL32MSB: u32 = 0x5c;
4724/// @segrel(sym + add), data4 LSB
4725pub const R_IA64_SEGREL32LSB: u32 = 0x5d;
4726/// @segrel(sym + add), data8 MSB
4727pub const R_IA64_SEGREL64MSB: u32 = 0x5e;
4728/// @segrel(sym + add), data8 LSB
4729pub const R_IA64_SEGREL64LSB: u32 = 0x5f;
4730/// @secrel(sym + add), data4 MSB
4731pub const R_IA64_SECREL32MSB: u32 = 0x64;
4732/// @secrel(sym + add), data4 LSB
4733pub const R_IA64_SECREL32LSB: u32 = 0x65;
4734/// @secrel(sym + add), data8 MSB
4735pub const R_IA64_SECREL64MSB: u32 = 0x66;
4736/// @secrel(sym + add), data8 LSB
4737pub const R_IA64_SECREL64LSB: u32 = 0x67;
4738/// data 4 + REL
4739pub const R_IA64_REL32MSB: u32 = 0x6c;
4740/// data 4 + REL
4741pub const R_IA64_REL32LSB: u32 = 0x6d;
4742/// data 8 + REL
4743pub const R_IA64_REL64MSB: u32 = 0x6e;
4744/// data 8 + REL
4745pub const R_IA64_REL64LSB: u32 = 0x6f;
4746/// symbol + addend, data4 MSB
4747pub const R_IA64_LTV32MSB: u32 = 0x74;
4748/// symbol + addend, data4 LSB
4749pub const R_IA64_LTV32LSB: u32 = 0x75;
4750/// symbol + addend, data8 MSB
4751pub const R_IA64_LTV64MSB: u32 = 0x76;
4752/// symbol + addend, data8 LSB
4753pub const R_IA64_LTV64LSB: u32 = 0x77;
4754/// @pcrel(sym + add), 21bit inst
4755pub const R_IA64_PCREL21BI: u32 = 0x79;
4756/// @pcrel(sym + add), 22bit inst
4757pub const R_IA64_PCREL22: u32 = 0x7a;
4758/// @pcrel(sym + add), 64bit inst
4759pub const R_IA64_PCREL64I: u32 = 0x7b;
4760/// dynamic reloc, imported PLT, MSB
4761pub const R_IA64_IPLTMSB: u32 = 0x80;
4762/// dynamic reloc, imported PLT, LSB
4763pub const R_IA64_IPLTLSB: u32 = 0x81;
4764/// copy relocation
4765pub const R_IA64_COPY: u32 = 0x84;
4766/// Addend and symbol difference
4767pub const R_IA64_SUB: u32 = 0x85;
4768/// LTOFF22, relaxable.
4769pub const R_IA64_LTOFF22X: u32 = 0x86;
4770/// Use of LTOFF22X.
4771pub const R_IA64_LDXMOV: u32 = 0x87;
4772/// @tprel(sym + add), imm14
4773pub const R_IA64_TPREL14: u32 = 0x91;
4774/// @tprel(sym + add), imm22
4775pub const R_IA64_TPREL22: u32 = 0x92;
4776/// @tprel(sym + add), imm64
4777pub const R_IA64_TPREL64I: u32 = 0x93;
4778/// @tprel(sym + add), data8 MSB
4779pub const R_IA64_TPREL64MSB: u32 = 0x96;
4780/// @tprel(sym + add), data8 LSB
4781pub const R_IA64_TPREL64LSB: u32 = 0x97;
4782/// @ltoff(@tprel(s+a)), imm2
4783pub const R_IA64_LTOFF_TPREL22: u32 = 0x9a;
4784/// @dtpmod(sym + add), data8 MSB
4785pub const R_IA64_DTPMOD64MSB: u32 = 0xa6;
4786/// @dtpmod(sym + add), data8 LSB
4787pub const R_IA64_DTPMOD64LSB: u32 = 0xa7;
4788/// @ltoff(@dtpmod(sym + add)), imm22
4789pub const R_IA64_LTOFF_DTPMOD22: u32 = 0xaa;
4790/// @dtprel(sym + add), imm14
4791pub const R_IA64_DTPREL14: u32 = 0xb1;
4792/// @dtprel(sym + add), imm22
4793pub const R_IA64_DTPREL22: u32 = 0xb2;
4794/// @dtprel(sym + add), imm64
4795pub const R_IA64_DTPREL64I: u32 = 0xb3;
4796/// @dtprel(sym + add), data4 MSB
4797pub const R_IA64_DTPREL32MSB: u32 = 0xb4;
4798/// @dtprel(sym + add), data4 LSB
4799pub const R_IA64_DTPREL32LSB: u32 = 0xb5;
4800/// @dtprel(sym + add), data8 MSB
4801pub const R_IA64_DTPREL64MSB: u32 = 0xb6;
4802/// @dtprel(sym + add), data8 LSB
4803pub const R_IA64_DTPREL64LSB: u32 = 0xb7;
4804/// @ltoff(@dtprel(s+a)), imm22
4805pub const R_IA64_LTOFF_DTPREL22: u32 = 0xba;
4806
4807// SH specific declarations.
4808
4809// SH values `FileHeader*::e_flags`.
4810pub const EF_SH_MACH_MASK: u32 = 0x1f;
4811pub const EF_SH_UNKNOWN: u32 = 0x0;
4812pub const EF_SH1: u32 = 0x1;
4813pub const EF_SH2: u32 = 0x2;
4814pub const EF_SH3: u32 = 0x3;
4815pub const EF_SH_DSP: u32 = 0x4;
4816pub const EF_SH3_DSP: u32 = 0x5;
4817pub const EF_SH4AL_DSP: u32 = 0x6;
4818pub const EF_SH3E: u32 = 0x8;
4819pub const EF_SH4: u32 = 0x9;
4820pub const EF_SH2E: u32 = 0xb;
4821pub const EF_SH4A: u32 = 0xc;
4822pub const EF_SH2A: u32 = 0xd;
4823pub const EF_SH4_NOFPU: u32 = 0x10;
4824pub const EF_SH4A_NOFPU: u32 = 0x11;
4825pub const EF_SH4_NOMMU_NOFPU: u32 = 0x12;
4826pub const EF_SH2A_NOFPU: u32 = 0x13;
4827pub const EF_SH3_NOMMU: u32 = 0x14;
4828pub const EF_SH2A_SH4_NOFPU: u32 = 0x15;
4829pub const EF_SH2A_SH3_NOFPU: u32 = 0x16;
4830pub const EF_SH2A_SH4: u32 = 0x17;
4831pub const EF_SH2A_SH3E: u32 = 0x18;
4832
4833// SH values `Rel*::r_type`.
4834pub const R_SH_NONE: u32 = 0;
4835pub const R_SH_DIR32: u32 = 1;
4836pub const R_SH_REL32: u32 = 2;
4837pub const R_SH_DIR8WPN: u32 = 3;
4838pub const R_SH_IND12W: u32 = 4;
4839pub const R_SH_DIR8WPL: u32 = 5;
4840pub const R_SH_DIR8WPZ: u32 = 6;
4841pub const R_SH_DIR8BP: u32 = 7;
4842pub const R_SH_DIR8W: u32 = 8;
4843pub const R_SH_DIR8L: u32 = 9;
4844pub const R_SH_SWITCH16: u32 = 25;
4845pub const R_SH_SWITCH32: u32 = 26;
4846pub const R_SH_USES: u32 = 27;
4847pub const R_SH_COUNT: u32 = 28;
4848pub const R_SH_ALIGN: u32 = 29;
4849pub const R_SH_CODE: u32 = 30;
4850pub const R_SH_DATA: u32 = 31;
4851pub const R_SH_LABEL: u32 = 32;
4852pub const R_SH_SWITCH8: u32 = 33;
4853pub const R_SH_GNU_VTINHERIT: u32 = 34;
4854pub const R_SH_GNU_VTENTRY: u32 = 35;
4855pub const R_SH_TLS_GD_32: u32 = 144;
4856pub const R_SH_TLS_LD_32: u32 = 145;
4857pub const R_SH_TLS_LDO_32: u32 = 146;
4858pub const R_SH_TLS_IE_32: u32 = 147;
4859pub const R_SH_TLS_LE_32: u32 = 148;
4860pub const R_SH_TLS_DTPMOD32: u32 = 149;
4861pub const R_SH_TLS_DTPOFF32: u32 = 150;
4862pub const R_SH_TLS_TPOFF32: u32 = 151;
4863pub const R_SH_GOT32: u32 = 160;
4864pub const R_SH_PLT32: u32 = 161;
4865pub const R_SH_COPY: u32 = 162;
4866pub const R_SH_GLOB_DAT: u32 = 163;
4867pub const R_SH_JMP_SLOT: u32 = 164;
4868pub const R_SH_RELATIVE: u32 = 165;
4869pub const R_SH_GOTOFF: u32 = 166;
4870pub const R_SH_GOTPC: u32 = 167;
4871
4872// S/390 specific definitions.
4873
4874// S/390 values `FileHeader*::e_flags`.
4875
4876/// High GPRs kernel facility needed.
4877pub const EF_S390_HIGH_GPRS: u32 = 0x0000_0001;
4878
4879// S/390 values `Rel*::r_type`.
4880
4881/// No reloc.
4882pub const R_390_NONE: u32 = 0;
4883/// Direct 8 bit.
4884pub const R_390_8: u32 = 1;
4885/// Direct 12 bit.
4886pub const R_390_12: u32 = 2;
4887/// Direct 16 bit.
4888pub const R_390_16: u32 = 3;
4889/// Direct 32 bit.
4890pub const R_390_32: u32 = 4;
4891/// PC relative 32 bit.
4892pub const R_390_PC32: u32 = 5;
4893/// 12 bit GOT offset.
4894pub const R_390_GOT12: u32 = 6;
4895/// 32 bit GOT offset.
4896pub const R_390_GOT32: u32 = 7;
4897/// 32 bit PC relative PLT address.
4898pub const R_390_PLT32: u32 = 8;
4899/// Copy symbol at runtime.
4900pub const R_390_COPY: u32 = 9;
4901/// Create GOT entry.
4902pub const R_390_GLOB_DAT: u32 = 10;
4903/// Create PLT entry.
4904pub const R_390_JMP_SLOT: u32 = 11;
4905/// Adjust by program base.
4906pub const R_390_RELATIVE: u32 = 12;
4907/// 32 bit offset to GOT.
4908pub const R_390_GOTOFF32: u32 = 13;
4909/// 32 bit PC relative offset to GOT.
4910pub const R_390_GOTPC: u32 = 14;
4911/// 16 bit GOT offset.
4912pub const R_390_GOT16: u32 = 15;
4913/// PC relative 16 bit.
4914pub const R_390_PC16: u32 = 16;
4915/// PC relative 16 bit shifted by 1.
4916pub const R_390_PC16DBL: u32 = 17;
4917/// 16 bit PC rel. PLT shifted by 1.
4918pub const R_390_PLT16DBL: u32 = 18;
4919/// PC relative 32 bit shifted by 1.
4920pub const R_390_PC32DBL: u32 = 19;
4921/// 32 bit PC rel. PLT shifted by 1.
4922pub const R_390_PLT32DBL: u32 = 20;
4923/// 32 bit PC rel. GOT shifted by 1.
4924pub const R_390_GOTPCDBL: u32 = 21;
4925/// Direct 64 bit.
4926pub const R_390_64: u32 = 22;
4927/// PC relative 64 bit.
4928pub const R_390_PC64: u32 = 23;
4929/// 64 bit GOT offset.
4930pub const R_390_GOT64: u32 = 24;
4931/// 64 bit PC relative PLT address.
4932pub const R_390_PLT64: u32 = 25;
4933/// 32 bit PC rel. to GOT entry >> 1.
4934pub const R_390_GOTENT: u32 = 26;
4935/// 16 bit offset to GOT.
4936pub const R_390_GOTOFF16: u32 = 27;
4937/// 64 bit offset to GOT.
4938pub const R_390_GOTOFF64: u32 = 28;
4939/// 12 bit offset to jump slot.
4940pub const R_390_GOTPLT12: u32 = 29;
4941/// 16 bit offset to jump slot.
4942pub const R_390_GOTPLT16: u32 = 30;
4943/// 32 bit offset to jump slot.
4944pub const R_390_GOTPLT32: u32 = 31;
4945/// 64 bit offset to jump slot.
4946pub const R_390_GOTPLT64: u32 = 32;
4947/// 32 bit rel. offset to jump slot.
4948pub const R_390_GOTPLTENT: u32 = 33;
4949/// 16 bit offset from GOT to PLT.
4950pub const R_390_PLTOFF16: u32 = 34;
4951/// 32 bit offset from GOT to PLT.
4952pub const R_390_PLTOFF32: u32 = 35;
4953/// 16 bit offset from GOT to PLT.
4954pub const R_390_PLTOFF64: u32 = 36;
4955/// Tag for load insn in TLS code.
4956pub const R_390_TLS_LOAD: u32 = 37;
4957/// Tag for function call in general dynamic TLS code.
4958pub const R_390_TLS_GDCALL: u32 = 38;
4959/// Tag for function call in local dynamic TLS code.
4960pub const R_390_TLS_LDCALL: u32 = 39;
4961/// Direct 32 bit for general dynamic thread local data.
4962pub const R_390_TLS_GD32: u32 = 40;
4963/// Direct 64 bit for general dynamic thread local data.
4964pub const R_390_TLS_GD64: u32 = 41;
4965/// 12 bit GOT offset for static TLS block offset.
4966pub const R_390_TLS_GOTIE12: u32 = 42;
4967/// 32 bit GOT offset for static TLS block offset.
4968pub const R_390_TLS_GOTIE32: u32 = 43;
4969/// 64 bit GOT offset for static TLS block offset.
4970pub const R_390_TLS_GOTIE64: u32 = 44;
4971/// Direct 32 bit for local dynamic thread local data in LE code.
4972pub const R_390_TLS_LDM32: u32 = 45;
4973/// Direct 64 bit for local dynamic thread local data in LE code.
4974pub const R_390_TLS_LDM64: u32 = 46;
4975/// 32 bit address of GOT entry for negated static TLS block offset.
4976pub const R_390_TLS_IE32: u32 = 47;
4977/// 64 bit address of GOT entry for negated static TLS block offset.
4978pub const R_390_TLS_IE64: u32 = 48;
4979/// 32 bit rel. offset to GOT entry for negated static TLS block offset.
4980pub const R_390_TLS_IEENT: u32 = 49;
4981/// 32 bit negated offset relative to static TLS block.
4982pub const R_390_TLS_LE32: u32 = 50;
4983/// 64 bit negated offset relative to static TLS block.
4984pub const R_390_TLS_LE64: u32 = 51;
4985/// 32 bit offset relative to TLS block.
4986pub const R_390_TLS_LDO32: u32 = 52;
4987/// 64 bit offset relative to TLS block.
4988pub const R_390_TLS_LDO64: u32 = 53;
4989/// ID of module containing symbol.
4990pub const R_390_TLS_DTPMOD: u32 = 54;
4991/// Offset in TLS block.
4992pub const R_390_TLS_DTPOFF: u32 = 55;
4993/// Negated offset in static TLS block.
4994pub const R_390_TLS_TPOFF: u32 = 56;
4995/// Direct 20 bit.
4996pub const R_390_20: u32 = 57;
4997/// 20 bit GOT offset.
4998pub const R_390_GOT20: u32 = 58;
4999/// 20 bit offset to jump slot.
5000pub const R_390_GOTPLT20: u32 = 59;
5001/// 20 bit GOT offset for static TLS block offset.
5002pub const R_390_TLS_GOTIE20: u32 = 60;
5003/// STT_GNU_IFUNC relocation.
5004pub const R_390_IRELATIVE: u32 = 61;
5005
5006// CRIS values `Rel*::r_type`.
5007pub const R_CRIS_NONE: u32 = 0;
5008pub const R_CRIS_8: u32 = 1;
5009pub const R_CRIS_16: u32 = 2;
5010pub const R_CRIS_32: u32 = 3;
5011pub const R_CRIS_8_PCREL: u32 = 4;
5012pub const R_CRIS_16_PCREL: u32 = 5;
5013pub const R_CRIS_32_PCREL: u32 = 6;
5014pub const R_CRIS_GNU_VTINHERIT: u32 = 7;
5015pub const R_CRIS_GNU_VTENTRY: u32 = 8;
5016pub const R_CRIS_COPY: u32 = 9;
5017pub const R_CRIS_GLOB_DAT: u32 = 10;
5018pub const R_CRIS_JUMP_SLOT: u32 = 11;
5019pub const R_CRIS_RELATIVE: u32 = 12;
5020pub const R_CRIS_16_GOT: u32 = 13;
5021pub const R_CRIS_32_GOT: u32 = 14;
5022pub const R_CRIS_16_GOTPLT: u32 = 15;
5023pub const R_CRIS_32_GOTPLT: u32 = 16;
5024pub const R_CRIS_32_GOTREL: u32 = 17;
5025pub const R_CRIS_32_PLT_GOTREL: u32 = 18;
5026pub const R_CRIS_32_PLT_PCREL: u32 = 19;
5027
5028// AMD x86-64 values `Rel*::r_type`.
5029/// No reloc
5030pub const R_X86_64_NONE: u32 = 0;
5031/// Direct 64 bit
5032pub const R_X86_64_64: u32 = 1;
5033/// PC relative 32 bit signed
5034pub const R_X86_64_PC32: u32 = 2;
5035/// 32 bit GOT entry
5036pub const R_X86_64_GOT32: u32 = 3;
5037/// 32 bit PLT address
5038pub const R_X86_64_PLT32: u32 = 4;
5039/// Copy symbol at runtime
5040pub const R_X86_64_COPY: u32 = 5;
5041/// Create GOT entry
5042pub const R_X86_64_GLOB_DAT: u32 = 6;
5043/// Create PLT entry
5044pub const R_X86_64_JUMP_SLOT: u32 = 7;
5045/// Adjust by program base
5046pub const R_X86_64_RELATIVE: u32 = 8;
5047/// 32 bit signed PC relative offset to GOT
5048pub const R_X86_64_GOTPCREL: u32 = 9;
5049/// Direct 32 bit zero extended
5050pub const R_X86_64_32: u32 = 10;
5051/// Direct 32 bit sign extended
5052pub const R_X86_64_32S: u32 = 11;
5053/// Direct 16 bit zero extended
5054pub const R_X86_64_16: u32 = 12;
5055/// 16 bit sign extended pc relative
5056pub const R_X86_64_PC16: u32 = 13;
5057/// Direct 8 bit sign extended
5058pub const R_X86_64_8: u32 = 14;
5059/// 8 bit sign extended pc relative
5060pub const R_X86_64_PC8: u32 = 15;
5061/// ID of module containing symbol
5062pub const R_X86_64_DTPMOD64: u32 = 16;
5063/// Offset in module's TLS block
5064pub const R_X86_64_DTPOFF64: u32 = 17;
5065/// Offset in initial TLS block
5066pub const R_X86_64_TPOFF64: u32 = 18;
5067/// 32 bit signed PC relative offset to two GOT entries for GD symbol
5068pub const R_X86_64_TLSGD: u32 = 19;
5069/// 32 bit signed PC relative offset to two GOT entries for LD symbol
5070pub const R_X86_64_TLSLD: u32 = 20;
5071/// Offset in TLS block
5072pub const R_X86_64_DTPOFF32: u32 = 21;
5073/// 32 bit signed PC relative offset to GOT entry for IE symbol
5074pub const R_X86_64_GOTTPOFF: u32 = 22;
5075/// Offset in initial TLS block
5076pub const R_X86_64_TPOFF32: u32 = 23;
5077/// PC relative 64 bit
5078pub const R_X86_64_PC64: u32 = 24;
5079/// 64 bit offset to GOT
5080pub const R_X86_64_GOTOFF64: u32 = 25;
5081/// 32 bit signed pc relative offset to GOT
5082pub const R_X86_64_GOTPC32: u32 = 26;
5083/// 64-bit GOT entry offset
5084pub const R_X86_64_GOT64: u32 = 27;
5085/// 64-bit PC relative offset to GOT entry
5086pub const R_X86_64_GOTPCREL64: u32 = 28;
5087/// 64-bit PC relative offset to GOT
5088pub const R_X86_64_GOTPC64: u32 = 29;
5089/// like GOT64, says PLT entry needed
5090pub const R_X86_64_GOTPLT64: u32 = 30;
5091/// 64-bit GOT relative offset to PLT entry
5092pub const R_X86_64_PLTOFF64: u32 = 31;
5093/// Size of symbol plus 32-bit addend
5094pub const R_X86_64_SIZE32: u32 = 32;
5095/// Size of symbol plus 64-bit addend
5096pub const R_X86_64_SIZE64: u32 = 33;
5097/// GOT offset for TLS descriptor.
5098pub const R_X86_64_GOTPC32_TLSDESC: u32 = 34;
5099/// Marker for call through TLS descriptor.
5100pub const R_X86_64_TLSDESC_CALL: u32 = 35;
5101/// TLS descriptor.
5102pub const R_X86_64_TLSDESC: u32 = 36;
5103/// Adjust indirectly by program base
5104pub const R_X86_64_IRELATIVE: u32 = 37;
5105/// 64-bit adjust by program base
5106pub const R_X86_64_RELATIVE64: u32 = 38;
5107// 39 Reserved was R_X86_64_PC32_BND
5108// 40 Reserved was R_X86_64_PLT32_BND
5109/// Load from 32 bit signed pc relative offset to GOT entry without REX prefix, relaxable.
5110pub const R_X86_64_GOTPCRELX: u32 = 41;
5111/// Load from 32 bit signed pc relative offset to GOT entry with REX prefix, relaxable.
5112pub const R_X86_64_REX_GOTPCRELX: u32 = 42;
5113/// 32 bit signed PC relative offset to GOT if the instruction starts at 4 bytes before the relocation offset, relaxable.
5114pub const R_X86_64_CODE_4_GOTPCRELX: u32 = 43;
5115/// 32 bit signed PC relative offset to GOT entry for IE symbol if the instruction starts at 4 bytes before the relocation offset.
5116pub const R_X86_64_CODE_4_GOTTPOFF: u32 = 44;
5117/// 32-bit PC relative to TLS descriptor in GOT if the instruction starts at 4 bytes before the relocation offset.
5118pub const R_X86_64_CODE_4_GOTPC32_TLSDESC: u32 = 45;
5119/// 32 bit signed PC relative offset to GOT if the instruction starts at 5 bytes before the relocation offset, relaxable.
5120pub const R_X86_64_CODE_5_GOTPCRELX: u32 = 46;
5121/// 32 bit signed PC relative offset to GOT entry for IE symbol if the instruction starts at 5 bytes before the relocation offset.
5122pub const R_X86_64_CODE_5_GOTTPOFF: u32 = 47;
5123/// 32-bit PC relative to TLS descriptor in GOT if the instruction starts at 5 bytes before the relocation offset.
5124pub const R_X86_64_CODE_5_GOTPC32_TLSDESC: u32 = 48;
5125/// 32 bit signed PC relative offset to GOT if the instruction starts at 6 bytes before the relocation offset, relaxable.
5126pub const R_X86_64_CODE_6_GOTPCRELX: u32 = 49;
5127/// 32 bit signed PC relative offset to GOT entry for IE symbol if the instruction starts at 6 bytes before the relocation offset.
5128pub const R_X86_64_CODE_6_GOTTPOFF: u32 = 50;
5129/// 32-bit PC relative to TLS descriptor in GOT if the instruction starts at 6 bytes before the relocation offset.
5130pub const R_X86_64_CODE_6_GOTPC32_TLSDESC: u32 = 51;
5131
5132// AMD x86-64 values `SectionHeader*::sh_type`.
5133/// Unwind information.
5134pub const SHT_X86_64_UNWIND: u32 = 0x7000_0001;
5135
5136// AM33 values `Rel*::r_type`.
5137/// No reloc.
5138pub const R_MN10300_NONE: u32 = 0;
5139/// Direct 32 bit.
5140pub const R_MN10300_32: u32 = 1;
5141/// Direct 16 bit.
5142pub const R_MN10300_16: u32 = 2;
5143/// Direct 8 bit.
5144pub const R_MN10300_8: u32 = 3;
5145/// PC-relative 32-bit.
5146pub const R_MN10300_PCREL32: u32 = 4;
5147/// PC-relative 16-bit signed.
5148pub const R_MN10300_PCREL16: u32 = 5;
5149/// PC-relative 8-bit signed.
5150pub const R_MN10300_PCREL8: u32 = 6;
5151/// Ancient C++ vtable garbage...
5152pub const R_MN10300_GNU_VTINHERIT: u32 = 7;
5153/// ... collection annotation.
5154pub const R_MN10300_GNU_VTENTRY: u32 = 8;
5155/// Direct 24 bit.
5156pub const R_MN10300_24: u32 = 9;
5157/// 32-bit PCrel offset to GOT.
5158pub const R_MN10300_GOTPC32: u32 = 10;
5159/// 16-bit PCrel offset to GOT.
5160pub const R_MN10300_GOTPC16: u32 = 11;
5161/// 32-bit offset from GOT.
5162pub const R_MN10300_GOTOFF32: u32 = 12;
5163/// 24-bit offset from GOT.
5164pub const R_MN10300_GOTOFF24: u32 = 13;
5165/// 16-bit offset from GOT.
5166pub const R_MN10300_GOTOFF16: u32 = 14;
5167/// 32-bit PCrel to PLT entry.
5168pub const R_MN10300_PLT32: u32 = 15;
5169/// 16-bit PCrel to PLT entry.
5170pub const R_MN10300_PLT16: u32 = 16;
5171/// 32-bit offset to GOT entry.
5172pub const R_MN10300_GOT32: u32 = 17;
5173/// 24-bit offset to GOT entry.
5174pub const R_MN10300_GOT24: u32 = 18;
5175/// 16-bit offset to GOT entry.
5176pub const R_MN10300_GOT16: u32 = 19;
5177/// Copy symbol at runtime.
5178pub const R_MN10300_COPY: u32 = 20;
5179/// Create GOT entry.
5180pub const R_MN10300_GLOB_DAT: u32 = 21;
5181/// Create PLT entry.
5182pub const R_MN10300_JMP_SLOT: u32 = 22;
5183/// Adjust by program base.
5184pub const R_MN10300_RELATIVE: u32 = 23;
5185/// 32-bit offset for global dynamic.
5186pub const R_MN10300_TLS_GD: u32 = 24;
5187/// 32-bit offset for local dynamic.
5188pub const R_MN10300_TLS_LD: u32 = 25;
5189/// Module-relative offset.
5190pub const R_MN10300_TLS_LDO: u32 = 26;
5191/// GOT offset for static TLS block offset.
5192pub const R_MN10300_TLS_GOTIE: u32 = 27;
5193/// GOT address for static TLS block offset.
5194pub const R_MN10300_TLS_IE: u32 = 28;
5195/// Offset relative to static TLS block.
5196pub const R_MN10300_TLS_LE: u32 = 29;
5197/// ID of module containing symbol.
5198pub const R_MN10300_TLS_DTPMOD: u32 = 30;
5199/// Offset in module TLS block.
5200pub const R_MN10300_TLS_DTPOFF: u32 = 31;
5201/// Offset in static TLS block.
5202pub const R_MN10300_TLS_TPOFF: u32 = 32;
5203/// Adjustment for next reloc as needed by linker relaxation.
5204pub const R_MN10300_SYM_DIFF: u32 = 33;
5205/// Alignment requirement for linker relaxation.
5206pub const R_MN10300_ALIGN: u32 = 34;
5207
5208// M32R values `Rel32::r_type`.
5209/// No reloc.
5210pub const R_M32R_NONE: u32 = 0;
5211/// Direct 16 bit.
5212pub const R_M32R_16: u32 = 1;
5213/// Direct 32 bit.
5214pub const R_M32R_32: u32 = 2;
5215/// Direct 24 bit.
5216pub const R_M32R_24: u32 = 3;
5217/// PC relative 10 bit shifted.
5218pub const R_M32R_10_PCREL: u32 = 4;
5219/// PC relative 18 bit shifted.
5220pub const R_M32R_18_PCREL: u32 = 5;
5221/// PC relative 26 bit shifted.
5222pub const R_M32R_26_PCREL: u32 = 6;
5223/// High 16 bit with unsigned low.
5224pub const R_M32R_HI16_ULO: u32 = 7;
5225/// High 16 bit with signed low.
5226pub const R_M32R_HI16_SLO: u32 = 8;
5227/// Low 16 bit.
5228pub const R_M32R_LO16: u32 = 9;
5229/// 16 bit offset in SDA.
5230pub const R_M32R_SDA16: u32 = 10;
5231pub const R_M32R_GNU_VTINHERIT: u32 = 11;
5232pub const R_M32R_GNU_VTENTRY: u32 = 12;
5233// M32R values `Rela32::r_type`.
5234/// Direct 16 bit.
5235pub const R_M32R_16_RELA: u32 = 33;
5236/// Direct 32 bit.
5237pub const R_M32R_32_RELA: u32 = 34;
5238/// Direct 24 bit.
5239pub const R_M32R_24_RELA: u32 = 35;
5240/// PC relative 10 bit shifted.
5241pub const R_M32R_10_PCREL_RELA: u32 = 36;
5242/// PC relative 18 bit shifted.
5243pub const R_M32R_18_PCREL_RELA: u32 = 37;
5244/// PC relative 26 bit shifted.
5245pub const R_M32R_26_PCREL_RELA: u32 = 38;
5246/// High 16 bit with unsigned low
5247pub const R_M32R_HI16_ULO_RELA: u32 = 39;
5248/// High 16 bit with signed low
5249pub const R_M32R_HI16_SLO_RELA: u32 = 40;
5250/// Low 16 bit
5251pub const R_M32R_LO16_RELA: u32 = 41;
5252/// 16 bit offset in SDA
5253pub const R_M32R_SDA16_RELA: u32 = 42;
5254pub const R_M32R_RELA_GNU_VTINHERIT: u32 = 43;
5255pub const R_M32R_RELA_GNU_VTENTRY: u32 = 44;
5256/// PC relative 32 bit.
5257pub const R_M32R_REL32: u32 = 45;
5258
5259/// 24 bit GOT entry
5260pub const R_M32R_GOT24: u32 = 48;
5261/// 26 bit PC relative to PLT shifted
5262pub const R_M32R_26_PLTREL: u32 = 49;
5263/// Copy symbol at runtime
5264pub const R_M32R_COPY: u32 = 50;
5265/// Create GOT entry
5266pub const R_M32R_GLOB_DAT: u32 = 51;
5267/// Create PLT entry
5268pub const R_M32R_JMP_SLOT: u32 = 52;
5269/// Adjust by program base
5270pub const R_M32R_RELATIVE: u32 = 53;
5271/// 24 bit offset to GOT
5272pub const R_M32R_GOTOFF: u32 = 54;
5273/// 24 bit PC relative offset to GOT
5274pub const R_M32R_GOTPC24: u32 = 55;
5275/// High 16 bit GOT entry with unsigned low
5276pub const R_M32R_GOT16_HI_ULO: u32 = 56;
5277/// High 16 bit GOT entry with signed low
5278pub const R_M32R_GOT16_HI_SLO: u32 = 57;
5279/// Low 16 bit GOT entry
5280pub const R_M32R_GOT16_LO: u32 = 58;
5281/// High 16 bit PC relative offset to GOT with unsigned low
5282pub const R_M32R_GOTPC_HI_ULO: u32 = 59;
5283/// High 16 bit PC relative offset to GOT with signed low
5284pub const R_M32R_GOTPC_HI_SLO: u32 = 60;
5285/// Low 16 bit PC relative offset to GOT
5286pub const R_M32R_GOTPC_LO: u32 = 61;
5287/// High 16 bit offset to GOT with unsigned low
5288pub const R_M32R_GOTOFF_HI_ULO: u32 = 62;
5289/// High 16 bit offset to GOT with signed low
5290pub const R_M32R_GOTOFF_HI_SLO: u32 = 63;
5291/// Low 16 bit offset to GOT
5292pub const R_M32R_GOTOFF_LO: u32 = 64;
5293/// Keep this the last entry.
5294pub const R_M32R_NUM: u32 = 256;
5295
5296// MicroBlaze values `Rel*::r_type`.
5297/// No reloc.
5298pub const R_MICROBLAZE_NONE: u32 = 0;
5299/// Direct 32 bit.
5300pub const R_MICROBLAZE_32: u32 = 1;
5301/// PC relative 32 bit.
5302pub const R_MICROBLAZE_32_PCREL: u32 = 2;
5303/// PC relative 64 bit.
5304pub const R_MICROBLAZE_64_PCREL: u32 = 3;
5305/// Low 16 bits of PCREL32.
5306pub const R_MICROBLAZE_32_PCREL_LO: u32 = 4;
5307/// Direct 64 bit.
5308pub const R_MICROBLAZE_64: u32 = 5;
5309/// Low 16 bit.
5310pub const R_MICROBLAZE_32_LO: u32 = 6;
5311/// Read-only small data area.
5312pub const R_MICROBLAZE_SRO32: u32 = 7;
5313/// Read-write small data area.
5314pub const R_MICROBLAZE_SRW32: u32 = 8;
5315/// No reloc.
5316pub const R_MICROBLAZE_64_NONE: u32 = 9;
5317/// Symbol Op Symbol relocation.
5318pub const R_MICROBLAZE_32_SYM_OP_SYM: u32 = 10;
5319/// GNU C++ vtable hierarchy.
5320pub const R_MICROBLAZE_GNU_VTINHERIT: u32 = 11;
5321/// GNU C++ vtable member usage.
5322pub const R_MICROBLAZE_GNU_VTENTRY: u32 = 12;
5323/// PC-relative GOT offset.
5324pub const R_MICROBLAZE_GOTPC_64: u32 = 13;
5325/// GOT entry offset.
5326pub const R_MICROBLAZE_GOT_64: u32 = 14;
5327/// PLT offset (PC-relative).
5328pub const R_MICROBLAZE_PLT_64: u32 = 15;
5329/// Adjust by program base.
5330pub const R_MICROBLAZE_REL: u32 = 16;
5331/// Create PLT entry.
5332pub const R_MICROBLAZE_JUMP_SLOT: u32 = 17;
5333/// Create GOT entry.
5334pub const R_MICROBLAZE_GLOB_DAT: u32 = 18;
5335/// 64 bit offset to GOT.
5336pub const R_MICROBLAZE_GOTOFF_64: u32 = 19;
5337/// 32 bit offset to GOT.
5338pub const R_MICROBLAZE_GOTOFF_32: u32 = 20;
5339/// Runtime copy.
5340pub const R_MICROBLAZE_COPY: u32 = 21;
5341/// TLS Reloc.
5342pub const R_MICROBLAZE_TLS: u32 = 22;
5343/// TLS General Dynamic.
5344pub const R_MICROBLAZE_TLSGD: u32 = 23;
5345/// TLS Local Dynamic.
5346pub const R_MICROBLAZE_TLSLD: u32 = 24;
5347/// TLS Module ID.
5348pub const R_MICROBLAZE_TLSDTPMOD32: u32 = 25;
5349/// TLS Offset Within TLS Block.
5350pub const R_MICROBLAZE_TLSDTPREL32: u32 = 26;
5351/// TLS Offset Within TLS Block.
5352pub const R_MICROBLAZE_TLSDTPREL64: u32 = 27;
5353/// TLS Offset From Thread Pointer.
5354pub const R_MICROBLAZE_TLSGOTTPREL32: u32 = 28;
5355/// TLS Offset From Thread Pointer.
5356pub const R_MICROBLAZE_TLSTPREL32: u32 = 29;
5357
5358// Nios II values `Dyn::d_tag`.
5359/// Address of _gp.
5360pub const DT_NIOS2_GP: i64 = 0x7000_0002;
5361
5362// Nios II values `Rel*::r_type`.
5363/// No reloc.
5364pub const R_NIOS2_NONE: u32 = 0;
5365/// Direct signed 16 bit.
5366pub const R_NIOS2_S16: u32 = 1;
5367/// Direct unsigned 16 bit.
5368pub const R_NIOS2_U16: u32 = 2;
5369/// PC relative 16 bit.
5370pub const R_NIOS2_PCREL16: u32 = 3;
5371/// Direct call.
5372pub const R_NIOS2_CALL26: u32 = 4;
5373/// 5 bit constant expression.
5374pub const R_NIOS2_IMM5: u32 = 5;
5375/// 5 bit expression, shift 22.
5376pub const R_NIOS2_CACHE_OPX: u32 = 6;
5377/// 6 bit constant expression.
5378pub const R_NIOS2_IMM6: u32 = 7;
5379/// 8 bit constant expression.
5380pub const R_NIOS2_IMM8: u32 = 8;
5381/// High 16 bit.
5382pub const R_NIOS2_HI16: u32 = 9;
5383/// Low 16 bit.
5384pub const R_NIOS2_LO16: u32 = 10;
5385/// High 16 bit, adjusted.
5386pub const R_NIOS2_HIADJ16: u32 = 11;
5387/// 32 bit symbol value + addend.
5388pub const R_NIOS2_BFD_RELOC_32: u32 = 12;
5389/// 16 bit symbol value + addend.
5390pub const R_NIOS2_BFD_RELOC_16: u32 = 13;
5391/// 8 bit symbol value + addend.
5392pub const R_NIOS2_BFD_RELOC_8: u32 = 14;
5393/// 16 bit GP pointer offset.
5394pub const R_NIOS2_GPREL: u32 = 15;
5395/// GNU C++ vtable hierarchy.
5396pub const R_NIOS2_GNU_VTINHERIT: u32 = 16;
5397/// GNU C++ vtable member usage.
5398pub const R_NIOS2_GNU_VTENTRY: u32 = 17;
5399/// Unconditional branch.
5400pub const R_NIOS2_UJMP: u32 = 18;
5401/// Conditional branch.
5402pub const R_NIOS2_CJMP: u32 = 19;
5403/// Indirect call through register.
5404pub const R_NIOS2_CALLR: u32 = 20;
5405/// Alignment requirement for linker relaxation.
5406pub const R_NIOS2_ALIGN: u32 = 21;
5407/// 16 bit GOT entry.
5408pub const R_NIOS2_GOT16: u32 = 22;
5409/// 16 bit GOT entry for function.
5410pub const R_NIOS2_CALL16: u32 = 23;
5411/// %lo of offset to GOT pointer.
5412pub const R_NIOS2_GOTOFF_LO: u32 = 24;
5413/// %hiadj of offset to GOT pointer.
5414pub const R_NIOS2_GOTOFF_HA: u32 = 25;
5415/// %lo of PC relative offset.
5416pub const R_NIOS2_PCREL_LO: u32 = 26;
5417/// %hiadj of PC relative offset.
5418pub const R_NIOS2_PCREL_HA: u32 = 27;
5419/// 16 bit GOT offset for TLS GD.
5420pub const R_NIOS2_TLS_GD16: u32 = 28;
5421/// 16 bit GOT offset for TLS LDM.
5422pub const R_NIOS2_TLS_LDM16: u32 = 29;
5423/// 16 bit module relative offset.
5424pub const R_NIOS2_TLS_LDO16: u32 = 30;
5425/// 16 bit GOT offset for TLS IE.
5426pub const R_NIOS2_TLS_IE16: u32 = 31;
5427/// 16 bit LE TP-relative offset.
5428pub const R_NIOS2_TLS_LE16: u32 = 32;
5429/// Module number.
5430pub const R_NIOS2_TLS_DTPMOD: u32 = 33;
5431/// Module-relative offset.
5432pub const R_NIOS2_TLS_DTPREL: u32 = 34;
5433/// TP-relative offset.
5434pub const R_NIOS2_TLS_TPREL: u32 = 35;
5435/// Copy symbol at runtime.
5436pub const R_NIOS2_COPY: u32 = 36;
5437/// Create GOT entry.
5438pub const R_NIOS2_GLOB_DAT: u32 = 37;
5439/// Create PLT entry.
5440pub const R_NIOS2_JUMP_SLOT: u32 = 38;
5441/// Adjust by program base.
5442pub const R_NIOS2_RELATIVE: u32 = 39;
5443/// 16 bit offset to GOT pointer.
5444pub const R_NIOS2_GOTOFF: u32 = 40;
5445/// Direct call in .noat section.
5446pub const R_NIOS2_CALL26_NOAT: u32 = 41;
5447/// %lo() of GOT entry.
5448pub const R_NIOS2_GOT_LO: u32 = 42;
5449/// %hiadj() of GOT entry.
5450pub const R_NIOS2_GOT_HA: u32 = 43;
5451/// %lo() of function GOT entry.
5452pub const R_NIOS2_CALL_LO: u32 = 44;
5453/// %hiadj() of function GOT entry.
5454pub const R_NIOS2_CALL_HA: u32 = 45;
5455
5456// TILEPro values `Rel*::r_type`.
5457/// No reloc
5458pub const R_TILEPRO_NONE: u32 = 0;
5459/// Direct 32 bit
5460pub const R_TILEPRO_32: u32 = 1;
5461/// Direct 16 bit
5462pub const R_TILEPRO_16: u32 = 2;
5463/// Direct 8 bit
5464pub const R_TILEPRO_8: u32 = 3;
5465/// PC relative 32 bit
5466pub const R_TILEPRO_32_PCREL: u32 = 4;
5467/// PC relative 16 bit
5468pub const R_TILEPRO_16_PCREL: u32 = 5;
5469/// PC relative 8 bit
5470pub const R_TILEPRO_8_PCREL: u32 = 6;
5471/// Low 16 bit
5472pub const R_TILEPRO_LO16: u32 = 7;
5473/// High 16 bit
5474pub const R_TILEPRO_HI16: u32 = 8;
5475/// High 16 bit, adjusted
5476pub const R_TILEPRO_HA16: u32 = 9;
5477/// Copy relocation
5478pub const R_TILEPRO_COPY: u32 = 10;
5479/// Create GOT entry
5480pub const R_TILEPRO_GLOB_DAT: u32 = 11;
5481/// Create PLT entry
5482pub const R_TILEPRO_JMP_SLOT: u32 = 12;
5483/// Adjust by program base
5484pub const R_TILEPRO_RELATIVE: u32 = 13;
5485/// X1 pipe branch offset
5486pub const R_TILEPRO_BROFF_X1: u32 = 14;
5487/// X1 pipe jump offset
5488pub const R_TILEPRO_JOFFLONG_X1: u32 = 15;
5489/// X1 pipe jump offset to PLT
5490pub const R_TILEPRO_JOFFLONG_X1_PLT: u32 = 16;
5491/// X0 pipe 8-bit
5492pub const R_TILEPRO_IMM8_X0: u32 = 17;
5493/// Y0 pipe 8-bit
5494pub const R_TILEPRO_IMM8_Y0: u32 = 18;
5495/// X1 pipe 8-bit
5496pub const R_TILEPRO_IMM8_X1: u32 = 19;
5497/// Y1 pipe 8-bit
5498pub const R_TILEPRO_IMM8_Y1: u32 = 20;
5499/// X1 pipe mtspr
5500pub const R_TILEPRO_MT_IMM15_X1: u32 = 21;
5501/// X1 pipe mfspr
5502pub const R_TILEPRO_MF_IMM15_X1: u32 = 22;
5503/// X0 pipe 16-bit
5504pub const R_TILEPRO_IMM16_X0: u32 = 23;
5505/// X1 pipe 16-bit
5506pub const R_TILEPRO_IMM16_X1: u32 = 24;
5507/// X0 pipe low 16-bit
5508pub const R_TILEPRO_IMM16_X0_LO: u32 = 25;
5509/// X1 pipe low 16-bit
5510pub const R_TILEPRO_IMM16_X1_LO: u32 = 26;
5511/// X0 pipe high 16-bit
5512pub const R_TILEPRO_IMM16_X0_HI: u32 = 27;
5513/// X1 pipe high 16-bit
5514pub const R_TILEPRO_IMM16_X1_HI: u32 = 28;
5515/// X0 pipe high 16-bit, adjusted
5516pub const R_TILEPRO_IMM16_X0_HA: u32 = 29;
5517/// X1 pipe high 16-bit, adjusted
5518pub const R_TILEPRO_IMM16_X1_HA: u32 = 30;
5519/// X0 pipe PC relative 16 bit
5520pub const R_TILEPRO_IMM16_X0_PCREL: u32 = 31;
5521/// X1 pipe PC relative 16 bit
5522pub const R_TILEPRO_IMM16_X1_PCREL: u32 = 32;
5523/// X0 pipe PC relative low 16 bit
5524pub const R_TILEPRO_IMM16_X0_LO_PCREL: u32 = 33;
5525/// X1 pipe PC relative low 16 bit
5526pub const R_TILEPRO_IMM16_X1_LO_PCREL: u32 = 34;
5527/// X0 pipe PC relative high 16 bit
5528pub const R_TILEPRO_IMM16_X0_HI_PCREL: u32 = 35;
5529/// X1 pipe PC relative high 16 bit
5530pub const R_TILEPRO_IMM16_X1_HI_PCREL: u32 = 36;
5531/// X0 pipe PC relative ha() 16 bit
5532pub const R_TILEPRO_IMM16_X0_HA_PCREL: u32 = 37;
5533/// X1 pipe PC relative ha() 16 bit
5534pub const R_TILEPRO_IMM16_X1_HA_PCREL: u32 = 38;
5535/// X0 pipe 16-bit GOT offset
5536pub const R_TILEPRO_IMM16_X0_GOT: u32 = 39;
5537/// X1 pipe 16-bit GOT offset
5538pub const R_TILEPRO_IMM16_X1_GOT: u32 = 40;
5539/// X0 pipe low 16-bit GOT offset
5540pub const R_TILEPRO_IMM16_X0_GOT_LO: u32 = 41;
5541/// X1 pipe low 16-bit GOT offset
5542pub const R_TILEPRO_IMM16_X1_GOT_LO: u32 = 42;
5543/// X0 pipe high 16-bit GOT offset
5544pub const R_TILEPRO_IMM16_X0_GOT_HI: u32 = 43;
5545/// X1 pipe high 16-bit GOT offset
5546pub const R_TILEPRO_IMM16_X1_GOT_HI: u32 = 44;
5547/// X0 pipe ha() 16-bit GOT offset
5548pub const R_TILEPRO_IMM16_X0_GOT_HA: u32 = 45;
5549/// X1 pipe ha() 16-bit GOT offset
5550pub const R_TILEPRO_IMM16_X1_GOT_HA: u32 = 46;
5551/// X0 pipe mm "start"
5552pub const R_TILEPRO_MMSTART_X0: u32 = 47;
5553/// X0 pipe mm "end"
5554pub const R_TILEPRO_MMEND_X0: u32 = 48;
5555/// X1 pipe mm "start"
5556pub const R_TILEPRO_MMSTART_X1: u32 = 49;
5557/// X1 pipe mm "end"
5558pub const R_TILEPRO_MMEND_X1: u32 = 50;
5559/// X0 pipe shift amount
5560pub const R_TILEPRO_SHAMT_X0: u32 = 51;
5561/// X1 pipe shift amount
5562pub const R_TILEPRO_SHAMT_X1: u32 = 52;
5563/// Y0 pipe shift amount
5564pub const R_TILEPRO_SHAMT_Y0: u32 = 53;
5565/// Y1 pipe shift amount
5566pub const R_TILEPRO_SHAMT_Y1: u32 = 54;
5567/// X1 pipe destination 8-bit
5568pub const R_TILEPRO_DEST_IMM8_X1: u32 = 55;
5569// Relocs 56-59 are currently not defined.
5570/// "jal" for TLS GD
5571pub const R_TILEPRO_TLS_GD_CALL: u32 = 60;
5572/// X0 pipe "addi" for TLS GD
5573pub const R_TILEPRO_IMM8_X0_TLS_GD_ADD: u32 = 61;
5574/// X1 pipe "addi" for TLS GD
5575pub const R_TILEPRO_IMM8_X1_TLS_GD_ADD: u32 = 62;
5576/// Y0 pipe "addi" for TLS GD
5577pub const R_TILEPRO_IMM8_Y0_TLS_GD_ADD: u32 = 63;
5578/// Y1 pipe "addi" for TLS GD
5579pub const R_TILEPRO_IMM8_Y1_TLS_GD_ADD: u32 = 64;
5580/// "lw_tls" for TLS IE
5581pub const R_TILEPRO_TLS_IE_LOAD: u32 = 65;
5582/// X0 pipe 16-bit TLS GD offset
5583pub const R_TILEPRO_IMM16_X0_TLS_GD: u32 = 66;
5584/// X1 pipe 16-bit TLS GD offset
5585pub const R_TILEPRO_IMM16_X1_TLS_GD: u32 = 67;
5586/// X0 pipe low 16-bit TLS GD offset
5587pub const R_TILEPRO_IMM16_X0_TLS_GD_LO: u32 = 68;
5588/// X1 pipe low 16-bit TLS GD offset
5589pub const R_TILEPRO_IMM16_X1_TLS_GD_LO: u32 = 69;
5590/// X0 pipe high 16-bit TLS GD offset
5591pub const R_TILEPRO_IMM16_X0_TLS_GD_HI: u32 = 70;
5592/// X1 pipe high 16-bit TLS GD offset
5593pub const R_TILEPRO_IMM16_X1_TLS_GD_HI: u32 = 71;
5594/// X0 pipe ha() 16-bit TLS GD offset
5595pub const R_TILEPRO_IMM16_X0_TLS_GD_HA: u32 = 72;
5596/// X1 pipe ha() 16-bit TLS GD offset
5597pub const R_TILEPRO_IMM16_X1_TLS_GD_HA: u32 = 73;
5598/// X0 pipe 16-bit TLS IE offset
5599pub const R_TILEPRO_IMM16_X0_TLS_IE: u32 = 74;
5600/// X1 pipe 16-bit TLS IE offset
5601pub const R_TILEPRO_IMM16_X1_TLS_IE: u32 = 75;
5602/// X0 pipe low 16-bit TLS IE offset
5603pub const R_TILEPRO_IMM16_X0_TLS_IE_LO: u32 = 76;
5604/// X1 pipe low 16-bit TLS IE offset
5605pub const R_TILEPRO_IMM16_X1_TLS_IE_LO: u32 = 77;
5606/// X0 pipe high 16-bit TLS IE offset
5607pub const R_TILEPRO_IMM16_X0_TLS_IE_HI: u32 = 78;
5608/// X1 pipe high 16-bit TLS IE offset
5609pub const R_TILEPRO_IMM16_X1_TLS_IE_HI: u32 = 79;
5610/// X0 pipe ha() 16-bit TLS IE offset
5611pub const R_TILEPRO_IMM16_X0_TLS_IE_HA: u32 = 80;
5612/// X1 pipe ha() 16-bit TLS IE offset
5613pub const R_TILEPRO_IMM16_X1_TLS_IE_HA: u32 = 81;
5614/// ID of module containing symbol
5615pub const R_TILEPRO_TLS_DTPMOD32: u32 = 82;
5616/// Offset in TLS block
5617pub const R_TILEPRO_TLS_DTPOFF32: u32 = 83;
5618/// Offset in static TLS block
5619pub const R_TILEPRO_TLS_TPOFF32: u32 = 84;
5620/// X0 pipe 16-bit TLS LE offset
5621pub const R_TILEPRO_IMM16_X0_TLS_LE: u32 = 85;
5622/// X1 pipe 16-bit TLS LE offset
5623pub const R_TILEPRO_IMM16_X1_TLS_LE: u32 = 86;
5624/// X0 pipe low 16-bit TLS LE offset
5625pub const R_TILEPRO_IMM16_X0_TLS_LE_LO: u32 = 87;
5626/// X1 pipe low 16-bit TLS LE offset
5627pub const R_TILEPRO_IMM16_X1_TLS_LE_LO: u32 = 88;
5628/// X0 pipe high 16-bit TLS LE offset
5629pub const R_TILEPRO_IMM16_X0_TLS_LE_HI: u32 = 89;
5630/// X1 pipe high 16-bit TLS LE offset
5631pub const R_TILEPRO_IMM16_X1_TLS_LE_HI: u32 = 90;
5632/// X0 pipe ha() 16-bit TLS LE offset
5633pub const R_TILEPRO_IMM16_X0_TLS_LE_HA: u32 = 91;
5634/// X1 pipe ha() 16-bit TLS LE offset
5635pub const R_TILEPRO_IMM16_X1_TLS_LE_HA: u32 = 92;
5636
5637/// GNU C++ vtable hierarchy
5638pub const R_TILEPRO_GNU_VTINHERIT: u32 = 128;
5639/// GNU C++ vtable member usage
5640pub const R_TILEPRO_GNU_VTENTRY: u32 = 129;
5641
5642// TILE-Gx values `Rel*::r_type`.
5643/// No reloc
5644pub const R_TILEGX_NONE: u32 = 0;
5645/// Direct 64 bit
5646pub const R_TILEGX_64: u32 = 1;
5647/// Direct 32 bit
5648pub const R_TILEGX_32: u32 = 2;
5649/// Direct 16 bit
5650pub const R_TILEGX_16: u32 = 3;
5651/// Direct 8 bit
5652pub const R_TILEGX_8: u32 = 4;
5653/// PC relative 64 bit
5654pub const R_TILEGX_64_PCREL: u32 = 5;
5655/// PC relative 32 bit
5656pub const R_TILEGX_32_PCREL: u32 = 6;
5657/// PC relative 16 bit
5658pub const R_TILEGX_16_PCREL: u32 = 7;
5659/// PC relative 8 bit
5660pub const R_TILEGX_8_PCREL: u32 = 8;
5661/// hword 0 16-bit
5662pub const R_TILEGX_HW0: u32 = 9;
5663/// hword 1 16-bit
5664pub const R_TILEGX_HW1: u32 = 10;
5665/// hword 2 16-bit
5666pub const R_TILEGX_HW2: u32 = 11;
5667/// hword 3 16-bit
5668pub const R_TILEGX_HW3: u32 = 12;
5669/// last hword 0 16-bit
5670pub const R_TILEGX_HW0_LAST: u32 = 13;
5671/// last hword 1 16-bit
5672pub const R_TILEGX_HW1_LAST: u32 = 14;
5673/// last hword 2 16-bit
5674pub const R_TILEGX_HW2_LAST: u32 = 15;
5675/// Copy relocation
5676pub const R_TILEGX_COPY: u32 = 16;
5677/// Create GOT entry
5678pub const R_TILEGX_GLOB_DAT: u32 = 17;
5679/// Create PLT entry
5680pub const R_TILEGX_JMP_SLOT: u32 = 18;
5681/// Adjust by program base
5682pub const R_TILEGX_RELATIVE: u32 = 19;
5683/// X1 pipe branch offset
5684pub const R_TILEGX_BROFF_X1: u32 = 20;
5685/// X1 pipe jump offset
5686pub const R_TILEGX_JUMPOFF_X1: u32 = 21;
5687/// X1 pipe jump offset to PLT
5688pub const R_TILEGX_JUMPOFF_X1_PLT: u32 = 22;
5689/// X0 pipe 8-bit
5690pub const R_TILEGX_IMM8_X0: u32 = 23;
5691/// Y0 pipe 8-bit
5692pub const R_TILEGX_IMM8_Y0: u32 = 24;
5693/// X1 pipe 8-bit
5694pub const R_TILEGX_IMM8_X1: u32 = 25;
5695/// Y1 pipe 8-bit
5696pub const R_TILEGX_IMM8_Y1: u32 = 26;
5697/// X1 pipe destination 8-bit
5698pub const R_TILEGX_DEST_IMM8_X1: u32 = 27;
5699/// X1 pipe mtspr
5700pub const R_TILEGX_MT_IMM14_X1: u32 = 28;
5701/// X1 pipe mfspr
5702pub const R_TILEGX_MF_IMM14_X1: u32 = 29;
5703/// X0 pipe mm "start"
5704pub const R_TILEGX_MMSTART_X0: u32 = 30;
5705/// X0 pipe mm "end"
5706pub const R_TILEGX_MMEND_X0: u32 = 31;
5707/// X0 pipe shift amount
5708pub const R_TILEGX_SHAMT_X0: u32 = 32;
5709/// X1 pipe shift amount
5710pub const R_TILEGX_SHAMT_X1: u32 = 33;
5711/// Y0 pipe shift amount
5712pub const R_TILEGX_SHAMT_Y0: u32 = 34;
5713/// Y1 pipe shift amount
5714pub const R_TILEGX_SHAMT_Y1: u32 = 35;
5715/// X0 pipe hword 0
5716pub const R_TILEGX_IMM16_X0_HW0: u32 = 36;
5717/// X1 pipe hword 0
5718pub const R_TILEGX_IMM16_X1_HW0: u32 = 37;
5719/// X0 pipe hword 1
5720pub const R_TILEGX_IMM16_X0_HW1: u32 = 38;
5721/// X1 pipe hword 1
5722pub const R_TILEGX_IMM16_X1_HW1: u32 = 39;
5723/// X0 pipe hword 2
5724pub const R_TILEGX_IMM16_X0_HW2: u32 = 40;
5725/// X1 pipe hword 2
5726pub const R_TILEGX_IMM16_X1_HW2: u32 = 41;
5727/// X0 pipe hword 3
5728pub const R_TILEGX_IMM16_X0_HW3: u32 = 42;
5729/// X1 pipe hword 3
5730pub const R_TILEGX_IMM16_X1_HW3: u32 = 43;
5731/// X0 pipe last hword 0
5732pub const R_TILEGX_IMM16_X0_HW0_LAST: u32 = 44;
5733/// X1 pipe last hword 0
5734pub const R_TILEGX_IMM16_X1_HW0_LAST: u32 = 45;
5735/// X0 pipe last hword 1
5736pub const R_TILEGX_IMM16_X0_HW1_LAST: u32 = 46;
5737/// X1 pipe last hword 1
5738pub const R_TILEGX_IMM16_X1_HW1_LAST: u32 = 47;
5739/// X0 pipe last hword 2
5740pub const R_TILEGX_IMM16_X0_HW2_LAST: u32 = 48;
5741/// X1 pipe last hword 2
5742pub const R_TILEGX_IMM16_X1_HW2_LAST: u32 = 49;
5743/// X0 pipe PC relative hword 0
5744pub const R_TILEGX_IMM16_X0_HW0_PCREL: u32 = 50;
5745/// X1 pipe PC relative hword 0
5746pub const R_TILEGX_IMM16_X1_HW0_PCREL: u32 = 51;
5747/// X0 pipe PC relative hword 1
5748pub const R_TILEGX_IMM16_X0_HW1_PCREL: u32 = 52;
5749/// X1 pipe PC relative hword 1
5750pub const R_TILEGX_IMM16_X1_HW1_PCREL: u32 = 53;
5751/// X0 pipe PC relative hword 2
5752pub const R_TILEGX_IMM16_X0_HW2_PCREL: u32 = 54;
5753/// X1 pipe PC relative hword 2
5754pub const R_TILEGX_IMM16_X1_HW2_PCREL: u32 = 55;
5755/// X0 pipe PC relative hword 3
5756pub const R_TILEGX_IMM16_X0_HW3_PCREL: u32 = 56;
5757/// X1 pipe PC relative hword 3
5758pub const R_TILEGX_IMM16_X1_HW3_PCREL: u32 = 57;
5759/// X0 pipe PC-rel last hword 0
5760pub const R_TILEGX_IMM16_X0_HW0_LAST_PCREL: u32 = 58;
5761/// X1 pipe PC-rel last hword 0
5762pub const R_TILEGX_IMM16_X1_HW0_LAST_PCREL: u32 = 59;
5763/// X0 pipe PC-rel last hword 1
5764pub const R_TILEGX_IMM16_X0_HW1_LAST_PCREL: u32 = 60;
5765/// X1 pipe PC-rel last hword 1
5766pub const R_TILEGX_IMM16_X1_HW1_LAST_PCREL: u32 = 61;
5767/// X0 pipe PC-rel last hword 2
5768pub const R_TILEGX_IMM16_X0_HW2_LAST_PCREL: u32 = 62;
5769/// X1 pipe PC-rel last hword 2
5770pub const R_TILEGX_IMM16_X1_HW2_LAST_PCREL: u32 = 63;
5771/// X0 pipe hword 0 GOT offset
5772pub const R_TILEGX_IMM16_X0_HW0_GOT: u32 = 64;
5773/// X1 pipe hword 0 GOT offset
5774pub const R_TILEGX_IMM16_X1_HW0_GOT: u32 = 65;
5775/// X0 pipe PC-rel PLT hword 0
5776pub const R_TILEGX_IMM16_X0_HW0_PLT_PCREL: u32 = 66;
5777/// X1 pipe PC-rel PLT hword 0
5778pub const R_TILEGX_IMM16_X1_HW0_PLT_PCREL: u32 = 67;
5779/// X0 pipe PC-rel PLT hword 1
5780pub const R_TILEGX_IMM16_X0_HW1_PLT_PCREL: u32 = 68;
5781/// X1 pipe PC-rel PLT hword 1
5782pub const R_TILEGX_IMM16_X1_HW1_PLT_PCREL: u32 = 69;
5783/// X0 pipe PC-rel PLT hword 2
5784pub const R_TILEGX_IMM16_X0_HW2_PLT_PCREL: u32 = 70;
5785/// X1 pipe PC-rel PLT hword 2
5786pub const R_TILEGX_IMM16_X1_HW2_PLT_PCREL: u32 = 71;
5787/// X0 pipe last hword 0 GOT offset
5788pub const R_TILEGX_IMM16_X0_HW0_LAST_GOT: u32 = 72;
5789/// X1 pipe last hword 0 GOT offset
5790pub const R_TILEGX_IMM16_X1_HW0_LAST_GOT: u32 = 73;
5791/// X0 pipe last hword 1 GOT offset
5792pub const R_TILEGX_IMM16_X0_HW1_LAST_GOT: u32 = 74;
5793/// X1 pipe last hword 1 GOT offset
5794pub const R_TILEGX_IMM16_X1_HW1_LAST_GOT: u32 = 75;
5795/// X0 pipe PC-rel PLT hword 3
5796pub const R_TILEGX_IMM16_X0_HW3_PLT_PCREL: u32 = 76;
5797/// X1 pipe PC-rel PLT hword 3
5798pub const R_TILEGX_IMM16_X1_HW3_PLT_PCREL: u32 = 77;
5799/// X0 pipe hword 0 TLS GD offset
5800pub const R_TILEGX_IMM16_X0_HW0_TLS_GD: u32 = 78;
5801/// X1 pipe hword 0 TLS GD offset
5802pub const R_TILEGX_IMM16_X1_HW0_TLS_GD: u32 = 79;
5803/// X0 pipe hword 0 TLS LE offset
5804pub const R_TILEGX_IMM16_X0_HW0_TLS_LE: u32 = 80;
5805/// X1 pipe hword 0 TLS LE offset
5806pub const R_TILEGX_IMM16_X1_HW0_TLS_LE: u32 = 81;
5807/// X0 pipe last hword 0 LE off
5808pub const R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE: u32 = 82;
5809/// X1 pipe last hword 0 LE off
5810pub const R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE: u32 = 83;
5811/// X0 pipe last hword 1 LE off
5812pub const R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE: u32 = 84;
5813/// X1 pipe last hword 1 LE off
5814pub const R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE: u32 = 85;
5815/// X0 pipe last hword 0 GD off
5816pub const R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD: u32 = 86;
5817/// X1 pipe last hword 0 GD off
5818pub const R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD: u32 = 87;
5819/// X0 pipe last hword 1 GD off
5820pub const R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD: u32 = 88;
5821/// X1 pipe last hword 1 GD off
5822pub const R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD: u32 = 89;
5823// Relocs 90-91 are currently not defined.
5824/// X0 pipe hword 0 TLS IE offset
5825pub const R_TILEGX_IMM16_X0_HW0_TLS_IE: u32 = 92;
5826/// X1 pipe hword 0 TLS IE offset
5827pub const R_TILEGX_IMM16_X1_HW0_TLS_IE: u32 = 93;
5828/// X0 pipe PC-rel PLT last hword 0
5829pub const R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL: u32 = 94;
5830/// X1 pipe PC-rel PLT last hword 0
5831pub const R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL: u32 = 95;
5832/// X0 pipe PC-rel PLT last hword 1
5833pub const R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL: u32 = 96;
5834/// X1 pipe PC-rel PLT last hword 1
5835pub const R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL: u32 = 97;
5836/// X0 pipe PC-rel PLT last hword 2
5837pub const R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL: u32 = 98;
5838/// X1 pipe PC-rel PLT last hword 2
5839pub const R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL: u32 = 99;
5840/// X0 pipe last hword 0 IE off
5841pub const R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE: u32 = 100;
5842/// X1 pipe last hword 0 IE off
5843pub const R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE: u32 = 101;
5844/// X0 pipe last hword 1 IE off
5845pub const R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE: u32 = 102;
5846/// X1 pipe last hword 1 IE off
5847pub const R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE: u32 = 103;
5848// Relocs 104-105 are currently not defined.
5849/// 64-bit ID of symbol's module
5850pub const R_TILEGX_TLS_DTPMOD64: u32 = 106;
5851/// 64-bit offset in TLS block
5852pub const R_TILEGX_TLS_DTPOFF64: u32 = 107;
5853/// 64-bit offset in static TLS block
5854pub const R_TILEGX_TLS_TPOFF64: u32 = 108;
5855/// 32-bit ID of symbol's module
5856pub const R_TILEGX_TLS_DTPMOD32: u32 = 109;
5857/// 32-bit offset in TLS block
5858pub const R_TILEGX_TLS_DTPOFF32: u32 = 110;
5859/// 32-bit offset in static TLS block
5860pub const R_TILEGX_TLS_TPOFF32: u32 = 111;
5861/// "jal" for TLS GD
5862pub const R_TILEGX_TLS_GD_CALL: u32 = 112;
5863/// X0 pipe "addi" for TLS GD
5864pub const R_TILEGX_IMM8_X0_TLS_GD_ADD: u32 = 113;
5865/// X1 pipe "addi" for TLS GD
5866pub const R_TILEGX_IMM8_X1_TLS_GD_ADD: u32 = 114;
5867/// Y0 pipe "addi" for TLS GD
5868pub const R_TILEGX_IMM8_Y0_TLS_GD_ADD: u32 = 115;
5869/// Y1 pipe "addi" for TLS GD
5870pub const R_TILEGX_IMM8_Y1_TLS_GD_ADD: u32 = 116;
5871/// "ld_tls" for TLS IE
5872pub const R_TILEGX_TLS_IE_LOAD: u32 = 117;
5873/// X0 pipe "addi" for TLS GD/IE
5874pub const R_TILEGX_IMM8_X0_TLS_ADD: u32 = 118;
5875/// X1 pipe "addi" for TLS GD/IE
5876pub const R_TILEGX_IMM8_X1_TLS_ADD: u32 = 119;
5877/// Y0 pipe "addi" for TLS GD/IE
5878pub const R_TILEGX_IMM8_Y0_TLS_ADD: u32 = 120;
5879/// Y1 pipe "addi" for TLS GD/IE
5880pub const R_TILEGX_IMM8_Y1_TLS_ADD: u32 = 121;
5881
5882/// GNU C++ vtable hierarchy
5883pub const R_TILEGX_GNU_VTINHERIT: u32 = 128;
5884/// GNU C++ vtable member usage
5885pub const R_TILEGX_GNU_VTENTRY: u32 = 129;
5886
5887// RISC-V values `FileHeader*::e_flags`.
5888pub const EF_RISCV_RVC: u32 = 0x0001;
5889pub const EF_RISCV_FLOAT_ABI: u32 = 0x0006;
5890pub const EF_RISCV_FLOAT_ABI_SOFT: u32 = 0x0000;
5891pub const EF_RISCV_FLOAT_ABI_SINGLE: u32 = 0x0002;
5892pub const EF_RISCV_FLOAT_ABI_DOUBLE: u32 = 0x0004;
5893pub const EF_RISCV_FLOAT_ABI_QUAD: u32 = 0x0006;
5894pub const EF_RISCV_RVE: u32 = 0x0008;
5895pub const EF_RISCV_TSO: u32 = 0x0010;
5896pub const EF_RISCV_RV64ILP32: u32 = 0x0020;
5897
5898// RISC-V values for `Sym64::st_other`.
5899/// Function uses variant calling convention.
5900pub const STO_RISCV_VARIANT_CC: u8 = 0x80;
5901
5902// RISC-V values for `SectionHeader*::sh_type`.
5903/// RISC-V attributes section.
5904pub const SHT_RISCV_ATTRIBUTES: u32 = SHT_LOPROC + 3;
5905
5906// RISC-V values for `ProgramHeader*::p_type`.
5907
5908pub const PT_RISCV_ATTRIBUTES: u32 = PT_LOPROC + 3;
5909
5910// RISC-V values for `Dyn64::d_tag`.
5911
5912pub const DT_RISCV_VARIANT_CC: i64 = DT_LOPROC + 1;
5913
5914// RISC-V values `Rel*::r_type`.
5915pub const R_RISCV_NONE: u32 = 0;
5916pub const R_RISCV_32: u32 = 1;
5917pub const R_RISCV_64: u32 = 2;
5918pub const R_RISCV_RELATIVE: u32 = 3;
5919pub const R_RISCV_COPY: u32 = 4;
5920pub const R_RISCV_JUMP_SLOT: u32 = 5;
5921pub const R_RISCV_TLS_DTPMOD32: u32 = 6;
5922pub const R_RISCV_TLS_DTPMOD64: u32 = 7;
5923pub const R_RISCV_TLS_DTPREL32: u32 = 8;
5924pub const R_RISCV_TLS_DTPREL64: u32 = 9;
5925pub const R_RISCV_TLS_TPREL32: u32 = 10;
5926pub const R_RISCV_TLS_TPREL64: u32 = 11;
5927pub const R_RISCV_TLSDESC: u32 = 12;
5928pub const R_RISCV_BRANCH: u32 = 16;
5929pub const R_RISCV_JAL: u32 = 17;
5930pub const R_RISCV_CALL: u32 = 18;
5931pub const R_RISCV_CALL_PLT: u32 = 19;
5932pub const R_RISCV_GOT_HI20: u32 = 20;
5933pub const R_RISCV_TLS_GOT_HI20: u32 = 21;
5934pub const R_RISCV_TLS_GD_HI20: u32 = 22;
5935pub const R_RISCV_PCREL_HI20: u32 = 23;
5936pub const R_RISCV_PCREL_LO12_I: u32 = 24;
5937pub const R_RISCV_PCREL_LO12_S: u32 = 25;
5938pub const R_RISCV_HI20: u32 = 26;
5939pub const R_RISCV_LO12_I: u32 = 27;
5940pub const R_RISCV_LO12_S: u32 = 28;
5941pub const R_RISCV_TPREL_HI20: u32 = 29;
5942pub const R_RISCV_TPREL_LO12_I: u32 = 30;
5943pub const R_RISCV_TPREL_LO12_S: u32 = 31;
5944pub const R_RISCV_TPREL_ADD: u32 = 32;
5945pub const R_RISCV_ADD8: u32 = 33;
5946pub const R_RISCV_ADD16: u32 = 34;
5947pub const R_RISCV_ADD32: u32 = 35;
5948pub const R_RISCV_ADD64: u32 = 36;
5949pub const R_RISCV_SUB8: u32 = 37;
5950pub const R_RISCV_SUB16: u32 = 38;
5951pub const R_RISCV_SUB32: u32 = 39;
5952pub const R_RISCV_SUB64: u32 = 40;
5953pub const R_RISCV_GOT32_PCREL: u32 = 41;
5954// 42 Reserved was R_RISCV_GNU_VTENTRY
5955pub const R_RISCV_ALIGN: u32 = 43;
5956pub const R_RISCV_RVC_BRANCH: u32 = 44;
5957pub const R_RISCV_RVC_JUMP: u32 = 45;
5958pub const R_RISCV_RVC_LUI: u32 = 46;
5959pub const R_RISCV_GPREL_I: u32 = 47;
5960pub const R_RISCV_GPREL_S: u32 = 48;
5961pub const R_RISCV_TPREL_I: u32 = 49;
5962pub const R_RISCV_TPREL_S: u32 = 50;
5963pub const R_RISCV_RELAX: u32 = 51;
5964pub const R_RISCV_SUB6: u32 = 52;
5965pub const R_RISCV_SET6: u32 = 53;
5966pub const R_RISCV_SET8: u32 = 54;
5967pub const R_RISCV_SET16: u32 = 55;
5968pub const R_RISCV_SET32: u32 = 56;
5969pub const R_RISCV_32_PCREL: u32 = 57;
5970pub const R_RISCV_IRELATIVE: u32 = 58;
5971pub const R_RISCV_PLT32: u32 = 59;
5972pub const R_RISCV_SET_ULEB128: u32 = 60;
5973pub const R_RISCV_SUB_ULEB128: u32 = 61;
5974pub const R_RISCV_TLSDESC_HI20: u32 = 62;
5975pub const R_RISCV_TLSDESC_LOAD_LO12: u32 = 63;
5976pub const R_RISCV_TLSDESC_ADD_LO12: u32 = 64;
5977pub const R_RISCV_TLSDESC_CALL: u32 = 65;
5978
5979// BPF values `Rel*::r_type`.
5980/// No reloc
5981pub const R_BPF_NONE: u32 = 0;
5982pub const R_BPF_64_64: u32 = 1;
5983pub const R_BPF_64_32: u32 = 10;
5984
5985// SBF values `Rel*::r_type`.
5986/// No reloc
5987pub const R_SBF_NONE: u32 = 0;
5988pub const R_SBF_64_64: u32 = 1;
5989pub const R_SBF_64_32: u32 = 10;
5990
5991// Imagination Meta values `Rel*::r_type`.
5992
5993pub const R_METAG_HIADDR16: u32 = 0;
5994pub const R_METAG_LOADDR16: u32 = 1;
5995/// 32bit absolute address
5996pub const R_METAG_ADDR32: u32 = 2;
5997/// No reloc
5998pub const R_METAG_NONE: u32 = 3;
5999pub const R_METAG_RELBRANCH: u32 = 4;
6000pub const R_METAG_GETSETOFF: u32 = 5;
6001
6002// Backward compatibility
6003pub const R_METAG_REG32OP1: u32 = 6;
6004pub const R_METAG_REG32OP2: u32 = 7;
6005pub const R_METAG_REG32OP3: u32 = 8;
6006pub const R_METAG_REG16OP1: u32 = 9;
6007pub const R_METAG_REG16OP2: u32 = 10;
6008pub const R_METAG_REG16OP3: u32 = 11;
6009pub const R_METAG_REG32OP4: u32 = 12;
6010
6011pub const R_METAG_HIOG: u32 = 13;
6012pub const R_METAG_LOOG: u32 = 14;
6013
6014pub const R_METAG_REL8: u32 = 15;
6015pub const R_METAG_REL16: u32 = 16;
6016
6017pub const R_METAG_GNU_VTINHERIT: u32 = 30;
6018pub const R_METAG_GNU_VTENTRY: u32 = 31;
6019
6020// PIC relocations
6021pub const R_METAG_HI16_GOTOFF: u32 = 32;
6022pub const R_METAG_LO16_GOTOFF: u32 = 33;
6023pub const R_METAG_GETSET_GOTOFF: u32 = 34;
6024pub const R_METAG_GETSET_GOT: u32 = 35;
6025pub const R_METAG_HI16_GOTPC: u32 = 36;
6026pub const R_METAG_LO16_GOTPC: u32 = 37;
6027pub const R_METAG_HI16_PLT: u32 = 38;
6028pub const R_METAG_LO16_PLT: u32 = 39;
6029pub const R_METAG_RELBRANCH_PLT: u32 = 40;
6030pub const R_METAG_GOTOFF: u32 = 41;
6031pub const R_METAG_PLT: u32 = 42;
6032pub const R_METAG_COPY: u32 = 43;
6033pub const R_METAG_JMP_SLOT: u32 = 44;
6034pub const R_METAG_RELATIVE: u32 = 45;
6035pub const R_METAG_GLOB_DAT: u32 = 46;
6036
6037// TLS relocations
6038pub const R_METAG_TLS_GD: u32 = 47;
6039pub const R_METAG_TLS_LDM: u32 = 48;
6040pub const R_METAG_TLS_LDO_HI16: u32 = 49;
6041pub const R_METAG_TLS_LDO_LO16: u32 = 50;
6042pub const R_METAG_TLS_LDO: u32 = 51;
6043pub const R_METAG_TLS_IE: u32 = 52;
6044pub const R_METAG_TLS_IENONPIC: u32 = 53;
6045pub const R_METAG_TLS_IENONPIC_HI16: u32 = 54;
6046pub const R_METAG_TLS_IENONPIC_LO16: u32 = 55;
6047pub const R_METAG_TLS_TPOFF: u32 = 56;
6048pub const R_METAG_TLS_DTPMOD: u32 = 57;
6049pub const R_METAG_TLS_DTPOFF: u32 = 58;
6050pub const R_METAG_TLS_LE: u32 = 59;
6051pub const R_METAG_TLS_LE_HI16: u32 = 60;
6052pub const R_METAG_TLS_LE_LO16: u32 = 61;
6053
6054// NDS32 values `Rel*::r_type`.
6055pub const R_NDS32_NONE: u32 = 0;
6056pub const R_NDS32_32_RELA: u32 = 20;
6057pub const R_NDS32_COPY: u32 = 39;
6058pub const R_NDS32_GLOB_DAT: u32 = 40;
6059pub const R_NDS32_JMP_SLOT: u32 = 41;
6060pub const R_NDS32_RELATIVE: u32 = 42;
6061pub const R_NDS32_TLS_TPOFF: u32 = 102;
6062pub const R_NDS32_TLS_DESC: u32 = 119;
6063
6064// LoongArch values `FileHeader*::e_flags`.
6065/// Additional properties of the base ABI type, including the FP calling
6066/// convention.
6067pub const EF_LARCH_ABI_MODIFIER_MASK: u32 = 0x7;
6068/// Uses GPRs and the stack for parameter passing
6069pub const EF_LARCH_ABI_SOFT_FLOAT: u32 = 0x1;
6070/// Uses GPRs, 32-bit FPRs and the stack for parameter passing
6071pub const EF_LARCH_ABI_SINGLE_FLOAT: u32 = 0x2;
6072/// Uses GPRs, 64-bit FPRs and the stack for parameter passing
6073pub const EF_LARCH_ABI_DOUBLE_FLOAT: u32 = 0x3;
6074/// Uses relocation types directly writing to immediate slots
6075pub const EF_LARCH_OBJABI_V1: u32 = 0x40;
6076
6077// LoongArch values `Rel*::r_type`.
6078/// No reloc
6079pub const R_LARCH_NONE: u32 = 0;
6080/// Runtime address resolving
6081pub const R_LARCH_32: u32 = 1;
6082/// Runtime address resolving
6083pub const R_LARCH_64: u32 = 2;
6084/// Runtime fixup for load-address
6085pub const R_LARCH_RELATIVE: u32 = 3;
6086/// Runtime memory copy in executable
6087pub const R_LARCH_COPY: u32 = 4;
6088/// Runtime PLT supporting
6089pub const R_LARCH_JUMP_SLOT: u32 = 5;
6090/// Runtime relocation for TLS-GD
6091pub const R_LARCH_TLS_DTPMOD32: u32 = 6;
6092/// Runtime relocation for TLS-GD
6093pub const R_LARCH_TLS_DTPMOD64: u32 = 7;
6094/// Runtime relocation for TLS-GD
6095pub const R_LARCH_TLS_DTPREL32: u32 = 8;
6096/// Runtime relocation for TLS-GD
6097pub const R_LARCH_TLS_DTPREL64: u32 = 9;
6098/// Runtime relocation for TLE-IE
6099pub const R_LARCH_TLS_TPREL32: u32 = 10;
6100/// Runtime relocation for TLE-IE
6101pub const R_LARCH_TLS_TPREL64: u32 = 11;
6102/// Runtime local indirect function resolving
6103pub const R_LARCH_IRELATIVE: u32 = 12;
6104/// Runtime relocation for TLS descriptors
6105pub const R_LARCH_TLS_DESC32: u32 = 13;
6106/// Runtime relocation for TLS descriptors
6107pub const R_LARCH_TLS_DESC64: u32 = 14;
6108/// Mark la.abs: load absolute address for static link.
6109pub const R_LARCH_MARK_LA: u32 = 20;
6110/// Mark external label branch: access PC relative address for static link.
6111pub const R_LARCH_MARK_PCREL: u32 = 21;
6112/// Push PC-relative offset
6113pub const R_LARCH_SOP_PUSH_PCREL: u32 = 22;
6114/// Push constant or absolute address
6115pub const R_LARCH_SOP_PUSH_ABSOLUTE: u32 = 23;
6116/// Duplicate stack top
6117pub const R_LARCH_SOP_PUSH_DUP: u32 = 24;
6118/// Push for access GOT entry
6119pub const R_LARCH_SOP_PUSH_GPREL: u32 = 25;
6120/// Push for TLS-LE
6121pub const R_LARCH_SOP_PUSH_TLS_TPREL: u32 = 26;
6122/// Push for TLS-IE
6123pub const R_LARCH_SOP_PUSH_TLS_GOT: u32 = 27;
6124/// Push for TLS-GD
6125pub const R_LARCH_SOP_PUSH_TLS_GD: u32 = 28;
6126/// Push for external function calling
6127pub const R_LARCH_SOP_PUSH_PLT_PCREL: u32 = 29;
6128/// Assert stack top
6129pub const R_LARCH_SOP_ASSERT: u32 = 30;
6130/// Stack top logical not (unary)
6131pub const R_LARCH_SOP_NOT: u32 = 31;
6132/// Stack top subtraction (binary)
6133pub const R_LARCH_SOP_SUB: u32 = 32;
6134/// Stack top left shift (binary)
6135pub const R_LARCH_SOP_SL: u32 = 33;
6136/// Stack top right shift (binary)
6137pub const R_LARCH_SOP_SR: u32 = 34;
6138/// Stack top addition (binary)
6139pub const R_LARCH_SOP_ADD: u32 = 35;
6140/// Stack top bitwise and (binary)
6141pub const R_LARCH_SOP_AND: u32 = 36;
6142/// Stack top selection (tertiary)
6143pub const R_LARCH_SOP_IF_ELSE: u32 = 37;
6144/// Pop stack top to fill 5-bit signed immediate operand
6145pub const R_LARCH_SOP_POP_32_S_10_5: u32 = 38;
6146/// Pop stack top to fill 12-bit unsigned immediate operand
6147pub const R_LARCH_SOP_POP_32_U_10_12: u32 = 39;
6148/// Pop stack top to fill 12-bit signed immediate operand
6149pub const R_LARCH_SOP_POP_32_S_10_12: u32 = 40;
6150/// Pop stack top to fill 16-bit signed immediate operand
6151pub const R_LARCH_SOP_POP_32_S_10_16: u32 = 41;
6152/// Pop stack top to fill 18-bit signed immediate operand with two trailing
6153/// zeros implied
6154pub const R_LARCH_SOP_POP_32_S_10_16_S2: u32 = 42;
6155/// Pop stack top to fill 20-bit signed immediate operand
6156pub const R_LARCH_SOP_POP_32_S_5_20: u32 = 43;
6157/// Pop stack top to fill 23-bit signed immediate operand with two trailing
6158/// zeros implied
6159pub const R_LARCH_SOP_POP_32_S_0_5_10_16_S2: u32 = 44;
6160/// Pop stack top to fill 28-bit signed immediate operand with two trailing
6161/// zeros implied
6162pub const R_LARCH_SOP_POP_32_S_0_10_10_16_S2: u32 = 45;
6163/// Pop stack top to fill an instruction
6164pub const R_LARCH_SOP_POP_32_U: u32 = 46;
6165/// 8-bit in-place addition
6166pub const R_LARCH_ADD8: u32 = 47;
6167/// 16-bit in-place addition
6168pub const R_LARCH_ADD16: u32 = 48;
6169/// 24-bit in-place addition
6170pub const R_LARCH_ADD24: u32 = 49;
6171/// 32-bit in-place addition
6172pub const R_LARCH_ADD32: u32 = 50;
6173/// 64-bit in-place addition
6174pub const R_LARCH_ADD64: u32 = 51;
6175/// 8-bit in-place subtraction
6176pub const R_LARCH_SUB8: u32 = 52;
6177/// 16-bit in-place subtraction
6178pub const R_LARCH_SUB16: u32 = 53;
6179/// 24-bit in-place subtraction
6180pub const R_LARCH_SUB24: u32 = 54;
6181/// 32-bit in-place subtraction
6182pub const R_LARCH_SUB32: u32 = 55;
6183/// 64-bit in-place subtraction
6184pub const R_LARCH_SUB64: u32 = 56;
6185/// GNU C++ vtable hierarchy
6186pub const R_LARCH_GNU_VTINHERIT: u32 = 57;
6187/// GNU C++ vtable member usage
6188pub const R_LARCH_GNU_VTENTRY: u32 = 58;
6189/// 18-bit PC-relative jump offset with two trailing zeros
6190pub const R_LARCH_B16: u32 = 64;
6191/// 23-bit PC-relative jump offset with two trailing zeros
6192pub const R_LARCH_B21: u32 = 65;
6193/// 28-bit PC-relative jump offset with two trailing zeros
6194pub const R_LARCH_B26: u32 = 66;
6195/// 12..=31 bits of 32/64-bit absolute address
6196pub const R_LARCH_ABS_HI20: u32 = 67;
6197/// 0..=11 bits of 32/64-bit absolute address
6198pub const R_LARCH_ABS_LO12: u32 = 68;
6199/// 32..=51 bits of 64-bit absolute address
6200pub const R_LARCH_ABS64_LO20: u32 = 69;
6201/// 52..=63 bits of 64-bit absolute address
6202pub const R_LARCH_ABS64_HI12: u32 = 70;
6203/// The signed 32-bit offset `offs` from `PC & 0xfffff000` to
6204/// `(S + A + 0x800) & 0xfffff000`, with 12 trailing zeros removed.
6205///
6206/// We define the *PC relative anchor* for `S + A` as `PC + offs` (`offs`
6207/// is sign-extended to VA bits).
6208pub const R_LARCH_PCALA_HI20: u32 = 71;
6209/// Same as R_LARCH_ABS_LO12.  0..=11 bits of the 32/64-bit offset from the
6210/// [PC relative anchor][R_LARCH_PCALA_HI20].
6211pub const R_LARCH_PCALA_LO12: u32 = 72;
6212/// 32..=51 bits of the 64-bit offset from the
6213/// [PC relative anchor][R_LARCH_PCALA_HI20].
6214pub const R_LARCH_PCALA64_LO20: u32 = 73;
6215/// 52..=63 bits of the 64-bit offset from the
6216/// [PC relative anchor][R_LARCH_PCALA_HI20].
6217pub const R_LARCH_PCALA64_HI12: u32 = 74;
6218/// The signed 32-bit offset `offs` from `PC & 0xfffff000` to
6219/// `(GP + G + 0x800) & 0xfffff000`, with 12 trailing zeros removed.
6220///
6221/// We define the *PC relative anchor* for the GOT entry at `GP + G` as
6222/// `PC + offs` (`offs` is sign-extended to VA bits).
6223pub const R_LARCH_GOT_PC_HI20: u32 = 75;
6224/// 0..=11 bits of the 32/64-bit offset from the
6225/// [PC relative anchor][R_LARCH_GOT_PC_HI20] to the GOT entry.
6226pub const R_LARCH_GOT_PC_LO12: u32 = 76;
6227/// 32..=51 bits of the 64-bit offset from the
6228/// [PC relative anchor][R_LARCH_GOT_PC_HI20] to the GOT entry.
6229pub const R_LARCH_GOT64_PC_LO20: u32 = 77;
6230/// 52..=63 bits of the 64-bit offset from the
6231/// [PC relative anchor][R_LARCH_GOT_PC_HI20] to the GOT entry.
6232pub const R_LARCH_GOT64_PC_HI12: u32 = 78;
6233/// 12..=31 bits of 32/64-bit GOT entry absolute address
6234pub const R_LARCH_GOT_HI20: u32 = 79;
6235/// 0..=11 bits of 32/64-bit GOT entry absolute address
6236pub const R_LARCH_GOT_LO12: u32 = 80;
6237/// 32..=51 bits of 64-bit GOT entry absolute address
6238pub const R_LARCH_GOT64_LO20: u32 = 81;
6239/// 52..=63 bits of 64-bit GOT entry absolute address
6240pub const R_LARCH_GOT64_HI12: u32 = 82;
6241/// 12..=31 bits of TLS LE 32/64-bit offset from thread pointer
6242pub const R_LARCH_TLS_LE_HI20: u32 = 83;
6243/// 0..=11 bits of TLS LE 32/64-bit offset from thread pointer
6244pub const R_LARCH_TLS_LE_LO12: u32 = 84;
6245/// 32..=51 bits of TLS LE 64-bit offset from thread pointer
6246pub const R_LARCH_TLS_LE64_LO20: u32 = 85;
6247/// 52..=63 bits of TLS LE 64-bit offset from thread pointer
6248pub const R_LARCH_TLS_LE64_HI12: u32 = 86;
6249/// The signed 32-bit offset `offs` from `PC & 0xfffff000` to
6250/// `(GP + IE + 0x800) & 0xfffff000`, with 12 trailing zeros removed.
6251///
6252/// We define the *PC relative anchor* for the TLS IE GOT entry at
6253/// `GP + IE` as `PC + offs` (`offs` is sign-extended to VA bits).
6254pub const R_LARCH_TLS_IE_PC_HI20: u32 = 87;
6255/// 0..=12 bits of the 32/64-bit offset from the
6256/// [PC-relative anchor][R_LARCH_TLS_IE_PC_HI20] to the TLS IE GOT entry.
6257pub const R_LARCH_TLS_IE_PC_LO12: u32 = 88;
6258/// 32..=51 bits of the 64-bit offset from the
6259/// [PC-relative anchor][R_LARCH_TLS_IE_PC_HI20] to the TLS IE GOT entry.
6260pub const R_LARCH_TLS_IE64_PC_LO20: u32 = 89;
6261/// 52..=63 bits of the 64-bit offset from the
6262/// [PC-relative anchor][R_LARCH_TLS_IE_PC_HI20] to the TLS IE GOT entry.
6263pub const R_LARCH_TLS_IE64_PC_HI12: u32 = 90;
6264/// 12..=31 bits of TLS IE GOT entry 32/64-bit absolute address
6265pub const R_LARCH_TLS_IE_HI20: u32 = 91;
6266/// 0..=11 bits of TLS IE GOT entry 32/64-bit absolute address
6267pub const R_LARCH_TLS_IE_LO12: u32 = 92;
6268/// 32..=51 bits of TLS IE GOT entry 64-bit absolute address
6269pub const R_LARCH_TLS_IE64_LO20: u32 = 93;
6270/// 51..=63 bits of TLS IE GOT entry 64-bit absolute address
6271pub const R_LARCH_TLS_IE64_HI12: u32 = 94;
6272/// 12..=31 bits of the offset from `PC` to `GP + GD + 0x800`, where
6273/// `GP + GD` is a TLS LD GOT entry
6274pub const R_LARCH_TLS_LD_PC_HI20: u32 = 95;
6275/// 12..=31 bits of TLS LD GOT entry 32/64-bit absolute address
6276pub const R_LARCH_TLS_LD_HI20: u32 = 96;
6277/// 12..=31 bits of the 32/64-bit PC-relative offset to the PC-relative
6278/// anchor for the TLE GD GOT entry.
6279pub const R_LARCH_TLS_GD_PC_HI20: u32 = 97;
6280/// 12..=31 bits of TLS GD GOT entry 32/64-bit absolute address
6281pub const R_LARCH_TLS_GD_HI20: u32 = 98;
6282/// 32-bit PC relative
6283pub const R_LARCH_32_PCREL: u32 = 99;
6284/// Paired with a normal relocation at the same address to indicate the
6285/// instruction can be relaxed
6286pub const R_LARCH_RELAX: u32 = 100;
6287/// Reserved
6288pub const R_LARCH_DELETE: u32 = 101;
6289/// Delete some bytes to ensure the instruction at PC + A aligned to
6290/// `A.next_power_of_two()`-byte boundary
6291pub const R_LARCH_ALIGN: u32 = 102;
6292/// 22-bit PC-relative offset with two trailing zeros
6293pub const R_LARCH_PCREL20_S2: u32 = 103;
6294/// Reserved
6295pub const R_LARCH_CFA: u32 = 104;
6296/// 6-bit in-place addition
6297pub const R_LARCH_ADD6: u32 = 105;
6298/// 6-bit in-place subtraction
6299pub const R_LARCH_SUB6: u32 = 106;
6300/// LEB128 in-place addition
6301pub const R_LARCH_ADD_ULEB128: u32 = 107;
6302/// LEB128 in-place subtraction
6303pub const R_LARCH_SUB_ULEB128: u32 = 108;
6304/// 64-bit PC relative
6305pub const R_LARCH_64_PCREL: u32 = 109;
6306/// 18..=37 bits of `S + A - PC` into the `pcaddu18i` instruction at `PC`,
6307/// and 2..=17 bits of `S + A - PC` into the `jirl` instruction at `PC + 4`
6308pub const R_LARCH_CALL36: u32 = 110;
6309/// 12..=31 bits of 32/64-bit PC-relative offset to TLS DESC GOT entry
6310pub const R_LARCH_TLS_DESC_PC_HI20: u32 = 111;
6311/// 0..=11 bits of 32/64-bit TLS DESC GOT entry address
6312pub const R_LARCH_TLS_DESC_PC_LO12: u32 = 112;
6313/// 32..=51 bits of 64-bit PC-relative offset to TLS DESC GOT entry
6314pub const R_LARCH_TLS_DESC64_PC_LO20: u32 = 113;
6315/// 52..=63 bits of 64-bit PC-relative offset to TLS DESC GOT entry
6316pub const R_LARCH_TLS_DESC64_PC_HI12: u32 = 114;
6317/// 12..=31 bits of 32/64-bit TLS DESC GOT entry absolute address
6318pub const R_LARCH_TLS_DESC_HI20: u32 = 115;
6319/// 0..=11 bits of 32/64-bit TLS DESC GOT entry absolute address
6320pub const R_LARCH_TLS_DESC_LO12: u32 = 116;
6321/// 32..=51 bits of 64-bit TLS DESC GOT entry absolute address
6322pub const R_LARCH_TLS_DESC64_LO20: u32 = 117;
6323/// 52..=63 bits of 64-bit TLS DESC GOT entry absolute address
6324pub const R_LARCH_TLS_DESC64_HI12: u32 = 118;
6325/// Used on ld.{w,d} for TLS DESC to get the resolve function address
6326/// from GOT entry
6327pub const R_LARCH_TLS_DESC_LD: u32 = 119;
6328/// Used on jirl for TLS DESC to call the resolve function
6329pub const R_LARCH_TLS_DESC_CALL: u32 = 120;
6330/// 12..=31 bits of TLS LE 32/64-bit offset from TP register, can be relaxed
6331pub const R_LARCH_TLS_LE_HI20_R: u32 = 121;
6332/// TLS LE thread pointer usage, can be relaxed
6333pub const R_LARCH_TLS_LE_ADD_R: u32 = 122;
6334/// 0..=11 bits of TLS LE 32/64-bit offset from TP register, sign-extended,
6335/// can be relaxed.
6336pub const R_LARCH_TLS_LE_LO12_R: u32 = 123;
6337/// 22-bit PC-relative offset to TLS LD GOT entry
6338pub const R_LARCH_TLS_LD_PCREL20_S2: u32 = 124;
6339/// 22-bit PC-relative offset to TLS GD GOT entry
6340pub const R_LARCH_TLS_GD_PCREL20_S2: u32 = 125;
6341/// 22-bit PC-relative offset to TLS DESC GOT entry
6342pub const R_LARCH_TLS_DESC_PCREL20_S2: u32 = 126;
6343/// 12..=31 bits of `S + A - PC` into the `pcaddu12i` instruction at `PC`,
6344/// and 2..=11 bits of `S + A - PC` into the `jirl` instruction at `PC + 4`
6345pub const R_LARCH_CALL30: u32 = 127;
6346/// The signed 32-bit offset `offs` from `PC` to `(S + A + 0x800) & 0xfffff000`.
6347///
6348/// We define the *PC relative anchor* for `S + A` as `PC + offs` (`offs`
6349/// is sign-extended to VA bits).
6350pub const R_LARCH_PCADD_HI20: u32 = 128;
6351/// 0..=11 bits of the 32-bit offset from the
6352/// [PC relative anchor][R_LARCH_PCADD_HI20].
6353pub const R_LARCH_PCADD_LO12: u32 = 129;
6354/// The signed 32-bit offset `offs` from `PC` to
6355/// `(GP + G + 0x800) & 0xfffff000`.
6356///
6357/// We define the *PC relative anchor* for the GOT entry at `GP + G` as
6358/// `PC + offs` (`offs` is sign-extended to VA bits).
6359pub const R_LARCH_GOT_PCADD_HI20: u32 = 130;
6360/// 0..=11 bits of the 32-bit offset from the
6361/// [PC relative anchor][R_LARCH_GOT_PCADD_HI20] to the GOT entry.
6362pub const R_LARCH_GOT_PCADD_LO12: u32 = 131;
6363/// The signed 32-bit offset `offs` from `PC` to
6364/// `(GP + IE + 0x800) & 0xfffff000`.
6365///
6366/// We define the *PC relative anchor* for the TLS IE GOT entry at
6367/// `GP + IE` as `PC + offs` (`offs` is sign-extended to VA bits).
6368pub const R_LARCH_TLS_IE_PCADD_HI20: u32 = 132;
6369/// 0..=11 bits of the 32-bit offset from the
6370/// [PC-relative anchor][R_LARCH_TLS_IE_PCADD_HI20] to the TLS IE GOT entry.
6371pub const R_LARCH_TLS_IE_PCADD_LO12: u32 = 133;
6372/// The signed 32-bit offset `offs` from `PC` to
6373/// `(GP + GD + 0x800) & 0xfffff000`.
6374///
6375/// We define the *PC relative anchor* for the TLS LD GOT entry at
6376/// `GP + GD` as `PC + offs` (`offs` is sign-extended to VA bits).
6377pub const R_LARCH_TLS_LD_PCADD_HI20: u32 = 134;
6378/// 0..=11 bits of the 32-bit offset from the
6379/// [PC-relative anchor][R_LARCH_TLS_LD_PCADD_HI20] to the TLS LD GOT entry.
6380pub const R_LARCH_TLS_LD_PCADD_LO12: u32 = 135;
6381/// The signed 32-bit offset `offs` from `PC` to
6382/// `(GP + GD + 0x800) & 0xfffff000`.
6383///
6384/// We define the *PC relative anchor* for the TLS GD GOT entry at
6385/// `GP + GD` as `PC + offs` (`offs` is sign-extended to VA bits).
6386pub const R_LARCH_TLS_GD_PCADD_HI20: u32 = 136;
6387/// 0..=11 bits of the 32-bit offset from the
6388/// [PC-relative anchor][R_LARCH_TLS_GD_PCADD_HI20] to the TLS GD GOT entry.
6389pub const R_LARCH_TLS_GD_PCADD_LO12: u32 = 137;
6390/// The signed 32-bit offset `offs` from `PC` to
6391/// `(GP + GD + 0x800) & 0xfffff000`.
6392///
6393/// We define the *PC relative anchor* for the TLS DESC GOT entry at
6394/// `GP + GD` as `PC + offs` (`offs` is sign-extended to VA bits).
6395pub const R_LARCH_TLS_DESC_PCADD_HI20: u32 = 138;
6396/// 0..=11 bits of the 32-bit offset from the
6397/// [PC-relative anchor][R_LARCH_TLS_DESC_PCADD_HI20] to the TLS DESC GOT entry.
6398pub const R_LARCH_TLS_DESC_PCADD_LO12: u32 = 139;
6399
6400// Xtensa values Rel*::r_type`.
6401pub const R_XTENSA_NONE: u32 = 0;
6402pub const R_XTENSA_32: u32 = 1;
6403pub const R_XTENSA_RTLD: u32 = 2;
6404pub const R_XTENSA_GLOB_DAT: u32 = 3;
6405pub const R_XTENSA_JMP_SLOT: u32 = 4;
6406pub const R_XTENSA_RELATIVE: u32 = 5;
6407pub const R_XTENSA_PLT: u32 = 6;
6408pub const R_XTENSA_OP0: u32 = 8;
6409pub const R_XTENSA_OP1: u32 = 9;
6410pub const R_XTENSA_OP2: u32 = 10;
6411pub const R_XTENSA_ASM_EXPAND: u32 = 11;
6412pub const R_XTENSA_ASM_SIMPLIFY: u32 = 12;
6413pub const R_XTENSA_32_PCREL: u32 = 14;
6414pub const R_XTENSA_GNU_VTINHERIT: u32 = 15;
6415pub const R_XTENSA_GNU_VTENTRY: u32 = 16;
6416pub const R_XTENSA_DIFF8: u32 = 17;
6417pub const R_XTENSA_DIFF16: u32 = 18;
6418pub const R_XTENSA_DIFF32: u32 = 19;
6419pub const R_XTENSA_SLOT0_OP: u32 = 20;
6420pub const R_XTENSA_SLOT1_OP: u32 = 21;
6421pub const R_XTENSA_SLOT2_OP: u32 = 22;
6422pub const R_XTENSA_SLOT3_OP: u32 = 23;
6423pub const R_XTENSA_SLOT4_OP: u32 = 24;
6424pub const R_XTENSA_SLOT5_OP: u32 = 25;
6425pub const R_XTENSA_SLOT6_OP: u32 = 26;
6426pub const R_XTENSA_SLOT7_OP: u32 = 27;
6427pub const R_XTENSA_SLOT8_OP: u32 = 28;
6428pub const R_XTENSA_SLOT9_OP: u32 = 29;
6429pub const R_XTENSA_SLOT10_OP: u32 = 30;
6430pub const R_XTENSA_SLOT11_OP: u32 = 31;
6431pub const R_XTENSA_SLOT12_OP: u32 = 32;
6432pub const R_XTENSA_SLOT13_OP: u32 = 33;
6433pub const R_XTENSA_SLOT14_OP: u32 = 34;
6434pub const R_XTENSA_SLOT0_ALT: u32 = 35;
6435pub const R_XTENSA_SLOT1_ALT: u32 = 36;
6436pub const R_XTENSA_SLOT2_ALT: u32 = 37;
6437pub const R_XTENSA_SLOT3_ALT: u32 = 38;
6438pub const R_XTENSA_SLOT4_ALT: u32 = 39;
6439pub const R_XTENSA_SLOT5_ALT: u32 = 40;
6440pub const R_XTENSA_SLOT6_ALT: u32 = 41;
6441pub const R_XTENSA_SLOT7_ALT: u32 = 42;
6442pub const R_XTENSA_SLOT8_ALT: u32 = 43;
6443pub const R_XTENSA_SLOT9_ALT: u32 = 44;
6444pub const R_XTENSA_SLOT10_ALT: u32 = 45;
6445pub const R_XTENSA_SLOT11_ALT: u32 = 46;
6446pub const R_XTENSA_SLOT12_ALT: u32 = 47;
6447pub const R_XTENSA_SLOT13_ALT: u32 = 48;
6448pub const R_XTENSA_SLOT14_ALT: u32 = 49;
6449pub const R_XTENSA_TLSDESC_FN: u32 = 50;
6450pub const R_XTENSA_TLSDESC_ARG: u32 = 51;
6451pub const R_XTENSA_TLS_DTPOFF: u32 = 52;
6452pub const R_XTENSA_TLS_TPOFF: u32 = 53;
6453pub const R_XTENSA_TLS_FUNC: u32 = 54;
6454pub const R_XTENSA_TLS_ARG: u32 = 55;
6455pub const R_XTENSA_TLS_CALL: u32 = 56;
6456pub const R_XTENSA_PDIFF8: u32 = 57;
6457pub const R_XTENSA_PDIFF16: u32 = 58;
6458pub const R_XTENSA_PDIFF32: u32 = 59;
6459pub const R_XTENSA_NDIFF8: u32 = 60;
6460pub const R_XTENSA_NDIFF16: u32 = 61;
6461pub const R_XTENSA_NDIFF32: u32 = 62;
6462
6463// E2K values for `FileHeader*::e_flags`.
6464pub const EF_E2K_IPD: u32 = 3;
6465pub const EF_E2K_X86APP: u32 = 4;
6466pub const EF_E2K_4MB_PAGES: u32 = 8;
6467pub const EF_E2K_INCOMPAT: u32 = 16;
6468pub const EF_E2K_PM: u32 = 32;
6469pub const EF_E2K_PACK_SEGMENTS: u32 = 64;
6470
6471/// Encode `E_E2K_MACH_*` into `FileHeader*::e_flags`.
6472pub const fn ef_e2k_mach_to_flag(e_flags: u32, x: u32) -> u32 {
6473    (e_flags & 0xffffff) | (x << 24)
6474}
6475
6476/// Decode `E_E2K_MACH_*` from `FileHeader*::e_flags`.
6477pub const fn ef_e2k_flag_to_mach(e_flags: u32) -> u32 {
6478    e_flags >> 24
6479}
6480
6481// Codes of supported E2K machines.
6482
6483/// -march=generic code.
6484///
6485/// Legacy. Shouldn't be created nowadays.
6486pub const E_E2K_MACH_BASE: u32 = 0;
6487/// -march=elbrus-v1 code.
6488///
6489/// Legacy. Shouldn't be created nowadays.
6490pub const E_E2K_MACH_EV1: u32 = 1;
6491/// -march=elbrus-v2 code.
6492pub const E_E2K_MACH_EV2: u32 = 2;
6493/// -march=elbrus-v3 code.
6494pub const E_E2K_MACH_EV3: u32 = 3;
6495/// -march=elbrus-v4 code.
6496pub const E_E2K_MACH_EV4: u32 = 4;
6497/// -march=elbrus-v5 code.
6498pub const E_E2K_MACH_EV5: u32 = 5;
6499/// -march=elbrus-v6 code.
6500pub const E_E2K_MACH_EV6: u32 = 6;
6501/// -march=elbrus-v7 code.
6502pub const E_E2K_MACH_EV7: u32 = 7;
6503/// -mtune=elbrus-8c code.
6504pub const E_E2K_MACH_8C: u32 = 19;
6505/// -mtune=elbrus-1c+ code.
6506pub const E_E2K_MACH_1CPLUS: u32 = 20;
6507/// -mtune=elbrus-12c code.
6508pub const E_E2K_MACH_12C: u32 = 21;
6509/// -mtune=elbrus-16c code.
6510pub const E_E2K_MACH_16C: u32 = 22;
6511/// -mtune=elbrus-2c3 code.
6512pub const E_E2K_MACH_2C3: u32 = 23;
6513/// -mtune=elbrus-48c code.
6514pub const E_E2K_MACH_48C: u32 = 24;
6515/// -mtune=elbrus-8v7 code.
6516pub const E_E2K_MACH_8V7: u32 = 25;
6517
6518// E2K values `Rel*::r_type`.
6519
6520/// Direct 32 bit.
6521pub const R_E2K_32_ABS: u32 = 0;
6522/// PC relative 32 bit.
6523pub const R_E2K_32_PC: u32 = 2;
6524/// 32-bit offset of AP GOT entry.
6525pub const R_E2K_AP_GOT: u32 = 3;
6526/// 32-bit offset of PL GOT entry.
6527pub const R_E2K_PL_GOT: u32 = 4;
6528/// Create PLT entry.
6529pub const R_E2K_32_JMP_SLOT: u32 = 8;
6530/// Copy relocation, 32-bit case.
6531pub const R_E2K_32_COPY: u32 = 9;
6532/// Adjust by program base, 32-bit case.
6533pub const R_E2K_32_RELATIVE: u32 = 10;
6534/// Adjust indirectly by program base, 32-bit case.
6535pub const R_E2K_32_IRELATIVE: u32 = 11;
6536/// Size of symbol plus 32-bit addend.
6537pub const R_E2K_32_SIZE: u32 = 12;
6538/// Symbol value if resolved by the definition in the same
6539/// compilation unit or NULL otherwise, 32-bit case.
6540pub const R_E2K_32_DYNOPT: u32 = 13;
6541/// Direct 64 bit.
6542pub const R_E2K_64_ABS: u32 = 50;
6543/// Direct 64 bit for literal.
6544pub const R_E2K_64_ABS_LIT: u32 = 51;
6545/// PC relative 64 bit for literal.
6546pub const R_E2K_64_PC_LIT: u32 = 54;
6547/// Create PLT entry, 64-bit case.
6548pub const R_E2K_64_JMP_SLOT: u32 = 63;
6549/// Copy relocation, 64-bit case.
6550pub const R_E2K_64_COPY: u32 = 64;
6551/// Adjust by program base, 64-bit case.
6552pub const R_E2K_64_RELATIVE: u32 = 65;
6553/// Adjust by program base for literal, 64-bit case.
6554pub const R_E2K_64_RELATIVE_LIT: u32 = 66;
6555/// Adjust indirectly by program base, 64-bit case.
6556pub const R_E2K_64_IRELATIVE: u32 = 67;
6557/// Size of symbol plus 64-bit addend.
6558pub const R_E2K_64_SIZE: u32 = 68;
6559/// 64-bit offset of the symbol from GOT.
6560pub const R_E2K_64_GOTOFF: u32 = 69;
6561
6562/// GOT entry for ID of module containing symbol.
6563pub const R_E2K_TLS_GDMOD: u32 = 70;
6564/// GOT entry for offset in module TLS block.
6565pub const R_E2K_TLS_GDREL: u32 = 71;
6566/// Static TLS block offset GOT entry.
6567pub const R_E2K_TLS_IE: u32 = 74;
6568/// Offset relative to static TLS block, 32-bit case.
6569pub const R_E2K_32_TLS_LE: u32 = 75;
6570/// Offset relative to static TLS block, 64-bit case.
6571pub const R_E2K_64_TLS_LE: u32 = 76;
6572/// ID of module containing symbol, 32-bit case.
6573pub const R_E2K_TLS_32_DTPMOD: u32 = 80;
6574/// Offset in module TLS block, 32-bit case.
6575pub const R_E2K_TLS_32_DTPREL: u32 = 81;
6576/// ID of module containing symbol, 64-bit case.
6577pub const R_E2K_TLS_64_DTPMOD: u32 = 82;
6578/// Offset in module TLS block, 64-bit case.
6579pub const R_E2K_TLS_64_DTPREL: u32 = 83;
6580/// Offset in static TLS block, 32-bit case.
6581pub const R_E2K_TLS_32_TPREL: u32 = 84;
6582/// Offset in static TLS block, 64-bit case.
6583pub const R_E2K_TLS_64_TPREL: u32 = 85;
6584
6585/// Direct AP.
6586pub const R_E2K_AP: u32 = 100;
6587/// Direct PL.
6588pub const R_E2K_PL: u32 = 101;
6589
6590/// 32-bit offset of the symbol's entry in GOT.
6591pub const R_E2K_GOT: u32 = 108;
6592/// 32-bit offset of the symbol from GOT.
6593pub const R_E2K_GOTOFF: u32 = 109;
6594/// PC relative 28 bit for DISP.
6595pub const R_E2K_DISP: u32 = 110;
6596/// Prefetch insn line containing the label (symbol).
6597pub const R_E2K_PREF: u32 = 111;
6598/// No reloc.
6599pub const R_E2K_NONE: u32 = 112;
6600/// 32-bit offset of the symbol's entry in .got.plt.
6601pub const R_E2K_GOTPLT: u32 = 114;
6602/// Is symbol resolved locally during the link.
6603/// The result is encoded in 5-bit ALS.src1.
6604pub const R_E2K_ISLOCAL: u32 = 115;
6605/// Is symbol resloved locally during the link.
6606/// The result is encoded in a long 32-bit LTS.
6607pub const R_E2K_ISLOCAL32: u32 = 118;
6608/// The symbol's offset from GOT encoded within a 64-bit literal.
6609pub const R_E2K_64_GOTOFF_LIT: u32 = 256;
6610/// Symbol value if resolved by the definition in the same
6611/// compilation unit or NULL otherwise, 64-bit case.
6612pub const R_E2K_64_DYNOPT: u32 = 257;
6613/// PC relative 64 bit in data.
6614pub const R_E2K_64_PC: u32 = 258;
6615
6616// E2K values for `Dyn32::d_tag`.
6617
6618pub const DT_E2K_LAZY: i64 = DT_LOPROC + 1;
6619pub const DT_E2K_LAZY_GOT: i64 = DT_LOPROC + 3;
6620
6621pub const DT_E2K_INIT_GOT: i64 = DT_LOPROC + 0x101c;
6622pub const DT_E2K_EXPORT_PL: i64 = DT_LOPROC + 0x101d;
6623pub const DT_E2K_EXPORT_PLSZ: i64 = DT_LOPROC + 0x101e;
6624pub const DT_E2K_REAL_PLTGOT: i64 = DT_LOPROC + 0x101f;
6625pub const DT_E2K_NO_SELFINIT: i64 = DT_LOPROC + 0x1020;
6626
6627pub const DT_E2K_NUM: i64 = 0x1021;
6628
6629#[allow(non_upper_case_globals)]
6630pub const Tag_File: u8 = 1;
6631#[allow(non_upper_case_globals)]
6632pub const Tag_Section: u8 = 2;
6633#[allow(non_upper_case_globals)]
6634pub const Tag_Symbol: u8 = 3;
6635
6636unsafe_impl_endian_pod!(
6637    FileHeader32,
6638    FileHeader64,
6639    SectionHeader32,
6640    SectionHeader64,
6641    CompressionHeader32,
6642    CompressionHeader64,
6643    Sym32,
6644    Sym64,
6645    Syminfo32,
6646    Syminfo64,
6647    Rel32,
6648    Rel64,
6649    Rela32,
6650    Rela64,
6651    Relr32,
6652    Relr64,
6653    ProgramHeader32,
6654    ProgramHeader64,
6655    Dyn32,
6656    Dyn64,
6657    Versym,
6658    Verdef,
6659    Verdaux,
6660    Verneed,
6661    Vernaux,
6662    NoteHeader32,
6663    NoteHeader64,
6664    HashHeader,
6665    GnuHashHeader,
6666);