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