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