···11+#ifndef _UAPI_LINUX_AUXVEC_H
22+#define _UAPI_LINUX_AUXVEC_H
33+44+/* Symbolic values for the entries in the auxiliary table
55+ put on the initial stack */
66+#define AT_NULL 0 /* end of vector */
77+#define AT_IGNORE 1 /* entry should be ignored */
88+#define AT_EXECFD 2 /* file descriptor of program */
99+#define AT_PHDR 3 /* program headers for program */
1010+#define AT_PHENT 4 /* size of program header entry */
1111+#define AT_PHNUM 5 /* number of program headers */
1212+#define AT_PAGESZ 6 /* system page size */
1313+#define AT_BASE 7 /* base address of interpreter */
1414+#define AT_FLAGS 8 /* flags */
1515+#define AT_ENTRY 9 /* entry point of program */
1616+#define AT_NOTELF 10 /* program is not ELF */
1717+#define AT_UID 11 /* real uid */
1818+#define AT_EUID 12 /* effective uid */
1919+#define AT_GID 13 /* real gid */
2020+#define AT_EGID 14 /* effective gid */
2121+#define AT_PLATFORM 15 /* string identifying CPU for optimizations */
2222+#define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
2323+#define AT_CLKTCK 17 /* frequency at which times() increments */
2424+/* AT_* values 18 through 22 are reserved */
2525+#define AT_SECURE 23 /* secure mode boolean */
2626+#define AT_BASE_PLATFORM 24 /* string identifying real platform, may
2727+ * differ from AT_PLATFORM. */
2828+#define AT_RANDOM 25 /* address of 16 random bytes */
2929+#define AT_HWCAP2 26 /* extension of AT_HWCAP */
3030+3131+#define AT_EXECFN 31 /* filename of program */
3232+3333+3434+#endif /* _UAPI_LINUX_AUXVEC_H */
3535+
+3690
src/libelfloader/elf.h
···11+/* This file defines standard ELF types, structures, and macros.
22+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
33+ This file is part of the GNU C Library.
44+55+ The GNU C Library is free software; you can redistribute it and/or
66+ modify it under the terms of the GNU Lesser General Public
77+ License as published by the Free Software Foundation; either
88+ version 2.1 of the License, or (at your option) any later version.
99+1010+ The GNU C Library is distributed in the hope that it will be useful,
1111+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1212+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313+ Lesser General Public License for more details.
1414+1515+ You should have received a copy of the GNU Lesser General Public
1616+ License along with the GNU C Library; if not, see
1717+ <http://www.gnu.org/licenses/>. */
1818+1919+#ifndef _ELF_H
2020+#define _ELF_H 1
2121+2222+#include <features.h>
2323+2424+__BEGIN_DECLS
2525+2626+/* Standard ELF types. */
2727+2828+#include <stdint.h>
2929+3030+/* Type for a 16-bit quantity. */
3131+typedef uint16_t Elf32_Half;
3232+typedef uint16_t Elf64_Half;
3333+3434+/* Types for signed and unsigned 32-bit quantities. */
3535+typedef uint32_t Elf32_Word;
3636+typedef int32_t Elf32_Sword;
3737+typedef uint32_t Elf64_Word;
3838+typedef int32_t Elf64_Sword;
3939+4040+/* Types for signed and unsigned 64-bit quantities. */
4141+typedef uint64_t Elf32_Xword;
4242+typedef int64_t Elf32_Sxword;
4343+typedef uint64_t Elf64_Xword;
4444+typedef int64_t Elf64_Sxword;
4545+4646+/* Type of addresses. */
4747+typedef uint32_t Elf32_Addr;
4848+typedef uint64_t Elf64_Addr;
4949+5050+/* Type of file offsets. */
5151+typedef uint32_t Elf32_Off;
5252+typedef uint64_t Elf64_Off;
5353+5454+/* Type for section indices, which are 16-bit quantities. */
5555+typedef uint16_t Elf32_Section;
5656+typedef uint16_t Elf64_Section;
5757+5858+/* Type for version symbol information. */
5959+typedef Elf32_Half Elf32_Versym;
6060+typedef Elf64_Half Elf64_Versym;
6161+6262+6363+/* The ELF file header. This appears at the start of every ELF file. */
6464+6565+#define EI_NIDENT (16)
6666+6767+typedef struct
6868+{
6969+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
7070+ Elf32_Half e_type; /* Object file type */
7171+ Elf32_Half e_machine; /* Architecture */
7272+ Elf32_Word e_version; /* Object file version */
7373+ Elf32_Addr e_entry; /* Entry point virtual address */
7474+ Elf32_Off e_phoff; /* Program header table file offset */
7575+ Elf32_Off e_shoff; /* Section header table file offset */
7676+ Elf32_Word e_flags; /* Processor-specific flags */
7777+ Elf32_Half e_ehsize; /* ELF header size in bytes */
7878+ Elf32_Half e_phentsize; /* Program header table entry size */
7979+ Elf32_Half e_phnum; /* Program header table entry count */
8080+ Elf32_Half e_shentsize; /* Section header table entry size */
8181+ Elf32_Half e_shnum; /* Section header table entry count */
8282+ Elf32_Half e_shstrndx; /* Section header string table index */
8383+} Elf32_Ehdr;
8484+8585+typedef struct
8686+{
8787+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
8888+ Elf64_Half e_type; /* Object file type */
8989+ Elf64_Half e_machine; /* Architecture */
9090+ Elf64_Word e_version; /* Object file version */
9191+ Elf64_Addr e_entry; /* Entry point virtual address */
9292+ Elf64_Off e_phoff; /* Program header table file offset */
9393+ Elf64_Off e_shoff; /* Section header table file offset */
9494+ Elf64_Word e_flags; /* Processor-specific flags */
9595+ Elf64_Half e_ehsize; /* ELF header size in bytes */
9696+ Elf64_Half e_phentsize; /* Program header table entry size */
9797+ Elf64_Half e_phnum; /* Program header table entry count */
9898+ Elf64_Half e_shentsize; /* Section header table entry size */
9999+ Elf64_Half e_shnum; /* Section header table entry count */
100100+ Elf64_Half e_shstrndx; /* Section header string table index */
101101+} Elf64_Ehdr;
102102+103103+/* Fields in the e_ident array. The EI_* macros are indices into the
104104+ array. The macros under each EI_* macro are the values the byte
105105+ may have. */
106106+107107+#define EI_MAG0 0 /* File identification byte 0 index */
108108+#define ELFMAG0 0x7f /* Magic number byte 0 */
109109+110110+#define EI_MAG1 1 /* File identification byte 1 index */
111111+#define ELFMAG1 'E' /* Magic number byte 1 */
112112+113113+#define EI_MAG2 2 /* File identification byte 2 index */
114114+#define ELFMAG2 'L' /* Magic number byte 2 */
115115+116116+#define EI_MAG3 3 /* File identification byte 3 index */
117117+#define ELFMAG3 'F' /* Magic number byte 3 */
118118+119119+/* Conglomeration of the identification bytes, for easy testing as a word. */
120120+#define ELFMAG "\177ELF"
121121+#define SELFMAG 4
122122+123123+#define EI_CLASS 4 /* File class byte index */
124124+#define ELFCLASSNONE 0 /* Invalid class */
125125+#define ELFCLASS32 1 /* 32-bit objects */
126126+#define ELFCLASS64 2 /* 64-bit objects */
127127+#define ELFCLASSNUM 3
128128+129129+#define EI_DATA 5 /* Data encoding byte index */
130130+#define ELFDATANONE 0 /* Invalid data encoding */
131131+#define ELFDATA2LSB 1 /* 2's complement, little endian */
132132+#define ELFDATA2MSB 2 /* 2's complement, big endian */
133133+#define ELFDATANUM 3
134134+135135+#define EI_VERSION 6 /* File version byte index */
136136+ /* Value must be EV_CURRENT */
137137+138138+#define EI_OSABI 7 /* OS ABI identification */
139139+#define ELFOSABI_NONE 0 /* UNIX System V ABI */
140140+#define ELFOSABI_SYSV 0 /* Alias. */
141141+#define ELFOSABI_HPUX 1 /* HP-UX */
142142+#define ELFOSABI_NETBSD 2 /* NetBSD. */
143143+#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */
144144+#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */
145145+#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
146146+#define ELFOSABI_AIX 7 /* IBM AIX. */
147147+#define ELFOSABI_IRIX 8 /* SGI Irix. */
148148+#define ELFOSABI_FREEBSD 9 /* FreeBSD. */
149149+#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
150150+#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
151151+#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
152152+#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
153153+#define ELFOSABI_ARM 97 /* ARM */
154154+#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
155155+156156+#define EI_ABIVERSION 8 /* ABI version */
157157+158158+#define EI_PAD 9 /* Byte index of padding bytes */
159159+160160+/* Legal values for e_type (object file type). */
161161+162162+#define ET_NONE 0 /* No file type */
163163+#define ET_REL 1 /* Relocatable file */
164164+#define ET_EXEC 2 /* Executable file */
165165+#define ET_DYN 3 /* Shared object file */
166166+#define ET_CORE 4 /* Core file */
167167+#define ET_NUM 5 /* Number of defined types */
168168+#define ET_LOOS 0xfe00 /* OS-specific range start */
169169+#define ET_HIOS 0xfeff /* OS-specific range end */
170170+#define ET_LOPROC 0xff00 /* Processor-specific range start */
171171+#define ET_HIPROC 0xffff /* Processor-specific range end */
172172+173173+/* Legal values for e_machine (architecture). */
174174+175175+#define EM_NONE 0 /* No machine */
176176+#define EM_M32 1 /* AT&T WE 32100 */
177177+#define EM_SPARC 2 /* SUN SPARC */
178178+#define EM_386 3 /* Intel 80386 */
179179+#define EM_68K 4 /* Motorola m68k family */
180180+#define EM_88K 5 /* Motorola m88k family */
181181+#define EM_IAMCU 6 /* Intel MCU */
182182+#define EM_860 7 /* Intel 80860 */
183183+#define EM_MIPS 8 /* MIPS R3000 big-endian */
184184+#define EM_S370 9 /* IBM System/370 */
185185+#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
186186+ /* reserved 11-14 */
187187+#define EM_PARISC 15 /* HPPA */
188188+ /* reserved 16 */
189189+#define EM_VPP500 17 /* Fujitsu VPP500 */
190190+#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
191191+#define EM_960 19 /* Intel 80960 */
192192+#define EM_PPC 20 /* PowerPC */
193193+#define EM_PPC64 21 /* PowerPC 64-bit */
194194+#define EM_S390 22 /* IBM S390 */
195195+#define EM_SPU 23 /* IBM SPU/SPC */
196196+ /* reserved 24-35 */
197197+#define EM_V800 36 /* NEC V800 series */
198198+#define EM_FR20 37 /* Fujitsu FR20 */
199199+#define EM_RH32 38 /* TRW RH-32 */
200200+#define EM_RCE 39 /* Motorola RCE */
201201+#define EM_ARM 40 /* ARM */
202202+#define EM_FAKE_ALPHA 41 /* Digital Alpha */
203203+#define EM_SH 42 /* Hitachi SH */
204204+#define EM_SPARCV9 43 /* SPARC v9 64-bit */
205205+#define EM_TRICORE 44 /* Siemens Tricore */
206206+#define EM_ARC 45 /* Argonaut RISC Core */
207207+#define EM_H8_300 46 /* Hitachi H8/300 */
208208+#define EM_H8_300H 47 /* Hitachi H8/300H */
209209+#define EM_H8S 48 /* Hitachi H8S */
210210+#define EM_H8_500 49 /* Hitachi H8/500 */
211211+#define EM_IA_64 50 /* Intel Merced */
212212+#define EM_MIPS_X 51 /* Stanford MIPS-X */
213213+#define EM_COLDFIRE 52 /* Motorola Coldfire */
214214+#define EM_68HC12 53 /* Motorola M68HC12 */
215215+#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
216216+#define EM_PCP 55 /* Siemens PCP */
217217+#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
218218+#define EM_NDR1 57 /* Denso NDR1 microprocessor */
219219+#define EM_STARCORE 58 /* Motorola Start*Core processor */
220220+#define EM_ME16 59 /* Toyota ME16 processor */
221221+#define EM_ST100 60 /* STMicroelectronic ST100 processor */
222222+#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam */
223223+#define EM_X86_64 62 /* AMD x86-64 architecture */
224224+#define EM_PDSP 63 /* Sony DSP Processor */
225225+#define EM_PDP10 64 /* Digital PDP-10 */
226226+#define EM_PDP11 65 /* Digital PDP-11 */
227227+#define EM_FX66 66 /* Siemens FX66 microcontroller */
228228+#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
229229+#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
230230+#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
231231+#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
232232+#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
233233+#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
234234+#define EM_SVX 73 /* Silicon Graphics SVx */
235235+#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
236236+#define EM_VAX 75 /* Digital VAX */
237237+#define EM_CRIS 76 /* Axis Communications 32-bit emb.proc */
238238+#define EM_JAVELIN 77 /* Infineon Technologies 32-bit emb.proc */
239239+#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
240240+#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
241241+#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc */
242242+#define EM_HUANY 81 /* Harvard University machine-independent object files */
243243+#define EM_PRISM 82 /* SiTera Prism */
244244+#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
245245+#define EM_FR30 84 /* Fujitsu FR30 */
246246+#define EM_D10V 85 /* Mitsubishi D10V */
247247+#define EM_D30V 86 /* Mitsubishi D30V */
248248+#define EM_V850 87 /* NEC v850 */
249249+#define EM_M32R 88 /* Mitsubishi M32R */
250250+#define EM_MN10300 89 /* Matsushita MN10300 */
251251+#define EM_MN10200 90 /* Matsushita MN10200 */
252252+#define EM_PJ 91 /* picoJava */
253253+#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
254254+#define EM_ARC_COMPACT 93 /* ARC International ARCompact */
255255+#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
256256+#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore */
257257+#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Proc */
258258+#define EM_NS32K 97 /* National Semi. 32000 */
259259+#define EM_TPC 98 /* Tenor Network TPC */
260260+#define EM_SNP1K 99 /* Trebia SNP 1000 */
261261+#define EM_ST200 100 /* STMicroelectronics ST200 */
262262+#define EM_IP2K 101 /* Ubicom IP2xxx */
263263+#define EM_MAX 102 /* MAX processor */
264264+#define EM_CR 103 /* National Semi. CompactRISC */
265265+#define EM_F2MC16 104 /* Fujitsu F2MC16 */
266266+#define EM_MSP430 105 /* Texas Instruments msp430 */
267267+#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */
268268+#define EM_SE_C33 107 /* Seiko Epson S1C33 family */
269269+#define EM_SEP 108 /* Sharp embedded microprocessor */
270270+#define EM_ARCA 109 /* Arca RISC */
271271+#define EM_UNICORE 110 /* PKU-Unity & MPRC Peking Uni. mc series */
272272+#define EM_EXCESS 111 /* eXcess configurable cpu */
273273+#define EM_DXP 112 /* Icera Semi. Deep Execution Processor */
274274+#define EM_ALTERA_NIOS2 113 /* Altera Nios II */
275275+#define EM_CRX 114 /* National Semi. CompactRISC CRX */
276276+#define EM_XGATE 115 /* Motorola XGATE */
277277+#define EM_C166 116 /* Infineon C16x/XC16x */
278278+#define EM_M16C 117 /* Renesas M16C */
279279+#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F */
280280+#define EM_CE 119 /* Freescale Communication Engine RISC */
281281+#define EM_M32C 120 /* Renesas M32C */
282282+ /* reserved 121-130 */
283283+#define EM_TSK3000 131 /* Altium TSK3000 */
284284+#define EM_RS08 132 /* Freescale RS08 */
285285+#define EM_SHARC 133 /* Analog Devices SHARC family */
286286+#define EM_ECOG2 134 /* Cyan Technology eCOG2 */
287287+#define EM_SCORE7 135 /* Sunplus S+core7 RISC */
288288+#define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP */
289289+#define EM_VIDEOCORE3 137 /* Broadcom VideoCore III */
290290+#define EM_LATTICEMICO32 138 /* RISC for Lattice FPGA */
291291+#define EM_SE_C17 139 /* Seiko Epson C17 */
292292+#define EM_TI_C6000 140 /* Texas Instruments TMS320C6000 DSP */
293293+#define EM_TI_C2000 141 /* Texas Instruments TMS320C2000 DSP */
294294+#define EM_TI_C5500 142 /* Texas Instruments TMS320C55x DSP */
295295+#define EM_TI_ARP32 143 /* Texas Instruments App. Specific RISC */
296296+#define EM_TI_PRU 144 /* Texas Instruments Prog. Realtime Unit */
297297+ /* reserved 145-159 */
298298+#define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW DSP */
299299+#define EM_CYPRESS_M8C 161 /* Cypress M8C */
300300+#define EM_R32C 162 /* Renesas R32C */
301301+#define EM_TRIMEDIA 163 /* NXP Semi. TriMedia */
302302+#define EM_QDSP6 164 /* QUALCOMM DSP6 */
303303+#define EM_8051 165 /* Intel 8051 and variants */
304304+#define EM_STXP7X 166 /* STMicroelectronics STxP7x */
305305+#define EM_NDS32 167 /* Andes Tech. compact code emb. RISC */
306306+#define EM_ECOG1X 168 /* Cyan Technology eCOG1X */
307307+#define EM_MAXQ30 169 /* Dallas Semi. MAXQ30 mc */
308308+#define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP */
309309+#define EM_MANIK 171 /* M2000 Reconfigurable RISC */
310310+#define EM_CRAYNV2 172 /* Cray NV2 vector architecture */
311311+#define EM_RX 173 /* Renesas RX */
312312+#define EM_METAG 174 /* Imagination Tech. META */
313313+#define EM_MCST_ELBRUS 175 /* MCST Elbrus */
314314+#define EM_ECOG16 176 /* Cyan Technology eCOG16 */
315315+#define EM_CR16 177 /* National Semi. CompactRISC CR16 */
316316+#define EM_ETPU 178 /* Freescale Extended Time Processing Unit */
317317+#define EM_SLE9X 179 /* Infineon Tech. SLE9X */
318318+#define EM_L10M 180 /* Intel L10M */
319319+#define EM_K10M 181 /* Intel K10M */
320320+ /* reserved 182 */
321321+#define EM_AARCH64 183 /* ARM AARCH64 */
322322+ /* reserved 184 */
323323+#define EM_AVR32 185 /* Amtel 32-bit microprocessor */
324324+#define EM_STM8 186 /* STMicroelectronics STM8 */
325325+#define EM_TILE64 187 /* Tileta TILE64 */
326326+#define EM_TILEPRO 188 /* Tilera TILEPro */
327327+#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */
328328+#define EM_CUDA 190 /* NVIDIA CUDA */
329329+#define EM_TILEGX 191 /* Tilera TILE-Gx */
330330+#define EM_CLOUDSHIELD 192 /* CloudShield */
331331+#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st gen. */
332332+#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd gen. */
333333+#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */
334334+#define EM_OPEN8 196 /* Open8 RISC */
335335+#define EM_RL78 197 /* Renesas RL78 */
336336+#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V */
337337+#define EM_78KOR 199 /* Renesas 78KOR */
338338+#define EM_56800EX 200 /* Freescale 56800EX DSC */
339339+#define EM_BA1 201 /* Beyond BA1 */
340340+#define EM_BA2 202 /* Beyond BA2 */
341341+#define EM_XCORE 203 /* XMOS xCORE */
342342+#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) */
343343+ /* reserved 205-209 */
344344+#define EM_KM32 210 /* KM211 KM32 */
345345+#define EM_KMX32 211 /* KM211 KMX32 */
346346+#define EM_EMX16 212 /* KM211 KMX16 */
347347+#define EM_EMX8 213 /* KM211 KMX8 */
348348+#define EM_KVARC 214 /* KM211 KVARC */
349349+#define EM_CDP 215 /* Paneve CDP */
350350+#define EM_COGE 216 /* Cognitive Smart Memory Processor */
351351+#define EM_COOL 217 /* Bluechip CoolEngine */
352352+#define EM_NORC 218 /* Nanoradio Optimized RISC */
353353+#define EM_CSR_KALIMBA 219 /* CSR Kalimba */
354354+#define EM_Z80 220 /* Zilog Z80 */
355355+#define EM_VISIUM 221 /* Controls and Data Services VISIUMcore */
356356+#define EM_FT32 222 /* FTDI Chip FT32 */
357357+#define EM_MOXIE 223 /* Moxie processor */
358358+#define EM_AMDGPU 224 /* AMD GPU */
359359+ /* reserved 225-242 */
360360+#define EM_RISCV 243 /* RISC-V */
361361+362362+#define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */
363363+364364+#define EM_NUM 248
365365+366366+/* Old spellings/synonyms. */
367367+368368+#define EM_ARC_A5 EM_ARC_COMPACT
369369+370370+/* If it is necessary to assign new unofficial EM_* values, please
371371+ pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
372372+ chances of collision with official or non-GNU unofficial values. */
373373+374374+#define EM_ALPHA 0x9026
375375+376376+/* Legal values for e_version (version). */
377377+378378+#define EV_NONE 0 /* Invalid ELF version */
379379+#define EV_CURRENT 1 /* Current version */
380380+#define EV_NUM 2
381381+382382+/* Section header. */
383383+384384+typedef struct
385385+{
386386+ Elf32_Word sh_name; /* Section name (string tbl index) */
387387+ Elf32_Word sh_type; /* Section type */
388388+ Elf32_Word sh_flags; /* Section flags */
389389+ Elf32_Addr sh_addr; /* Section virtual addr at execution */
390390+ Elf32_Off sh_offset; /* Section file offset */
391391+ Elf32_Word sh_size; /* Section size in bytes */
392392+ Elf32_Word sh_link; /* Link to another section */
393393+ Elf32_Word sh_info; /* Additional section information */
394394+ Elf32_Word sh_addralign; /* Section alignment */
395395+ Elf32_Word sh_entsize; /* Entry size if section holds table */
396396+} Elf32_Shdr;
397397+398398+typedef struct
399399+{
400400+ Elf64_Word sh_name; /* Section name (string tbl index) */
401401+ Elf64_Word sh_type; /* Section type */
402402+ Elf64_Xword sh_flags; /* Section flags */
403403+ Elf64_Addr sh_addr; /* Section virtual addr at execution */
404404+ Elf64_Off sh_offset; /* Section file offset */
405405+ Elf64_Xword sh_size; /* Section size in bytes */
406406+ Elf64_Word sh_link; /* Link to another section */
407407+ Elf64_Word sh_info; /* Additional section information */
408408+ Elf64_Xword sh_addralign; /* Section alignment */
409409+ Elf64_Xword sh_entsize; /* Entry size if section holds table */
410410+} Elf64_Shdr;
411411+412412+/* Special section indices. */
413413+414414+#define SHN_UNDEF 0 /* Undefined section */
415415+#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
416416+#define SHN_LOPROC 0xff00 /* Start of processor-specific */
417417+#define SHN_BEFORE 0xff00 /* Order section before all others
418418+ (Solaris). */
419419+#define SHN_AFTER 0xff01 /* Order section after all others
420420+ (Solaris). */
421421+#define SHN_HIPROC 0xff1f /* End of processor-specific */
422422+#define SHN_LOOS 0xff20 /* Start of OS-specific */
423423+#define SHN_HIOS 0xff3f /* End of OS-specific */
424424+#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
425425+#define SHN_COMMON 0xfff2 /* Associated symbol is common */
426426+#define SHN_XINDEX 0xffff /* Index is in extra table. */
427427+#define SHN_HIRESERVE 0xffff /* End of reserved indices */
428428+429429+/* Legal values for sh_type (section type). */
430430+431431+#define SHT_NULL 0 /* Section header table entry unused */
432432+#define SHT_PROGBITS 1 /* Program data */
433433+#define SHT_SYMTAB 2 /* Symbol table */
434434+#define SHT_STRTAB 3 /* String table */
435435+#define SHT_RELA 4 /* Relocation entries with addends */
436436+#define SHT_HASH 5 /* Symbol hash table */
437437+#define SHT_DYNAMIC 6 /* Dynamic linking information */
438438+#define SHT_NOTE 7 /* Notes */
439439+#define SHT_NOBITS 8 /* Program space with no data (bss) */
440440+#define SHT_REL 9 /* Relocation entries, no addends */
441441+#define SHT_SHLIB 10 /* Reserved */
442442+#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
443443+#define SHT_INIT_ARRAY 14 /* Array of constructors */
444444+#define SHT_FINI_ARRAY 15 /* Array of destructors */
445445+#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
446446+#define SHT_GROUP 17 /* Section group */
447447+#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
448448+#define SHT_NUM 19 /* Number of defined types. */
449449+#define SHT_LOOS 0x60000000 /* Start OS-specific. */
450450+#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */
451451+#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
452452+#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
453453+#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
454454+#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
455455+#define SHT_SUNW_move 0x6ffffffa
456456+#define SHT_SUNW_COMDAT 0x6ffffffb
457457+#define SHT_SUNW_syminfo 0x6ffffffc
458458+#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
459459+#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
460460+#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
461461+#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
462462+#define SHT_HIOS 0x6fffffff /* End OS-specific type */
463463+#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
464464+#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
465465+#define SHT_LOUSER 0x80000000 /* Start of application-specific */
466466+#define SHT_HIUSER 0x8fffffff /* End of application-specific */
467467+468468+/* Legal values for sh_flags (section flags). */
469469+470470+#define SHF_WRITE (1 << 0) /* Writable */
471471+#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
472472+#define SHF_EXECINSTR (1 << 2) /* Executable */
473473+#define SHF_MERGE (1 << 4) /* Might be merged */
474474+#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
475475+#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
476476+#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
477477+#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
478478+ required */
479479+#define SHF_GROUP (1 << 9) /* Section is member of a group. */
480480+#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
481481+#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */
482482+#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
483483+#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
484484+#define SHF_ORDERED (1 << 30) /* Special ordering requirement
485485+ (Solaris). */
486486+#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless
487487+ referenced or allocated (Solaris).*/
488488+489489+/* Section compression header. Used when SHF_COMPRESSED is set. */
490490+491491+typedef struct
492492+{
493493+ Elf32_Word ch_type; /* Compression format. */
494494+ Elf32_Word ch_size; /* Uncompressed data size. */
495495+ Elf32_Word ch_addralign; /* Uncompressed data alignment. */
496496+} Elf32_Chdr;
497497+498498+typedef struct
499499+{
500500+ Elf64_Word ch_type; /* Compression format. */
501501+ Elf64_Word ch_reserved;
502502+ Elf64_Xword ch_size; /* Uncompressed data size. */
503503+ Elf64_Xword ch_addralign; /* Uncompressed data alignment. */
504504+} Elf64_Chdr;
505505+506506+/* Legal values for ch_type (compression algorithm). */
507507+#define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE algorithm. */
508508+#define ELFCOMPRESS_LOOS 0x60000000 /* Start of OS-specific. */
509509+#define ELFCOMPRESS_HIOS 0x6fffffff /* End of OS-specific. */
510510+#define ELFCOMPRESS_LOPROC 0x70000000 /* Start of processor-specific. */
511511+#define ELFCOMPRESS_HIPROC 0x7fffffff /* End of processor-specific. */
512512+513513+/* Section group handling. */
514514+#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
515515+516516+/* Symbol table entry. */
517517+518518+typedef struct
519519+{
520520+ Elf32_Word st_name; /* Symbol name (string tbl index) */
521521+ Elf32_Addr st_value; /* Symbol value */
522522+ Elf32_Word st_size; /* Symbol size */
523523+ unsigned char st_info; /* Symbol type and binding */
524524+ unsigned char st_other; /* Symbol visibility */
525525+ Elf32_Section st_shndx; /* Section index */
526526+} Elf32_Sym;
527527+528528+typedef struct
529529+{
530530+ Elf64_Word st_name; /* Symbol name (string tbl index) */
531531+ unsigned char st_info; /* Symbol type and binding */
532532+ unsigned char st_other; /* Symbol visibility */
533533+ Elf64_Section st_shndx; /* Section index */
534534+ Elf64_Addr st_value; /* Symbol value */
535535+ Elf64_Xword st_size; /* Symbol size */
536536+} Elf64_Sym;
537537+538538+/* The syminfo section if available contains additional information about
539539+ every dynamic symbol. */
540540+541541+typedef struct
542542+{
543543+ Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
544544+ Elf32_Half si_flags; /* Per symbol flags */
545545+} Elf32_Syminfo;
546546+547547+typedef struct
548548+{
549549+ Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
550550+ Elf64_Half si_flags; /* Per symbol flags */
551551+} Elf64_Syminfo;
552552+553553+/* Possible values for si_boundto. */
554554+#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
555555+#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
556556+#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
557557+558558+/* Possible bitmasks for si_flags. */
559559+#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
560560+#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
561561+#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
562562+#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
563563+ loaded */
564564+/* Syminfo version values. */
565565+#define SYMINFO_NONE 0
566566+#define SYMINFO_CURRENT 1
567567+#define SYMINFO_NUM 2
568568+569569+570570+/* How to extract and insert information held in the st_info field. */
571571+572572+#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
573573+#define ELF32_ST_TYPE(val) ((val) & 0xf)
574574+#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
575575+576576+/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
577577+#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
578578+#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
579579+#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
580580+581581+/* Legal values for ST_BIND subfield of st_info (symbol binding). */
582582+583583+#define STB_LOCAL 0 /* Local symbol */
584584+#define STB_GLOBAL 1 /* Global symbol */
585585+#define STB_WEAK 2 /* Weak symbol */
586586+#define STB_NUM 3 /* Number of defined types. */
587587+#define STB_LOOS 10 /* Start of OS-specific */
588588+#define STB_GNU_UNIQUE 10 /* Unique symbol. */
589589+#define STB_HIOS 12 /* End of OS-specific */
590590+#define STB_LOPROC 13 /* Start of processor-specific */
591591+#define STB_HIPROC 15 /* End of processor-specific */
592592+593593+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
594594+595595+#define STT_NOTYPE 0 /* Symbol type is unspecified */
596596+#define STT_OBJECT 1 /* Symbol is a data object */
597597+#define STT_FUNC 2 /* Symbol is a code object */
598598+#define STT_SECTION 3 /* Symbol associated with a section */
599599+#define STT_FILE 4 /* Symbol's name is file name */
600600+#define STT_COMMON 5 /* Symbol is a common data object */
601601+#define STT_TLS 6 /* Symbol is thread-local data object*/
602602+#define STT_NUM 7 /* Number of defined types. */
603603+#define STT_LOOS 10 /* Start of OS-specific */
604604+#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */
605605+#define STT_HIOS 12 /* End of OS-specific */
606606+#define STT_LOPROC 13 /* Start of processor-specific */
607607+#define STT_HIPROC 15 /* End of processor-specific */
608608+609609+610610+/* Symbol table indices are found in the hash buckets and chain table
611611+ of a symbol hash table section. This special index value indicates
612612+ the end of a chain, meaning no further symbols are found in that bucket. */
613613+614614+#define STN_UNDEF 0 /* End of a chain. */
615615+616616+617617+/* How to extract and insert information held in the st_other field. */
618618+619619+#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
620620+621621+/* For ELF64 the definitions are the same. */
622622+#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
623623+624624+/* Symbol visibility specification encoded in the st_other field. */
625625+#define STV_DEFAULT 0 /* Default symbol visibility rules */
626626+#define STV_INTERNAL 1 /* Processor specific hidden class */
627627+#define STV_HIDDEN 2 /* Sym unavailable in other modules */
628628+#define STV_PROTECTED 3 /* Not preemptible, not exported */
629629+630630+631631+/* Relocation table entry without addend (in section of type SHT_REL). */
632632+633633+typedef struct
634634+{
635635+ Elf32_Addr r_offset; /* Address */
636636+ Elf32_Word r_info; /* Relocation type and symbol index */
637637+} Elf32_Rel;
638638+639639+/* I have seen two different definitions of the Elf64_Rel and
640640+ Elf64_Rela structures, so we'll leave them out until Novell (or
641641+ whoever) gets their act together. */
642642+/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
643643+644644+typedef struct
645645+{
646646+ Elf64_Addr r_offset; /* Address */
647647+ Elf64_Xword r_info; /* Relocation type and symbol index */
648648+} Elf64_Rel;
649649+650650+/* Relocation table entry with addend (in section of type SHT_RELA). */
651651+652652+typedef struct
653653+{
654654+ Elf32_Addr r_offset; /* Address */
655655+ Elf32_Word r_info; /* Relocation type and symbol index */
656656+ Elf32_Sword r_addend; /* Addend */
657657+} Elf32_Rela;
658658+659659+typedef struct
660660+{
661661+ Elf64_Addr r_offset; /* Address */
662662+ Elf64_Xword r_info; /* Relocation type and symbol index */
663663+ Elf64_Sxword r_addend; /* Addend */
664664+} Elf64_Rela;
665665+666666+/* How to extract and insert information held in the r_info field. */
667667+668668+#define ELF32_R_SYM(val) ((val) >> 8)
669669+#define ELF32_R_TYPE(val) ((val) & 0xff)
670670+#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
671671+672672+#define ELF64_R_SYM(i) ((i) >> 32)
673673+#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
674674+#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
675675+676676+/* Program segment header. */
677677+678678+typedef struct
679679+{
680680+ Elf32_Word p_type; /* Segment type */
681681+ Elf32_Off p_offset; /* Segment file offset */
682682+ Elf32_Addr p_vaddr; /* Segment virtual address */
683683+ Elf32_Addr p_paddr; /* Segment physical address */
684684+ Elf32_Word p_filesz; /* Segment size in file */
685685+ Elf32_Word p_memsz; /* Segment size in memory */
686686+ Elf32_Word p_flags; /* Segment flags */
687687+ Elf32_Word p_align; /* Segment alignment */
688688+} Elf32_Phdr;
689689+690690+typedef struct
691691+{
692692+ Elf64_Word p_type; /* Segment type */
693693+ Elf64_Word p_flags; /* Segment flags */
694694+ Elf64_Off p_offset; /* Segment file offset */
695695+ Elf64_Addr p_vaddr; /* Segment virtual address */
696696+ Elf64_Addr p_paddr; /* Segment physical address */
697697+ Elf64_Xword p_filesz; /* Segment size in file */
698698+ Elf64_Xword p_memsz; /* Segment size in memory */
699699+ Elf64_Xword p_align; /* Segment alignment */
700700+} Elf64_Phdr;
701701+702702+/* Special value for e_phnum. This indicates that the real number of
703703+ program headers is too large to fit into e_phnum. Instead the real
704704+ value is in the field sh_info of section 0. */
705705+706706+#define PN_XNUM 0xffff
707707+708708+/* Legal values for p_type (segment type). */
709709+710710+#define PT_NULL 0 /* Program header table entry unused */
711711+#define PT_LOAD 1 /* Loadable program segment */
712712+#define PT_DYNAMIC 2 /* Dynamic linking information */
713713+#define PT_INTERP 3 /* Program interpreter */
714714+#define PT_NOTE 4 /* Auxiliary information */
715715+#define PT_SHLIB 5 /* Reserved */
716716+#define PT_PHDR 6 /* Entry for header table itself */
717717+#define PT_TLS 7 /* Thread-local storage segment */
718718+#define PT_NUM 8 /* Number of defined types */
719719+#define PT_LOOS 0x60000000 /* Start of OS-specific */
720720+#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
721721+#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
722722+#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
723723+#define PT_LOSUNW 0x6ffffffa
724724+#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
725725+#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
726726+#define PT_HISUNW 0x6fffffff
727727+#define PT_HIOS 0x6fffffff /* End of OS-specific */
728728+#define PT_LOPROC 0x70000000 /* Start of processor-specific */
729729+#define PT_HIPROC 0x7fffffff /* End of processor-specific */
730730+731731+/* Legal values for p_flags (segment flags). */
732732+733733+#define PF_X (1 << 0) /* Segment is executable */
734734+#define PF_W (1 << 1) /* Segment is writable */
735735+#define PF_R (1 << 2) /* Segment is readable */
736736+#define PF_MASKOS 0x0ff00000 /* OS-specific */
737737+#define PF_MASKPROC 0xf0000000 /* Processor-specific */
738738+739739+/* Legal values for note segment descriptor types for core files. */
740740+741741+#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
742742+#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
743743+#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
744744+#define NT_PRXREG 4 /* Contains copy of prxregset struct */
745745+#define NT_TASKSTRUCT 4 /* Contains copy of task structure */
746746+#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
747747+#define NT_AUXV 6 /* Contains copy of auxv array */
748748+#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
749749+#define NT_ASRS 8 /* Contains copy of asrset struct */
750750+#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
751751+#define NT_PSINFO 13 /* Contains copy of psinfo struct */
752752+#define NT_PRCRED 14 /* Contains copy of prcred struct */
753753+#define NT_UTSNAME 15 /* Contains copy of utsname struct */
754754+#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
755755+#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
756756+#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */
757757+#define NT_SIGINFO 0x53494749 /* Contains copy of siginfo_t,
758758+ size might increase */
759759+#define NT_FILE 0x46494c45 /* Contains information about mapped
760760+ files */
761761+#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */
762762+#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
763763+#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
764764+#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
765765+#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
766766+#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
767767+#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
768768+#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */
769769+#define NT_S390_TIMER 0x301 /* s390 timer register */
770770+#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */
771771+#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */
772772+#define NT_S390_CTRS 0x304 /* s390 control registers */
773773+#define NT_S390_PREFIX 0x305 /* s390 prefix register */
774774+#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */
775775+#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */
776776+#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */
777777+#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */
778778+#define NT_ARM_TLS 0x401 /* ARM TLS register */
779779+#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */
780780+#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */
781781+#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */
782782+783783+/* Legal values for the note segment descriptor types for object files. */
784784+785785+#define NT_VERSION 1 /* Contains a version string. */
786786+787787+788788+/* Dynamic section entry. */
789789+790790+typedef struct
791791+{
792792+ Elf32_Sword d_tag; /* Dynamic entry type */
793793+ union
794794+ {
795795+ Elf32_Word d_val; /* Integer value */
796796+ Elf32_Addr d_ptr; /* Address value */
797797+ } d_un;
798798+} Elf32_Dyn;
799799+800800+typedef struct
801801+{
802802+ Elf64_Sxword d_tag; /* Dynamic entry type */
803803+ union
804804+ {
805805+ Elf64_Xword d_val; /* Integer value */
806806+ Elf64_Addr d_ptr; /* Address value */
807807+ } d_un;
808808+} Elf64_Dyn;
809809+810810+/* Legal values for d_tag (dynamic entry type). */
811811+812812+#define DT_NULL 0 /* Marks end of dynamic section */
813813+#define DT_NEEDED 1 /* Name of needed library */
814814+#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
815815+#define DT_PLTGOT 3 /* Processor defined value */
816816+#define DT_HASH 4 /* Address of symbol hash table */
817817+#define DT_STRTAB 5 /* Address of string table */
818818+#define DT_SYMTAB 6 /* Address of symbol table */
819819+#define DT_RELA 7 /* Address of Rela relocs */
820820+#define DT_RELASZ 8 /* Total size of Rela relocs */
821821+#define DT_RELAENT 9 /* Size of one Rela reloc */
822822+#define DT_STRSZ 10 /* Size of string table */
823823+#define DT_SYMENT 11 /* Size of one symbol table entry */
824824+#define DT_INIT 12 /* Address of init function */
825825+#define DT_FINI 13 /* Address of termination function */
826826+#define DT_SONAME 14 /* Name of shared object */
827827+#define DT_RPATH 15 /* Library search path (deprecated) */
828828+#define DT_SYMBOLIC 16 /* Start symbol search here */
829829+#define DT_REL 17 /* Address of Rel relocs */
830830+#define DT_RELSZ 18 /* Total size of Rel relocs */
831831+#define DT_RELENT 19 /* Size of one Rel reloc */
832832+#define DT_PLTREL 20 /* Type of reloc in PLT */
833833+#define DT_DEBUG 21 /* For debugging; unspecified */
834834+#define DT_TEXTREL 22 /* Reloc might modify .text */
835835+#define DT_JMPREL 23 /* Address of PLT relocs */
836836+#define DT_BIND_NOW 24 /* Process relocations of object */
837837+#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
838838+#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
839839+#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
840840+#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
841841+#define DT_RUNPATH 29 /* Library search path */
842842+#define DT_FLAGS 30 /* Flags for the object being loaded */
843843+#define DT_ENCODING 32 /* Start of encoded range */
844844+#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
845845+#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
846846+#define DT_NUM 34 /* Number used */
847847+#define DT_LOOS 0x6000000d /* Start of OS-specific */
848848+#define DT_HIOS 0x6ffff000 /* End of OS-specific */
849849+#define DT_LOPROC 0x70000000 /* Start of processor-specific */
850850+#define DT_HIPROC 0x7fffffff /* End of processor-specific */
851851+#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
852852+853853+/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
854854+ Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
855855+ approach. */
856856+#define DT_VALRNGLO 0x6ffffd00
857857+#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
858858+#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
859859+#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
860860+#define DT_CHECKSUM 0x6ffffdf8
861861+#define DT_PLTPADSZ 0x6ffffdf9
862862+#define DT_MOVEENT 0x6ffffdfa
863863+#define DT_MOVESZ 0x6ffffdfb
864864+#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
865865+#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
866866+ the following DT_* entry. */
867867+#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
868868+#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
869869+#define DT_VALRNGHI 0x6ffffdff
870870+#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
871871+#define DT_VALNUM 12
872872+873873+/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
874874+ Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
875875+876876+ If any adjustment is made to the ELF object after it has been
877877+ built these entries will need to be adjusted. */
878878+#define DT_ADDRRNGLO 0x6ffffe00
879879+#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */
880880+#define DT_TLSDESC_PLT 0x6ffffef6
881881+#define DT_TLSDESC_GOT 0x6ffffef7
882882+#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
883883+#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
884884+#define DT_CONFIG 0x6ffffefa /* Configuration information. */
885885+#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
886886+#define DT_AUDIT 0x6ffffefc /* Object auditing. */
887887+#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
888888+#define DT_MOVETAB 0x6ffffefe /* Move table. */
889889+#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
890890+#define DT_ADDRRNGHI 0x6ffffeff
891891+#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
892892+#define DT_ADDRNUM 11
893893+894894+/* The versioning entry types. The next are defined as part of the
895895+ GNU extension. */
896896+#define DT_VERSYM 0x6ffffff0
897897+898898+#define DT_RELACOUNT 0x6ffffff9
899899+#define DT_RELCOUNT 0x6ffffffa
900900+901901+/* These were chosen by Sun. */
902902+#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
903903+#define DT_VERDEF 0x6ffffffc /* Address of version definition
904904+ table */
905905+#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
906906+#define DT_VERNEED 0x6ffffffe /* Address of table with needed
907907+ versions */
908908+#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
909909+#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
910910+#define DT_VERSIONTAGNUM 16
911911+912912+/* Sun added these machine-independent extensions in the "processor-specific"
913913+ range. Be compatible. */
914914+#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
915915+#define DT_FILTER 0x7fffffff /* Shared object to get values from */
916916+#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
917917+#define DT_EXTRANUM 3
918918+919919+/* Values of `d_un.d_val' in the DT_FLAGS entry. */
920920+#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
921921+#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
922922+#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
923923+#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
924924+#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
925925+926926+/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
927927+ entry in the dynamic section. */
928928+#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
929929+#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
930930+#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
931931+#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
932932+#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
933933+#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
934934+#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
935935+#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
936936+#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
937937+#define DF_1_TRANS 0x00000200
938938+#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
939939+#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
940940+#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
941941+#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
942942+#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
943943+#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
944944+#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
945945+#define DF_1_NODIRECT 0x00020000 /* Object has no-direct binding. */
946946+#define DF_1_IGNMULDEF 0x00040000
947947+#define DF_1_NOKSYMS 0x00080000
948948+#define DF_1_NOHDR 0x00100000
949949+#define DF_1_EDITED 0x00200000 /* Object is modified after built. */
950950+#define DF_1_NORELOC 0x00400000
951951+#define DF_1_SYMINTPOSE 0x00800000 /* Object has individual interposers. */
952952+#define DF_1_GLOBAUDIT 0x01000000 /* Global auditing required. */
953953+#define DF_1_SINGLETON 0x02000000 /* Singleton symbols are used. */
954954+955955+/* Flags for the feature selection in DT_FEATURE_1. */
956956+#define DTF_1_PARINIT 0x00000001
957957+#define DTF_1_CONFEXP 0x00000002
958958+959959+/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
960960+#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
961961+#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
962962+ generally available. */
963963+964964+/* Version definition sections. */
965965+966966+typedef struct
967967+{
968968+ Elf32_Half vd_version; /* Version revision */
969969+ Elf32_Half vd_flags; /* Version information */
970970+ Elf32_Half vd_ndx; /* Version Index */
971971+ Elf32_Half vd_cnt; /* Number of associated aux entries */
972972+ Elf32_Word vd_hash; /* Version name hash value */
973973+ Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
974974+ Elf32_Word vd_next; /* Offset in bytes to next verdef
975975+ entry */
976976+} Elf32_Verdef;
977977+978978+typedef struct
979979+{
980980+ Elf64_Half vd_version; /* Version revision */
981981+ Elf64_Half vd_flags; /* Version information */
982982+ Elf64_Half vd_ndx; /* Version Index */
983983+ Elf64_Half vd_cnt; /* Number of associated aux entries */
984984+ Elf64_Word vd_hash; /* Version name hash value */
985985+ Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
986986+ Elf64_Word vd_next; /* Offset in bytes to next verdef
987987+ entry */
988988+} Elf64_Verdef;
989989+990990+991991+/* Legal values for vd_version (version revision). */
992992+#define VER_DEF_NONE 0 /* No version */
993993+#define VER_DEF_CURRENT 1 /* Current version */
994994+#define VER_DEF_NUM 2 /* Given version number */
995995+996996+/* Legal values for vd_flags (version information flags). */
997997+#define VER_FLG_BASE 0x1 /* Version definition of file itself */
998998+#define VER_FLG_WEAK 0x2 /* Weak version identifier */
999999+10001000+/* Versym symbol index values. */
10011001+#define VER_NDX_LOCAL 0 /* Symbol is local. */
10021002+#define VER_NDX_GLOBAL 1 /* Symbol is global. */
10031003+#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
10041004+#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
10051005+10061006+/* Auxialiary version information. */
10071007+10081008+typedef struct
10091009+{
10101010+ Elf32_Word vda_name; /* Version or dependency names */
10111011+ Elf32_Word vda_next; /* Offset in bytes to next verdaux
10121012+ entry */
10131013+} Elf32_Verdaux;
10141014+10151015+typedef struct
10161016+{
10171017+ Elf64_Word vda_name; /* Version or dependency names */
10181018+ Elf64_Word vda_next; /* Offset in bytes to next verdaux
10191019+ entry */
10201020+} Elf64_Verdaux;
10211021+10221022+10231023+/* Version dependency section. */
10241024+10251025+typedef struct
10261026+{
10271027+ Elf32_Half vn_version; /* Version of structure */
10281028+ Elf32_Half vn_cnt; /* Number of associated aux entries */
10291029+ Elf32_Word vn_file; /* Offset of filename for this
10301030+ dependency */
10311031+ Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
10321032+ Elf32_Word vn_next; /* Offset in bytes to next verneed
10331033+ entry */
10341034+} Elf32_Verneed;
10351035+10361036+typedef struct
10371037+{
10381038+ Elf64_Half vn_version; /* Version of structure */
10391039+ Elf64_Half vn_cnt; /* Number of associated aux entries */
10401040+ Elf64_Word vn_file; /* Offset of filename for this
10411041+ dependency */
10421042+ Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
10431043+ Elf64_Word vn_next; /* Offset in bytes to next verneed
10441044+ entry */
10451045+} Elf64_Verneed;
10461046+10471047+10481048+/* Legal values for vn_version (version revision). */
10491049+#define VER_NEED_NONE 0 /* No version */
10501050+#define VER_NEED_CURRENT 1 /* Current version */
10511051+#define VER_NEED_NUM 2 /* Given version number */
10521052+10531053+/* Auxiliary needed version information. */
10541054+10551055+typedef struct
10561056+{
10571057+ Elf32_Word vna_hash; /* Hash value of dependency name */
10581058+ Elf32_Half vna_flags; /* Dependency specific information */
10591059+ Elf32_Half vna_other; /* Unused */
10601060+ Elf32_Word vna_name; /* Dependency name string offset */
10611061+ Elf32_Word vna_next; /* Offset in bytes to next vernaux
10621062+ entry */
10631063+} Elf32_Vernaux;
10641064+10651065+typedef struct
10661066+{
10671067+ Elf64_Word vna_hash; /* Hash value of dependency name */
10681068+ Elf64_Half vna_flags; /* Dependency specific information */
10691069+ Elf64_Half vna_other; /* Unused */
10701070+ Elf64_Word vna_name; /* Dependency name string offset */
10711071+ Elf64_Word vna_next; /* Offset in bytes to next vernaux
10721072+ entry */
10731073+} Elf64_Vernaux;
10741074+10751075+10761076+/* Legal values for vna_flags. */
10771077+#define VER_FLG_WEAK 0x2 /* Weak version identifier */
10781078+10791079+10801080+/* Auxiliary vector. */
10811081+10821082+/* This vector is normally only used by the program interpreter. The
10831083+ usual definition in an ABI supplement uses the name auxv_t. The
10841084+ vector is not usually defined in a standard <elf.h> file, but it
10851085+ can't hurt. We rename it to avoid conflicts. The sizes of these
10861086+ types are an arrangement between the exec server and the program
10871087+ interpreter, so we don't fully specify them here. */
10881088+10891089+typedef struct
10901090+{
10911091+ uint32_t a_type; /* Entry type */
10921092+ union
10931093+ {
10941094+ uint32_t a_val; /* Integer value */
10951095+ /* We use to have pointer elements added here. We cannot do that,
10961096+ though, since it does not work when using 32-bit definitions
10971097+ on 64-bit platforms and vice versa. */
10981098+ } a_un;
10991099+} Elf32_auxv_t;
11001100+11011101+typedef struct
11021102+{
11031103+ uint64_t a_type; /* Entry type */
11041104+ union
11051105+ {
11061106+ uint64_t a_val; /* Integer value */
11071107+ /* We use to have pointer elements added here. We cannot do that,
11081108+ though, since it does not work when using 32-bit definitions
11091109+ on 64-bit platforms and vice versa. */
11101110+ } a_un;
11111111+} Elf64_auxv_t;
11121112+11131113+#include <bits/auxv.h>
11141114+/* Note section contents. Each entry in the note section begins with
11151115+ a header of a fixed form. */
11161116+11171117+typedef struct
11181118+{
11191119+ Elf32_Word n_namesz; /* Length of the note's name. */
11201120+ Elf32_Word n_descsz; /* Length of the note's descriptor. */
11211121+ Elf32_Word n_type; /* Type of the note. */
11221122+} Elf32_Nhdr;
11231123+11241124+typedef struct
11251125+{
11261126+ Elf64_Word n_namesz; /* Length of the note's name. */
11271127+ Elf64_Word n_descsz; /* Length of the note's descriptor. */
11281128+ Elf64_Word n_type; /* Type of the note. */
11291129+} Elf64_Nhdr;
11301130+11311131+/* Known names of notes. */
11321132+11331133+/* Solaris entries in the note section have this name. */
11341134+#define ELF_NOTE_SOLARIS "SUNW Solaris"
11351135+11361136+/* Note entries for GNU systems have this name. */
11371137+#define ELF_NOTE_GNU "GNU"
11381138+11391139+11401140+/* Defined types of notes for Solaris. */
11411141+11421142+/* Value of descriptor (one word) is desired pagesize for the binary. */
11431143+#define ELF_NOTE_PAGESIZE_HINT 1
11441144+11451145+11461146+/* Defined note types for GNU systems. */
11471147+11481148+/* ABI information. The descriptor consists of words:
11491149+ word 0: OS descriptor
11501150+ word 1: major version of the ABI
11511151+ word 2: minor version of the ABI
11521152+ word 3: subminor version of the ABI
11531153+*/
11541154+#define NT_GNU_ABI_TAG 1
11551155+#define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */
11561156+11571157+/* Known OSes. These values can appear in word 0 of an
11581158+ NT_GNU_ABI_TAG note section entry. */
11591159+#define ELF_NOTE_OS_LINUX 0
11601160+#define ELF_NOTE_OS_GNU 1
11611161+#define ELF_NOTE_OS_SOLARIS2 2
11621162+#define ELF_NOTE_OS_FREEBSD 3
11631163+11641164+/* Synthetic hwcap information. The descriptor begins with two words:
11651165+ word 0: number of entries
11661166+ word 1: bitmask of enabled entries
11671167+ Then follow variable-length entries, one byte followed by a
11681168+ '\0'-terminated hwcap name string. The byte gives the bit
11691169+ number to test if enabled, (1U << bit) & bitmask. */
11701170+#define NT_GNU_HWCAP 2
11711171+11721172+/* Build ID bits as generated by ld --build-id.
11731173+ The descriptor consists of any nonzero number of bytes. */
11741174+#define NT_GNU_BUILD_ID 3
11751175+11761176+/* Version note generated by GNU gold containing a version string. */
11771177+#define NT_GNU_GOLD_VERSION 4
11781178+11791179+11801180+/* Move records. */
11811181+typedef struct
11821182+{
11831183+ Elf32_Xword m_value; /* Symbol value. */
11841184+ Elf32_Word m_info; /* Size and index. */
11851185+ Elf32_Word m_poffset; /* Symbol offset. */
11861186+ Elf32_Half m_repeat; /* Repeat count. */
11871187+ Elf32_Half m_stride; /* Stride info. */
11881188+} Elf32_Move;
11891189+11901190+typedef struct
11911191+{
11921192+ Elf64_Xword m_value; /* Symbol value. */
11931193+ Elf64_Xword m_info; /* Size and index. */
11941194+ Elf64_Xword m_poffset; /* Symbol offset. */
11951195+ Elf64_Half m_repeat; /* Repeat count. */
11961196+ Elf64_Half m_stride; /* Stride info. */
11971197+} Elf64_Move;
11981198+11991199+/* Macro to construct move records. */
12001200+#define ELF32_M_SYM(info) ((info) >> 8)
12011201+#define ELF32_M_SIZE(info) ((unsigned char) (info))
12021202+#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
12031203+12041204+#define ELF64_M_SYM(info) ELF32_M_SYM (info)
12051205+#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
12061206+#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
12071207+12081208+12091209+/* Motorola 68k specific definitions. */
12101210+12111211+/* Values for Elf32_Ehdr.e_flags. */
12121212+#define EF_CPU32 0x00810000
12131213+12141214+/* m68k relocs. */
12151215+12161216+#define R_68K_NONE 0 /* No reloc */
12171217+#define R_68K_32 1 /* Direct 32 bit */
12181218+#define R_68K_16 2 /* Direct 16 bit */
12191219+#define R_68K_8 3 /* Direct 8 bit */
12201220+#define R_68K_PC32 4 /* PC relative 32 bit */
12211221+#define R_68K_PC16 5 /* PC relative 16 bit */
12221222+#define R_68K_PC8 6 /* PC relative 8 bit */
12231223+#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
12241224+#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
12251225+#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
12261226+#define R_68K_GOT32O 10 /* 32 bit GOT offset */
12271227+#define R_68K_GOT16O 11 /* 16 bit GOT offset */
12281228+#define R_68K_GOT8O 12 /* 8 bit GOT offset */
12291229+#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
12301230+#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
12311231+#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
12321232+#define R_68K_PLT32O 16 /* 32 bit PLT offset */
12331233+#define R_68K_PLT16O 17 /* 16 bit PLT offset */
12341234+#define R_68K_PLT8O 18 /* 8 bit PLT offset */
12351235+#define R_68K_COPY 19 /* Copy symbol at runtime */
12361236+#define R_68K_GLOB_DAT 20 /* Create GOT entry */
12371237+#define R_68K_JMP_SLOT 21 /* Create PLT entry */
12381238+#define R_68K_RELATIVE 22 /* Adjust by program base */
12391239+#define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */
12401240+#define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */
12411241+#define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */
12421242+#define R_68K_TLS_LDM32 28 /* 32 bit GOT offset for LDM */
12431243+#define R_68K_TLS_LDM16 29 /* 16 bit GOT offset for LDM */
12441244+#define R_68K_TLS_LDM8 30 /* 8 bit GOT offset for LDM */
12451245+#define R_68K_TLS_LDO32 31 /* 32 bit module-relative offset */
12461246+#define R_68K_TLS_LDO16 32 /* 16 bit module-relative offset */
12471247+#define R_68K_TLS_LDO8 33 /* 8 bit module-relative offset */
12481248+#define R_68K_TLS_IE32 34 /* 32 bit GOT offset for IE */
12491249+#define R_68K_TLS_IE16 35 /* 16 bit GOT offset for IE */
12501250+#define R_68K_TLS_IE8 36 /* 8 bit GOT offset for IE */
12511251+#define R_68K_TLS_LE32 37 /* 32 bit offset relative to
12521252+ static TLS block */
12531253+#define R_68K_TLS_LE16 38 /* 16 bit offset relative to
12541254+ static TLS block */
12551255+#define R_68K_TLS_LE8 39 /* 8 bit offset relative to
12561256+ static TLS block */
12571257+#define R_68K_TLS_DTPMOD32 40 /* 32 bit module number */
12581258+#define R_68K_TLS_DTPREL32 41 /* 32 bit module-relative offset */
12591259+#define R_68K_TLS_TPREL32 42 /* 32 bit TP-relative offset */
12601260+/* Keep this the last entry. */
12611261+#define R_68K_NUM 43
12621262+12631263+/* Intel 80386 specific definitions. */
12641264+12651265+/* i386 relocs. */
12661266+12671267+#define R_386_NONE 0 /* No reloc */
12681268+#define R_386_32 1 /* Direct 32 bit */
12691269+#define R_386_PC32 2 /* PC relative 32 bit */
12701270+#define R_386_GOT32 3 /* 32 bit GOT entry */
12711271+#define R_386_PLT32 4 /* 32 bit PLT address */
12721272+#define R_386_COPY 5 /* Copy symbol at runtime */
12731273+#define R_386_GLOB_DAT 6 /* Create GOT entry */
12741274+#define R_386_JMP_SLOT 7 /* Create PLT entry */
12751275+#define R_386_RELATIVE 8 /* Adjust by program base */
12761276+#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
12771277+#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
12781278+#define R_386_32PLT 11
12791279+#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
12801280+#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
12811281+ block offset */
12821282+#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
12831283+ offset */
12841284+#define R_386_TLS_LE 17 /* Offset relative to static TLS
12851285+ block */
12861286+#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
12871287+ general dynamic thread local data */
12881288+#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
12891289+ local dynamic thread local data
12901290+ in LE code */
12911291+#define R_386_16 20
12921292+#define R_386_PC16 21
12931293+#define R_386_8 22
12941294+#define R_386_PC8 23
12951295+#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
12961296+ thread local data */
12971297+#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
12981298+#define R_386_TLS_GD_CALL 26 /* Relocation for call to
12991299+ __tls_get_addr() */
13001300+#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
13011301+#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
13021302+ thread local data in LE code */
13031303+#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
13041304+#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
13051305+ __tls_get_addr() in LDM code */
13061306+#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
13071307+#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
13081308+#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
13091309+ block offset */
13101310+#define R_386_TLS_LE_32 34 /* Negated offset relative to static
13111311+ TLS block */
13121312+#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
13131313+#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
13141314+#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
13151315+#define R_386_SIZE32 38 /* 32-bit symbol size */
13161316+#define R_386_TLS_GOTDESC 39 /* GOT offset for TLS descriptor. */
13171317+#define R_386_TLS_DESC_CALL 40 /* Marker of call through TLS
13181318+ descriptor for
13191319+ relaxation. */
13201320+#define R_386_TLS_DESC 41 /* TLS descriptor containing
13211321+ pointer to code and to
13221322+ argument, returning the TLS
13231323+ offset for the symbol. */
13241324+#define R_386_IRELATIVE 42 /* Adjust indirectly by program base */
13251325+#define R_386_GOT32X 43 /* Load from 32 bit GOT entry,
13261326+ relaxable. */
13271327+/* Keep this the last entry. */
13281328+#define R_386_NUM 44
13291329+13301330+/* SUN SPARC specific definitions. */
13311331+13321332+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
13331333+13341334+#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */
13351335+13361336+/* Values for Elf64_Ehdr.e_flags. */
13371337+13381338+#define EF_SPARCV9_MM 3
13391339+#define EF_SPARCV9_TSO 0
13401340+#define EF_SPARCV9_PSO 1
13411341+#define EF_SPARCV9_RMO 2
13421342+#define EF_SPARC_LEDATA 0x800000 /* little endian data */
13431343+#define EF_SPARC_EXT_MASK 0xFFFF00
13441344+#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
13451345+#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
13461346+#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
13471347+#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
13481348+13491349+/* SPARC relocs. */
13501350+13511351+#define R_SPARC_NONE 0 /* No reloc */
13521352+#define R_SPARC_8 1 /* Direct 8 bit */
13531353+#define R_SPARC_16 2 /* Direct 16 bit */
13541354+#define R_SPARC_32 3 /* Direct 32 bit */
13551355+#define R_SPARC_DISP8 4 /* PC relative 8 bit */
13561356+#define R_SPARC_DISP16 5 /* PC relative 16 bit */
13571357+#define R_SPARC_DISP32 6 /* PC relative 32 bit */
13581358+#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
13591359+#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
13601360+#define R_SPARC_HI22 9 /* High 22 bit */
13611361+#define R_SPARC_22 10 /* Direct 22 bit */
13621362+#define R_SPARC_13 11 /* Direct 13 bit */
13631363+#define R_SPARC_LO10 12 /* Truncated 10 bit */
13641364+#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
13651365+#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
13661366+#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
13671367+#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
13681368+#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
13691369+#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
13701370+#define R_SPARC_COPY 19 /* Copy symbol at runtime */
13711371+#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
13721372+#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
13731373+#define R_SPARC_RELATIVE 22 /* Adjust by program base */
13741374+#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
13751375+13761376+/* Additional Sparc64 relocs. */
13771377+13781378+#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
13791379+#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
13801380+#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
13811381+#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
13821382+#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
13831383+#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
13841384+#define R_SPARC_10 30 /* Direct 10 bit */
13851385+#define R_SPARC_11 31 /* Direct 11 bit */
13861386+#define R_SPARC_64 32 /* Direct 64 bit */
13871387+#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
13881388+#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
13891389+#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
13901390+#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
13911391+#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
13921392+#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
13931393+#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */
13941394+#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
13951395+#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
13961396+#define R_SPARC_GLOB_JMP 42 /* was part of v9 ABI but was removed */
13971397+#define R_SPARC_7 43 /* Direct 7 bit */
13981398+#define R_SPARC_5 44 /* Direct 5 bit */
13991399+#define R_SPARC_6 45 /* Direct 6 bit */
14001400+#define R_SPARC_DISP64 46 /* PC relative 64 bit */
14011401+#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
14021402+#define R_SPARC_HIX22 48 /* High 22 bit complemented */
14031403+#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
14041404+#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
14051405+#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
14061406+#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
14071407+#define R_SPARC_REGISTER 53 /* Global register usage */
14081408+#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
14091409+#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
14101410+#define R_SPARC_TLS_GD_HI22 56
14111411+#define R_SPARC_TLS_GD_LO10 57
14121412+#define R_SPARC_TLS_GD_ADD 58
14131413+#define R_SPARC_TLS_GD_CALL 59
14141414+#define R_SPARC_TLS_LDM_HI22 60
14151415+#define R_SPARC_TLS_LDM_LO10 61
14161416+#define R_SPARC_TLS_LDM_ADD 62
14171417+#define R_SPARC_TLS_LDM_CALL 63
14181418+#define R_SPARC_TLS_LDO_HIX22 64
14191419+#define R_SPARC_TLS_LDO_LOX10 65
14201420+#define R_SPARC_TLS_LDO_ADD 66
14211421+#define R_SPARC_TLS_IE_HI22 67
14221422+#define R_SPARC_TLS_IE_LO10 68
14231423+#define R_SPARC_TLS_IE_LD 69
14241424+#define R_SPARC_TLS_IE_LDX 70
14251425+#define R_SPARC_TLS_IE_ADD 71
14261426+#define R_SPARC_TLS_LE_HIX22 72
14271427+#define R_SPARC_TLS_LE_LOX10 73
14281428+#define R_SPARC_TLS_DTPMOD32 74
14291429+#define R_SPARC_TLS_DTPMOD64 75
14301430+#define R_SPARC_TLS_DTPOFF32 76
14311431+#define R_SPARC_TLS_DTPOFF64 77
14321432+#define R_SPARC_TLS_TPOFF32 78
14331433+#define R_SPARC_TLS_TPOFF64 79
14341434+#define R_SPARC_GOTDATA_HIX22 80
14351435+#define R_SPARC_GOTDATA_LOX10 81
14361436+#define R_SPARC_GOTDATA_OP_HIX22 82
14371437+#define R_SPARC_GOTDATA_OP_LOX10 83
14381438+#define R_SPARC_GOTDATA_OP 84
14391439+#define R_SPARC_H34 85
14401440+#define R_SPARC_SIZE32 86
14411441+#define R_SPARC_SIZE64 87
14421442+#define R_SPARC_WDISP10 88
14431443+#define R_SPARC_JMP_IREL 248
14441444+#define R_SPARC_IRELATIVE 249
14451445+#define R_SPARC_GNU_VTINHERIT 250
14461446+#define R_SPARC_GNU_VTENTRY 251
14471447+#define R_SPARC_REV32 252
14481448+/* Keep this the last entry. */
14491449+#define R_SPARC_NUM 253
14501450+14511451+/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
14521452+14531453+#define DT_SPARC_REGISTER 0x70000001
14541454+#define DT_SPARC_NUM 2
14551455+14561456+/* MIPS R3000 specific definitions. */
14571457+14581458+/* Legal values for e_flags field of Elf32_Ehdr. */
14591459+14601460+#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used. */
14611461+#define EF_MIPS_PIC 2 /* Contains PIC code. */
14621462+#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence. */
14631463+#define EF_MIPS_XGOT 8
14641464+#define EF_MIPS_64BIT_WHIRL 16
14651465+#define EF_MIPS_ABI2 32
14661466+#define EF_MIPS_ABI_ON32 64
14671467+#define EF_MIPS_FP64 512 /* Uses FP64 (12 callee-saved). */
14681468+#define EF_MIPS_NAN2008 1024 /* Uses IEEE 754-2008 NaN encoding. */
14691469+#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level. */
14701470+14711471+/* Legal values for MIPS architecture level. */
14721472+14731473+#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
14741474+#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
14751475+#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
14761476+#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
14771477+#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
14781478+#define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */
14791479+#define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */
14801480+#define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32r2 code. */
14811481+#define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64r2 code. */
14821482+14831483+/* The following are unofficial names and should not be used. */
14841484+14851485+#define E_MIPS_ARCH_1 EF_MIPS_ARCH_1
14861486+#define E_MIPS_ARCH_2 EF_MIPS_ARCH_2
14871487+#define E_MIPS_ARCH_3 EF_MIPS_ARCH_3
14881488+#define E_MIPS_ARCH_4 EF_MIPS_ARCH_4
14891489+#define E_MIPS_ARCH_5 EF_MIPS_ARCH_5
14901490+#define E_MIPS_ARCH_32 EF_MIPS_ARCH_32
14911491+#define E_MIPS_ARCH_64 EF_MIPS_ARCH_64
14921492+14931493+/* Special section indices. */
14941494+14951495+#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols. */
14961496+#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
14971497+#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
14981498+#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols. */
14991499+#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols. */
15001500+15011501+/* Legal values for sh_type field of Elf32_Shdr. */
15021502+15031503+#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link. */
15041504+#define SHT_MIPS_MSYM 0x70000001
15051505+#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols. */
15061506+#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes. */
15071507+#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
15081508+#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging info. */
15091509+#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information. */
15101510+#define SHT_MIPS_PACKAGE 0x70000007
15111511+#define SHT_MIPS_PACKSYM 0x70000008
15121512+#define SHT_MIPS_RELD 0x70000009
15131513+#define SHT_MIPS_IFACE 0x7000000b
15141514+#define SHT_MIPS_CONTENT 0x7000000c
15151515+#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
15161516+#define SHT_MIPS_SHDR 0x70000010
15171517+#define SHT_MIPS_FDESC 0x70000011
15181518+#define SHT_MIPS_EXTSYM 0x70000012
15191519+#define SHT_MIPS_DENSE 0x70000013
15201520+#define SHT_MIPS_PDESC 0x70000014
15211521+#define SHT_MIPS_LOCSYM 0x70000015
15221522+#define SHT_MIPS_AUXSYM 0x70000016
15231523+#define SHT_MIPS_OPTSYM 0x70000017
15241524+#define SHT_MIPS_LOCSTR 0x70000018
15251525+#define SHT_MIPS_LINE 0x70000019
15261526+#define SHT_MIPS_RFDESC 0x7000001a
15271527+#define SHT_MIPS_DELTASYM 0x7000001b
15281528+#define SHT_MIPS_DELTAINST 0x7000001c
15291529+#define SHT_MIPS_DELTACLASS 0x7000001d
15301530+#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
15311531+#define SHT_MIPS_DELTADECL 0x7000001f
15321532+#define SHT_MIPS_SYMBOL_LIB 0x70000020
15331533+#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
15341534+#define SHT_MIPS_TRANSLATE 0x70000022
15351535+#define SHT_MIPS_PIXIE 0x70000023
15361536+#define SHT_MIPS_XLATE 0x70000024
15371537+#define SHT_MIPS_XLATE_DEBUG 0x70000025
15381538+#define SHT_MIPS_WHIRL 0x70000026
15391539+#define SHT_MIPS_EH_REGION 0x70000027
15401540+#define SHT_MIPS_XLATE_OLD 0x70000028
15411541+#define SHT_MIPS_PDR_EXCEPTION 0x70000029
15421542+15431543+/* Legal values for sh_flags field of Elf32_Shdr. */
15441544+15451545+#define SHF_MIPS_GPREL 0x10000000 /* Must be in global data area. */
15461546+#define SHF_MIPS_MERGE 0x20000000
15471547+#define SHF_MIPS_ADDR 0x40000000
15481548+#define SHF_MIPS_STRINGS 0x80000000
15491549+#define SHF_MIPS_NOSTRIP 0x08000000
15501550+#define SHF_MIPS_LOCAL 0x04000000
15511551+#define SHF_MIPS_NAMES 0x02000000
15521552+#define SHF_MIPS_NODUPE 0x01000000
15531553+15541554+15551555+/* Symbol tables. */
15561556+15571557+/* MIPS specific values for `st_other'. */
15581558+#define STO_MIPS_DEFAULT 0x0
15591559+#define STO_MIPS_INTERNAL 0x1
15601560+#define STO_MIPS_HIDDEN 0x2
15611561+#define STO_MIPS_PROTECTED 0x3
15621562+#define STO_MIPS_PLT 0x8
15631563+#define STO_MIPS_SC_ALIGN_UNUSED 0xff
15641564+15651565+/* MIPS specific values for `st_info'. */
15661566+#define STB_MIPS_SPLIT_COMMON 13
15671567+15681568+/* Entries found in sections of type SHT_MIPS_GPTAB. */
15691569+15701570+typedef union
15711571+{
15721572+ struct
15731573+ {
15741574+ Elf32_Word gt_current_g_value; /* -G value used for compilation. */
15751575+ Elf32_Word gt_unused; /* Not used. */
15761576+ } gt_header; /* First entry in section. */
15771577+ struct
15781578+ {
15791579+ Elf32_Word gt_g_value; /* If this value were used for -G. */
15801580+ Elf32_Word gt_bytes; /* This many bytes would be used. */
15811581+ } gt_entry; /* Subsequent entries in section. */
15821582+} Elf32_gptab;
15831583+15841584+/* Entry found in sections of type SHT_MIPS_REGINFO. */
15851585+15861586+typedef struct
15871587+{
15881588+ Elf32_Word ri_gprmask; /* General registers used. */
15891589+ Elf32_Word ri_cprmask[4]; /* Coprocessor registers used. */
15901590+ Elf32_Sword ri_gp_value; /* $gp register value. */
15911591+} Elf32_RegInfo;
15921592+15931593+/* Entries found in sections of type SHT_MIPS_OPTIONS. */
15941594+15951595+typedef struct
15961596+{
15971597+ unsigned char kind; /* Determines interpretation of the
15981598+ variable part of descriptor. */
15991599+ unsigned char size; /* Size of descriptor, including header. */
16001600+ Elf32_Section section; /* Section header index of section affected,
16011601+ 0 for global options. */
16021602+ Elf32_Word info; /* Kind-specific information. */
16031603+} Elf_Options;
16041604+16051605+/* Values for `kind' field in Elf_Options. */
16061606+16071607+#define ODK_NULL 0 /* Undefined. */
16081608+#define ODK_REGINFO 1 /* Register usage information. */
16091609+#define ODK_EXCEPTIONS 2 /* Exception processing options. */
16101610+#define ODK_PAD 3 /* Section padding options. */
16111611+#define ODK_HWPATCH 4 /* Hardware workarounds performed */
16121612+#define ODK_FILL 5 /* record the fill value used by the linker. */
16131613+#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
16141614+#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
16151615+#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
16161616+16171617+/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
16181618+16191619+#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
16201620+#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
16211621+#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
16221622+#define OEX_SMM 0x20000 /* Force sequential memory mode? */
16231623+#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
16241624+#define OEX_PRECISEFP OEX_FPDBUG
16251625+#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
16261626+16271627+#define OEX_FPU_INVAL 0x10
16281628+#define OEX_FPU_DIV0 0x08
16291629+#define OEX_FPU_OFLO 0x04
16301630+#define OEX_FPU_UFLO 0x02
16311631+#define OEX_FPU_INEX 0x01
16321632+16331633+/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
16341634+16351635+#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
16361636+#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
16371637+#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
16381638+#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
16391639+16401640+#define OPAD_PREFIX 0x1
16411641+#define OPAD_POSTFIX 0x2
16421642+#define OPAD_SYMBOL 0x4
16431643+16441644+/* Entry found in `.options' section. */
16451645+16461646+typedef struct
16471647+{
16481648+ Elf32_Word hwp_flags1; /* Extra flags. */
16491649+ Elf32_Word hwp_flags2; /* Extra flags. */
16501650+} Elf_Options_Hw;
16511651+16521652+/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
16531653+16541654+#define OHWA0_R4KEOP_CHECKED 0x00000001
16551655+#define OHWA1_R4KEOP_CLEAN 0x00000002
16561656+16571657+/* MIPS relocs. */
16581658+16591659+#define R_MIPS_NONE 0 /* No reloc */
16601660+#define R_MIPS_16 1 /* Direct 16 bit */
16611661+#define R_MIPS_32 2 /* Direct 32 bit */
16621662+#define R_MIPS_REL32 3 /* PC relative 32 bit */
16631663+#define R_MIPS_26 4 /* Direct 26 bit shifted */
16641664+#define R_MIPS_HI16 5 /* High 16 bit */
16651665+#define R_MIPS_LO16 6 /* Low 16 bit */
16661666+#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
16671667+#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
16681668+#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
16691669+#define R_MIPS_PC16 10 /* PC relative 16 bit */
16701670+#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
16711671+#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
16721672+16731673+#define R_MIPS_SHIFT5 16
16741674+#define R_MIPS_SHIFT6 17
16751675+#define R_MIPS_64 18
16761676+#define R_MIPS_GOT_DISP 19
16771677+#define R_MIPS_GOT_PAGE 20
16781678+#define R_MIPS_GOT_OFST 21
16791679+#define R_MIPS_GOT_HI16 22
16801680+#define R_MIPS_GOT_LO16 23
16811681+#define R_MIPS_SUB 24
16821682+#define R_MIPS_INSERT_A 25
16831683+#define R_MIPS_INSERT_B 26
16841684+#define R_MIPS_DELETE 27
16851685+#define R_MIPS_HIGHER 28
16861686+#define R_MIPS_HIGHEST 29
16871687+#define R_MIPS_CALL_HI16 30
16881688+#define R_MIPS_CALL_LO16 31
16891689+#define R_MIPS_SCN_DISP 32
16901690+#define R_MIPS_REL16 33
16911691+#define R_MIPS_ADD_IMMEDIATE 34
16921692+#define R_MIPS_PJUMP 35
16931693+#define R_MIPS_RELGOT 36
16941694+#define R_MIPS_JALR 37
16951695+#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */
16961696+#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */
16971697+#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */
16981698+#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */
16991699+#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */
17001700+#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */
17011701+#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */
17021702+#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */
17031703+#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */
17041704+#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */
17051705+#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */
17061706+#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */
17071707+#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */
17081708+#define R_MIPS_GLOB_DAT 51
17091709+#define R_MIPS_COPY 126
17101710+#define R_MIPS_JUMP_SLOT 127
17111711+/* Keep this the last entry. */
17121712+#define R_MIPS_NUM 128
17131713+17141714+/* Legal values for p_type field of Elf32_Phdr. */
17151715+17161716+#define PT_MIPS_REGINFO 0x70000000 /* Register usage information. */
17171717+#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
17181718+#define PT_MIPS_OPTIONS 0x70000002
17191719+#define PT_MIPS_ABIFLAGS 0x70000003 /* FP mode requirement. */
17201720+17211721+/* Special program header types. */
17221722+17231723+#define PF_MIPS_LOCAL 0x10000000
17241724+17251725+/* Legal values for d_tag field of Elf32_Dyn. */
17261726+17271727+#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
17281728+#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
17291729+#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
17301730+#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
17311731+#define DT_MIPS_FLAGS 0x70000005 /* Flags */
17321732+#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
17331733+#define DT_MIPS_MSYM 0x70000007
17341734+#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
17351735+#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
17361736+#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
17371737+#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
17381738+#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
17391739+#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
17401740+#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
17411741+#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
17421742+#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
17431743+#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
17441744+#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
17451745+#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
17461746+ DT_MIPS_DELTA_CLASS. */
17471747+#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
17481748+#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
17491749+ DT_MIPS_DELTA_INSTANCE. */
17501750+#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
17511751+#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
17521752+ DT_MIPS_DELTA_RELOC. */
17531753+#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
17541754+ relocations refer to. */
17551755+#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
17561756+ DT_MIPS_DELTA_SYM. */
17571757+#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
17581758+ class declaration. */
17591759+#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
17601760+ DT_MIPS_DELTA_CLASSSYM. */
17611761+#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
17621762+#define DT_MIPS_PIXIE_INIT 0x70000023
17631763+#define DT_MIPS_SYMBOL_LIB 0x70000024
17641764+#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
17651765+#define DT_MIPS_LOCAL_GOTIDX 0x70000026
17661766+#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
17671767+#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
17681768+#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
17691769+#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
17701770+#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
17711771+#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
17721772+#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
17731773+ function stored in GOT. */
17741774+#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
17751775+ by rld on dlopen() calls. */
17761776+#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
17771777+#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
17781778+#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
17791779+/* The address of .got.plt in an executable using the new non-PIC ABI. */
17801780+#define DT_MIPS_PLTGOT 0x70000032
17811781+/* The base of the PLT in an executable using the new non-PIC ABI if that
17821782+ PLT is writable. For a non-writable PLT, this is omitted or has a zero
17831783+ value. */
17841784+#define DT_MIPS_RWPLT 0x70000034
17851785+/* An alternative description of the classic MIPS RLD_MAP that is usable
17861786+ in a PIE as it stores a relative offset from the address of the tag
17871787+ rather than an absolute address. */
17881788+#define DT_MIPS_RLD_MAP_REL 0x70000035
17891789+#define DT_MIPS_NUM 0x36
17901790+17911791+/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
17921792+17931793+#define RHF_NONE 0 /* No flags */
17941794+#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
17951795+#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
17961796+#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
17971797+#define RHF_NO_MOVE (1 << 3)
17981798+#define RHF_SGI_ONLY (1 << 4)
17991799+#define RHF_GUARANTEE_INIT (1 << 5)
18001800+#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
18011801+#define RHF_GUARANTEE_START_INIT (1 << 7)
18021802+#define RHF_PIXIE (1 << 8)
18031803+#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
18041804+#define RHF_REQUICKSTART (1 << 10)
18051805+#define RHF_REQUICKSTARTED (1 << 11)
18061806+#define RHF_CORD (1 << 12)
18071807+#define RHF_NO_UNRES_UNDEF (1 << 13)
18081808+#define RHF_RLD_ORDER_SAFE (1 << 14)
18091809+18101810+/* Entries found in sections of type SHT_MIPS_LIBLIST. */
18111811+18121812+typedef struct
18131813+{
18141814+ Elf32_Word l_name; /* Name (string table index) */
18151815+ Elf32_Word l_time_stamp; /* Timestamp */
18161816+ Elf32_Word l_checksum; /* Checksum */
18171817+ Elf32_Word l_version; /* Interface version */
18181818+ Elf32_Word l_flags; /* Flags */
18191819+} Elf32_Lib;
18201820+18211821+typedef struct
18221822+{
18231823+ Elf64_Word l_name; /* Name (string table index) */
18241824+ Elf64_Word l_time_stamp; /* Timestamp */
18251825+ Elf64_Word l_checksum; /* Checksum */
18261826+ Elf64_Word l_version; /* Interface version */
18271827+ Elf64_Word l_flags; /* Flags */
18281828+} Elf64_Lib;
18291829+18301830+18311831+/* Legal values for l_flags. */
18321832+18331833+#define LL_NONE 0
18341834+#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
18351835+#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
18361836+#define LL_REQUIRE_MINOR (1 << 2)
18371837+#define LL_EXPORTS (1 << 3)
18381838+#define LL_DELAY_LOAD (1 << 4)
18391839+#define LL_DELTA (1 << 5)
18401840+18411841+/* Entries found in sections of type SHT_MIPS_CONFLICT. */
18421842+18431843+typedef Elf32_Addr Elf32_Conflict;
18441844+18451845+typedef struct
18461846+{
18471847+ /* Version of flags structure. */
18481848+ Elf32_Half version;
18491849+ /* The level of the ISA: 1-5, 32, 64. */
18501850+ unsigned char isa_level;
18511851+ /* The revision of ISA: 0 for MIPS V and below, 1-n otherwise. */
18521852+ unsigned char isa_rev;
18531853+ /* The size of general purpose registers. */
18541854+ unsigned char gpr_size;
18551855+ /* The size of co-processor 1 registers. */
18561856+ unsigned char cpr1_size;
18571857+ /* The size of co-processor 2 registers. */
18581858+ unsigned char cpr2_size;
18591859+ /* The floating-point ABI. */
18601860+ unsigned char fp_abi;
18611861+ /* Processor-specific extension. */
18621862+ Elf32_Word isa_ext;
18631863+ /* Mask of ASEs used. */
18641864+ Elf32_Word ases;
18651865+ /* Mask of general flags. */
18661866+ Elf32_Word flags1;
18671867+ Elf32_Word flags2;
18681868+} Elf_MIPS_ABIFlags_v0;
18691869+18701870+/* Values for the register size bytes of an abi flags structure. */
18711871+18721872+#define MIPS_AFL_REG_NONE 0x00 /* No registers. */
18731873+#define MIPS_AFL_REG_32 0x01 /* 32-bit registers. */
18741874+#define MIPS_AFL_REG_64 0x02 /* 64-bit registers. */
18751875+#define MIPS_AFL_REG_128 0x03 /* 128-bit registers. */
18761876+18771877+/* Masks for the ases word of an ABI flags structure. */
18781878+18791879+#define MIPS_AFL_ASE_DSP 0x00000001 /* DSP ASE. */
18801880+#define MIPS_AFL_ASE_DSPR2 0x00000002 /* DSP R2 ASE. */
18811881+#define MIPS_AFL_ASE_EVA 0x00000004 /* Enhanced VA Scheme. */
18821882+#define MIPS_AFL_ASE_MCU 0x00000008 /* MCU (MicroController) ASE. */
18831883+#define MIPS_AFL_ASE_MDMX 0x00000010 /* MDMX ASE. */
18841884+#define MIPS_AFL_ASE_MIPS3D 0x00000020 /* MIPS-3D ASE. */
18851885+#define MIPS_AFL_ASE_MT 0x00000040 /* MT ASE. */
18861886+#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 /* SmartMIPS ASE. */
18871887+#define MIPS_AFL_ASE_VIRT 0x00000100 /* VZ ASE. */
18881888+#define MIPS_AFL_ASE_MSA 0x00000200 /* MSA ASE. */
18891889+#define MIPS_AFL_ASE_MIPS16 0x00000400 /* MIPS16 ASE. */
18901890+#define MIPS_AFL_ASE_MICROMIPS 0x00000800 /* MICROMIPS ASE. */
18911891+#define MIPS_AFL_ASE_XPA 0x00001000 /* XPA ASE. */
18921892+#define MIPS_AFL_ASE_MASK 0x00001fff /* All ASEs. */
18931893+18941894+/* Values for the isa_ext word of an ABI flags structure. */
18951895+18961896+#define MIPS_AFL_EXT_XLR 1 /* RMI Xlr instruction. */
18971897+#define MIPS_AFL_EXT_OCTEON2 2 /* Cavium Networks Octeon2. */
18981898+#define MIPS_AFL_EXT_OCTEONP 3 /* Cavium Networks OcteonP. */
18991899+#define MIPS_AFL_EXT_LOONGSON_3A 4 /* Loongson 3A. */
19001900+#define MIPS_AFL_EXT_OCTEON 5 /* Cavium Networks Octeon. */
19011901+#define MIPS_AFL_EXT_5900 6 /* MIPS R5900 instruction. */
19021902+#define MIPS_AFL_EXT_4650 7 /* MIPS R4650 instruction. */
19031903+#define MIPS_AFL_EXT_4010 8 /* LSI R4010 instruction. */
19041904+#define MIPS_AFL_EXT_4100 9 /* NEC VR4100 instruction. */
19051905+#define MIPS_AFL_EXT_3900 10 /* Toshiba R3900 instruction. */
19061906+#define MIPS_AFL_EXT_10000 11 /* MIPS R10000 instruction. */
19071907+#define MIPS_AFL_EXT_SB1 12 /* Broadcom SB-1 instruction. */
19081908+#define MIPS_AFL_EXT_4111 13 /* NEC VR4111/VR4181 instruction. */
19091909+#define MIPS_AFL_EXT_4120 14 /* NEC VR4120 instruction. */
19101910+#define MIPS_AFL_EXT_5400 15 /* NEC VR5400 instruction. */
19111911+#define MIPS_AFL_EXT_5500 16 /* NEC VR5500 instruction. */
19121912+#define MIPS_AFL_EXT_LOONGSON_2E 17 /* ST Microelectronics Loongson 2E. */
19131913+#define MIPS_AFL_EXT_LOONGSON_2F 18 /* ST Microelectronics Loongson 2F. */
19141914+19151915+/* Masks for the flags1 word of an ABI flags structure. */
19161916+#define MIPS_AFL_FLAGS1_ODDSPREG 1 /* Uses odd single-precision registers. */
19171917+19181918+/* Object attribute values. */
19191919+enum
19201920+{
19211921+ /* Not tagged or not using any ABIs affected by the differences. */
19221922+ Val_GNU_MIPS_ABI_FP_ANY = 0,
19231923+ /* Using hard-float -mdouble-float. */
19241924+ Val_GNU_MIPS_ABI_FP_DOUBLE = 1,
19251925+ /* Using hard-float -msingle-float. */
19261926+ Val_GNU_MIPS_ABI_FP_SINGLE = 2,
19271927+ /* Using soft-float. */
19281928+ Val_GNU_MIPS_ABI_FP_SOFT = 3,
19291929+ /* Using -mips32r2 -mfp64. */
19301930+ Val_GNU_MIPS_ABI_FP_OLD_64 = 4,
19311931+ /* Using -mfpxx. */
19321932+ Val_GNU_MIPS_ABI_FP_XX = 5,
19331933+ /* Using -mips32r2 -mfp64. */
19341934+ Val_GNU_MIPS_ABI_FP_64 = 6,
19351935+ /* Using -mips32r2 -mfp64 -mno-odd-spreg. */
19361936+ Val_GNU_MIPS_ABI_FP_64A = 7,
19371937+ /* Maximum allocated FP ABI value. */
19381938+ Val_GNU_MIPS_ABI_FP_MAX = 7
19391939+};
19401940+19411941+/* HPPA specific definitions. */
19421942+19431943+/* Legal values for e_flags field of Elf32_Ehdr. */
19441944+19451945+#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */
19461946+#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */
19471947+#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */
19481948+#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */
19491949+#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch
19501950+ prediction. */
19511951+#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */
19521952+#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */
19531953+19541954+/* Defined values for `e_flags & EF_PARISC_ARCH' are: */
19551955+19561956+#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */
19571957+#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
19581958+#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
19591959+19601960+/* Additional section indeces. */
19611961+19621962+#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
19631963+ symbols in ANSI C. */
19641964+#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
19651965+19661966+/* Legal values for sh_type field of Elf32_Shdr. */
19671967+19681968+#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */
19691969+#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */
19701970+#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */
19711971+19721972+/* Legal values for sh_flags field of Elf32_Shdr. */
19731973+19741974+#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
19751975+#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */
19761976+#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */
19771977+19781978+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
19791979+19801980+#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
19811981+19821982+#define STT_HP_OPAQUE (STT_LOOS + 0x1)
19831983+#define STT_HP_STUB (STT_LOOS + 0x2)
19841984+19851985+/* HPPA relocs. */
19861986+19871987+#define R_PARISC_NONE 0 /* No reloc. */
19881988+#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
19891989+#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
19901990+#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
19911991+#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */
19921992+#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */
19931993+#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */
19941994+#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */
19951995+#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */
19961996+#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
19971997+#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
19981998+#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
19991999+#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
20002000+#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
20012001+#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
20022002+#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
20032003+#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
20042004+#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
20052005+#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
20062006+#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
20072007+#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
20082008+#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
20092009+#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
20102010+#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
20112011+#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
20122012+#define R_PARISC_FPTR64 64 /* 64 bits function address. */
20132013+#define R_PARISC_PLABEL32 65 /* 32 bits function address. */
20142014+#define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */
20152015+#define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */
20162016+#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
20172017+#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
20182018+#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
20192019+#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
20202020+#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */
20212021+#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */
20222022+#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */
20232023+#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */
20242024+#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */
20252025+#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */
20262026+#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */
20272027+#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */
20282028+#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */
20292029+#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */
20302030+#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */
20312031+#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */
20322032+#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */
20332033+#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */
20342034+#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */
20352035+#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */
20362036+#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */
20372037+#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */
20382038+#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */
20392039+#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
20402040+#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
20412041+#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
20422042+#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
20432043+#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
20442044+#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
20452045+#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */
20462046+#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */
20472047+#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */
20482048+#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */
20492049+#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */
20502050+#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */
20512051+#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */
20522052+#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */
20532053+#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */
20542054+#define R_PARISC_LORESERVE 128
20552055+#define R_PARISC_COPY 128 /* Copy relocation. */
20562056+#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */
20572057+#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */
20582058+#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */
20592059+#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */
20602060+#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */
20612061+#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */
20622062+#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/
20632063+#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */
20642064+#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */
20652065+#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */
20662066+#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */
20672067+#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */
20682068+#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */
20692069+#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */
20702070+#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */
20712071+#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/
20722072+#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/
20732073+#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */
20742074+#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */
20752075+#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */
20762076+#define R_PARISC_GNU_VTENTRY 232
20772077+#define R_PARISC_GNU_VTINHERIT 233
20782078+#define R_PARISC_TLS_GD21L 234 /* GD 21-bit left. */
20792079+#define R_PARISC_TLS_GD14R 235 /* GD 14-bit right. */
20802080+#define R_PARISC_TLS_GDCALL 236 /* GD call to __t_g_a. */
20812081+#define R_PARISC_TLS_LDM21L 237 /* LD module 21-bit left. */
20822082+#define R_PARISC_TLS_LDM14R 238 /* LD module 14-bit right. */
20832083+#define R_PARISC_TLS_LDMCALL 239 /* LD module call to __t_g_a. */
20842084+#define R_PARISC_TLS_LDO21L 240 /* LD offset 21-bit left. */
20852085+#define R_PARISC_TLS_LDO14R 241 /* LD offset 14-bit right. */
20862086+#define R_PARISC_TLS_DTPMOD32 242 /* DTP module 32-bit. */
20872087+#define R_PARISC_TLS_DTPMOD64 243 /* DTP module 64-bit. */
20882088+#define R_PARISC_TLS_DTPOFF32 244 /* DTP offset 32-bit. */
20892089+#define R_PARISC_TLS_DTPOFF64 245 /* DTP offset 32-bit. */
20902090+#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L
20912091+#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R
20922092+#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L
20932093+#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R
20942094+#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32
20952095+#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64
20962096+#define R_PARISC_HIRESERVE 255
20972097+20982098+/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */
20992099+21002100+#define PT_HP_TLS (PT_LOOS + 0x0)
21012101+#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
21022102+#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
21032103+#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
21042104+#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
21052105+#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
21062106+#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
21072107+#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
21082108+#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
21092109+#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
21102110+#define PT_HP_PARALLEL (PT_LOOS + 0x10)
21112111+#define PT_HP_FASTBIND (PT_LOOS + 0x11)
21122112+#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
21132113+#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
21142114+#define PT_HP_STACK (PT_LOOS + 0x14)
21152115+21162116+#define PT_PARISC_ARCHEXT 0x70000000
21172117+#define PT_PARISC_UNWIND 0x70000001
21182118+21192119+/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */
21202120+21212121+#define PF_PARISC_SBP 0x08000000
21222122+21232123+#define PF_HP_PAGE_SIZE 0x00100000
21242124+#define PF_HP_FAR_SHARED 0x00200000
21252125+#define PF_HP_NEAR_SHARED 0x00400000
21262126+#define PF_HP_CODE 0x01000000
21272127+#define PF_HP_MODIFY 0x02000000
21282128+#define PF_HP_LAZYSWAP 0x04000000
21292129+#define PF_HP_SBP 0x08000000
21302130+21312131+21322132+/* Alpha specific definitions. */
21332133+21342134+/* Legal values for e_flags field of Elf64_Ehdr. */
21352135+21362136+#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
21372137+#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
21382138+21392139+/* Legal values for sh_type field of Elf64_Shdr. */
21402140+21412141+/* These two are primerily concerned with ECOFF debugging info. */
21422142+#define SHT_ALPHA_DEBUG 0x70000001
21432143+#define SHT_ALPHA_REGINFO 0x70000002
21442144+21452145+/* Legal values for sh_flags field of Elf64_Shdr. */
21462146+21472147+#define SHF_ALPHA_GPREL 0x10000000
21482148+21492149+/* Legal values for st_other field of Elf64_Sym. */
21502150+#define STO_ALPHA_NOPV 0x80 /* No PV required. */
21512151+#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
21522152+21532153+/* Alpha relocs. */
21542154+21552155+#define R_ALPHA_NONE 0 /* No reloc */
21562156+#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
21572157+#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
21582158+#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
21592159+#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
21602160+#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
21612161+#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
21622162+#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
21632163+#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
21642164+#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
21652165+#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
21662166+#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
21672167+#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */
21682168+#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */
21692169+#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */
21702170+#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
21712171+#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
21722172+#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
21732173+#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
21742174+#define R_ALPHA_TLS_GD_HI 28
21752175+#define R_ALPHA_TLSGD 29
21762176+#define R_ALPHA_TLS_LDM 30
21772177+#define R_ALPHA_DTPMOD64 31
21782178+#define R_ALPHA_GOTDTPREL 32
21792179+#define R_ALPHA_DTPREL64 33
21802180+#define R_ALPHA_DTPRELHI 34
21812181+#define R_ALPHA_DTPRELLO 35
21822182+#define R_ALPHA_DTPREL16 36
21832183+#define R_ALPHA_GOTTPREL 37
21842184+#define R_ALPHA_TPREL64 38
21852185+#define R_ALPHA_TPRELHI 39
21862186+#define R_ALPHA_TPRELLO 40
21872187+#define R_ALPHA_TPREL16 41
21882188+/* Keep this the last entry. */
21892189+#define R_ALPHA_NUM 46
21902190+21912191+/* Magic values of the LITUSE relocation addend. */
21922192+#define LITUSE_ALPHA_ADDR 0
21932193+#define LITUSE_ALPHA_BASE 1
21942194+#define LITUSE_ALPHA_BYTOFF 2
21952195+#define LITUSE_ALPHA_JSR 3
21962196+#define LITUSE_ALPHA_TLS_GD 4
21972197+#define LITUSE_ALPHA_TLS_LDM 5
21982198+21992199+/* Legal values for d_tag of Elf64_Dyn. */
22002200+#define DT_ALPHA_PLTRO (DT_LOPROC + 0)
22012201+#define DT_ALPHA_NUM 1
22022202+22032203+/* PowerPC specific declarations */
22042204+22052205+/* Values for Elf32/64_Ehdr.e_flags. */
22062206+#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
22072207+22082208+/* Cygnus local bits below */
22092209+#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
22102210+#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
22112211+ flag */
22122212+22132213+/* PowerPC relocations defined by the ABIs */
22142214+#define R_PPC_NONE 0
22152215+#define R_PPC_ADDR32 1 /* 32bit absolute address */
22162216+#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
22172217+#define R_PPC_ADDR16 3 /* 16bit absolute address */
22182218+#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
22192219+#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
22202220+#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
22212221+#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
22222222+#define R_PPC_ADDR14_BRTAKEN 8
22232223+#define R_PPC_ADDR14_BRNTAKEN 9
22242224+#define R_PPC_REL24 10 /* PC relative 26 bit */
22252225+#define R_PPC_REL14 11 /* PC relative 16 bit */
22262226+#define R_PPC_REL14_BRTAKEN 12
22272227+#define R_PPC_REL14_BRNTAKEN 13
22282228+#define R_PPC_GOT16 14
22292229+#define R_PPC_GOT16_LO 15
22302230+#define R_PPC_GOT16_HI 16
22312231+#define R_PPC_GOT16_HA 17
22322232+#define R_PPC_PLTREL24 18
22332233+#define R_PPC_COPY 19
22342234+#define R_PPC_GLOB_DAT 20
22352235+#define R_PPC_JMP_SLOT 21
22362236+#define R_PPC_RELATIVE 22
22372237+#define R_PPC_LOCAL24PC 23
22382238+#define R_PPC_UADDR32 24
22392239+#define R_PPC_UADDR16 25
22402240+#define R_PPC_REL32 26
22412241+#define R_PPC_PLT32 27
22422242+#define R_PPC_PLTREL32 28
22432243+#define R_PPC_PLT16_LO 29
22442244+#define R_PPC_PLT16_HI 30
22452245+#define R_PPC_PLT16_HA 31
22462246+#define R_PPC_SDAREL16 32
22472247+#define R_PPC_SECTOFF 33
22482248+#define R_PPC_SECTOFF_LO 34
22492249+#define R_PPC_SECTOFF_HI 35
22502250+#define R_PPC_SECTOFF_HA 36
22512251+22522252+/* PowerPC relocations defined for the TLS access ABI. */
22532253+#define R_PPC_TLS 67 /* none (sym+add)@tls */
22542254+#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */
22552255+#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */
22562256+#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
22572257+#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
22582258+#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
22592259+#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */
22602260+#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */
22612261+#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
22622262+#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
22632263+#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
22642264+#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */
22652265+#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
22662266+#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
22672267+#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
22682268+#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
22692269+#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
22702270+#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
22712271+#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
22722272+#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
22732273+#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */
22742274+#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */
22752275+#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
22762276+#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
22772277+#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */
22782278+#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */
22792279+#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */
22802280+#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */
22812281+#define R_PPC_TLSGD 95 /* none (sym+add)@tlsgd */
22822282+#define R_PPC_TLSLD 96 /* none (sym+add)@tlsld */
22832283+22842284+/* The remaining relocs are from the Embedded ELF ABI, and are not
22852285+ in the SVR4 ELF ABI. */
22862286+#define R_PPC_EMB_NADDR32 101
22872287+#define R_PPC_EMB_NADDR16 102
22882288+#define R_PPC_EMB_NADDR16_LO 103
22892289+#define R_PPC_EMB_NADDR16_HI 104
22902290+#define R_PPC_EMB_NADDR16_HA 105
22912291+#define R_PPC_EMB_SDAI16 106
22922292+#define R_PPC_EMB_SDA2I16 107
22932293+#define R_PPC_EMB_SDA2REL 108
22942294+#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
22952295+#define R_PPC_EMB_MRKREF 110
22962296+#define R_PPC_EMB_RELSEC16 111
22972297+#define R_PPC_EMB_RELST_LO 112
22982298+#define R_PPC_EMB_RELST_HI 113
22992299+#define R_PPC_EMB_RELST_HA 114
23002300+#define R_PPC_EMB_BIT_FLD 115
23012301+#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
23022302+23032303+/* Diab tool relocations. */
23042304+#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
23052305+#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
23062306+#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
23072307+#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
23082308+#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
23092309+#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
23102310+23112311+/* GNU extension to support local ifunc. */
23122312+#define R_PPC_IRELATIVE 248
23132313+23142314+/* GNU relocs used in PIC code sequences. */
23152315+#define R_PPC_REL16 249 /* half16 (sym+add-.) */
23162316+#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */
23172317+#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */
23182318+#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */
23192319+23202320+/* This is a phony reloc to handle any old fashioned TOC16 references
23212321+ that may still be in object files. */
23222322+#define R_PPC_TOC16 255
23232323+23242324+/* PowerPC specific values for the Dyn d_tag field. */
23252325+#define DT_PPC_GOT (DT_LOPROC + 0)
23262326+#define DT_PPC_OPT (DT_LOPROC + 1)
23272327+#define DT_PPC_NUM 2
23282328+23292329+/* PowerPC specific values for the DT_PPC_OPT Dyn entry. */
23302330+#define PPC_OPT_TLS 1
23312331+23322332+/* PowerPC64 relocations defined by the ABIs */
23332333+#define R_PPC64_NONE R_PPC_NONE
23342334+#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */
23352335+#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */
23362336+#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */
23372337+#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */
23382338+#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */
23392339+#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */
23402340+#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */
23412341+#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
23422342+#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
23432343+#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */
23442344+#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */
23452345+#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
23462346+#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
23472347+#define R_PPC64_GOT16 R_PPC_GOT16
23482348+#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
23492349+#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
23502350+#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
23512351+23522352+#define R_PPC64_COPY R_PPC_COPY
23532353+#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
23542354+#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
23552355+#define R_PPC64_RELATIVE R_PPC_RELATIVE
23562356+23572357+#define R_PPC64_UADDR32 R_PPC_UADDR32
23582358+#define R_PPC64_UADDR16 R_PPC_UADDR16
23592359+#define R_PPC64_REL32 R_PPC_REL32
23602360+#define R_PPC64_PLT32 R_PPC_PLT32
23612361+#define R_PPC64_PLTREL32 R_PPC_PLTREL32
23622362+#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
23632363+#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
23642364+#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
23652365+23662366+#define R_PPC64_SECTOFF R_PPC_SECTOFF
23672367+#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
23682368+#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
23692369+#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
23702370+#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */
23712371+#define R_PPC64_ADDR64 38 /* doubleword64 S + A */
23722372+#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */
23732373+#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */
23742374+#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */
23752375+#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */
23762376+#define R_PPC64_UADDR64 43 /* doubleword64 S + A */
23772377+#define R_PPC64_REL64 44 /* doubleword64 S + A - P */
23782378+#define R_PPC64_PLT64 45 /* doubleword64 L + A */
23792379+#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */
23802380+#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */
23812381+#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */
23822382+#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */
23832383+#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */
23842384+#define R_PPC64_TOC 51 /* doubleword64 .TOC */
23852385+#define R_PPC64_PLTGOT16 52 /* half16* M + A */
23862386+#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */
23872387+#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */
23882388+#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */
23892389+23902390+#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */
23912391+#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */
23922392+#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */
23932393+#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */
23942394+#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */
23952395+#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */
23962396+#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */
23972397+#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */
23982398+#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */
23992399+#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */
24002400+#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */
24012401+24022402+/* PowerPC64 relocations defined for the TLS access ABI. */
24032403+#define R_PPC64_TLS 67 /* none (sym+add)@tls */
24042404+#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */
24052405+#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */
24062406+#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
24072407+#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
24082408+#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
24092409+#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */
24102410+#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */
24112411+#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
24122412+#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
24132413+#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
24142414+#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */
24152415+#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
24162416+#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
24172417+#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
24182418+#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
24192419+#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
24202420+#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
24212421+#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
24222422+#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
24232423+#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */
24242424+#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
24252425+#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
24262426+#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
24272427+#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */
24282428+#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
24292429+#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */
24302430+#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */
24312431+#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */
24322432+#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */
24332433+#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */
24342434+#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */
24352435+#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */
24362436+#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */
24372437+#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */
24382438+#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */
24392439+#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */
24402440+#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
24412441+#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
24422442+#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */
24432443+#define R_PPC64_TLSGD 107 /* none (sym+add)@tlsgd */
24442444+#define R_PPC64_TLSLD 108 /* none (sym+add)@tlsld */
24452445+#define R_PPC64_TOCSAVE 109 /* none */
24462446+24472447+/* Added when HA and HI relocs were changed to report overflows. */
24482448+#define R_PPC64_ADDR16_HIGH 110
24492449+#define R_PPC64_ADDR16_HIGHA 111
24502450+#define R_PPC64_TPREL16_HIGH 112
24512451+#define R_PPC64_TPREL16_HIGHA 113
24522452+#define R_PPC64_DTPREL16_HIGH 114
24532453+#define R_PPC64_DTPREL16_HIGHA 115
24542454+24552455+/* GNU extension to support local ifunc. */
24562456+#define R_PPC64_JMP_IREL 247
24572457+#define R_PPC64_IRELATIVE 248
24582458+#define R_PPC64_REL16 249 /* half16 (sym+add-.) */
24592459+#define R_PPC64_REL16_LO 250 /* half16 (sym+add-.)@l */
24602460+#define R_PPC64_REL16_HI 251 /* half16 (sym+add-.)@h */
24612461+#define R_PPC64_REL16_HA 252 /* half16 (sym+add-.)@ha */
24622462+24632463+/* e_flags bits specifying ABI.
24642464+ 1 for original function descriptor using ABI,
24652465+ 2 for revised ABI without function descriptors,
24662466+ 0 for unspecified or not using any features affected by the differences. */
24672467+#define EF_PPC64_ABI 3
24682468+24692469+/* PowerPC64 specific values for the Dyn d_tag field. */
24702470+#define DT_PPC64_GLINK (DT_LOPROC + 0)
24712471+#define DT_PPC64_OPD (DT_LOPROC + 1)
24722472+#define DT_PPC64_OPDSZ (DT_LOPROC + 2)
24732473+#define DT_PPC64_OPT (DT_LOPROC + 3)
24742474+#define DT_PPC64_NUM 4
24752475+24762476+/* PowerPC64 specific values for the DT_PPC64_OPT Dyn entry. */
24772477+#define PPC64_OPT_TLS 1
24782478+#define PPC64_OPT_MULTI_TOC 2
24792479+24802480+/* PowerPC64 specific values for the Elf64_Sym st_other field. */
24812481+#define STO_PPC64_LOCAL_BIT 5
24822482+#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT)
24832483+#define PPC64_LOCAL_ENTRY_OFFSET(other) \
24842484+ (((1 << (((other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2)
24852485+24862486+24872487+/* ARM specific declarations */
24882488+24892489+/* Processor specific flags for the ELF header e_flags field. */
24902490+#define EF_ARM_RELEXEC 0x01
24912491+#define EF_ARM_HASENTRY 0x02
24922492+#define EF_ARM_INTERWORK 0x04
24932493+#define EF_ARM_APCS_26 0x08
24942494+#define EF_ARM_APCS_FLOAT 0x10
24952495+#define EF_ARM_PIC 0x20
24962496+#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
24972497+#define EF_ARM_NEW_ABI 0x80
24982498+#define EF_ARM_OLD_ABI 0x100
24992499+#define EF_ARM_SOFT_FLOAT 0x200
25002500+#define EF_ARM_VFP_FLOAT 0x400
25012501+#define EF_ARM_MAVERICK_FLOAT 0x800
25022502+25032503+#define EF_ARM_ABI_FLOAT_SOFT 0x200 /* NB conflicts with EF_ARM_SOFT_FLOAT */
25042504+#define EF_ARM_ABI_FLOAT_HARD 0x400 /* NB conflicts with EF_ARM_VFP_FLOAT */
25052505+25062506+25072507+/* Other constants defined in the ARM ELF spec. version B-01. */
25082508+/* NB. These conflict with values defined above. */
25092509+#define EF_ARM_SYMSARESORTED 0x04
25102510+#define EF_ARM_DYNSYMSUSESEGIDX 0x08
25112511+#define EF_ARM_MAPSYMSFIRST 0x10
25122512+#define EF_ARM_EABIMASK 0XFF000000
25132513+25142514+/* Constants defined in AAELF. */
25152515+#define EF_ARM_BE8 0x00800000
25162516+#define EF_ARM_LE8 0x00400000
25172517+25182518+#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
25192519+#define EF_ARM_EABI_UNKNOWN 0x00000000
25202520+#define EF_ARM_EABI_VER1 0x01000000
25212521+#define EF_ARM_EABI_VER2 0x02000000
25222522+#define EF_ARM_EABI_VER3 0x03000000
25232523+#define EF_ARM_EABI_VER4 0x04000000
25242524+#define EF_ARM_EABI_VER5 0x05000000
25252525+25262526+/* Additional symbol types for Thumb. */
25272527+#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
25282528+#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
25292529+25302530+/* ARM-specific values for sh_flags */
25312531+#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
25322532+#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
25332533+ in the input to a link step. */
25342534+25352535+/* ARM-specific program header flags */
25362536+#define PF_ARM_SB 0x10000000 /* Segment contains the location
25372537+ addressed by the static base. */
25382538+#define PF_ARM_PI 0x20000000 /* Position-independent segment. */
25392539+#define PF_ARM_ABS 0x40000000 /* Absolute segment. */
25402540+25412541+/* Processor specific values for the Phdr p_type field. */
25422542+#define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */
25432543+25442544+/* Processor specific values for the Shdr sh_type field. */
25452545+#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
25462546+#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
25472547+#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
25482548+25492549+25502550+/* AArch64 relocs. */
25512551+25522552+#define R_AARCH64_NONE 0 /* No relocation. */
25532553+25542554+/* ILP32 AArch64 relocs. */
25552555+#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */
25562556+#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */
25572557+#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */
25582558+#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */
25592559+#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */
25602560+#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */
25612561+#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */
25622562+#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */
25632563+#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */
25642564+#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */
25652565+25662566+/* LP64 AArch64 relocs. */
25672567+#define R_AARCH64_ABS64 257 /* Direct 64 bit. */
25682568+#define R_AARCH64_ABS32 258 /* Direct 32 bit. */
25692569+#define R_AARCH64_ABS16 259 /* Direct 16-bit. */
25702570+#define R_AARCH64_PREL64 260 /* PC-relative 64-bit. */
25712571+#define R_AARCH64_PREL32 261 /* PC-relative 32-bit. */
25722572+#define R_AARCH64_PREL16 262 /* PC-relative 16-bit. */
25732573+#define R_AARCH64_MOVW_UABS_G0 263 /* Dir. MOVZ imm. from bits 15:0. */
25742574+#define R_AARCH64_MOVW_UABS_G0_NC 264 /* Likewise for MOVK; no check. */
25752575+#define R_AARCH64_MOVW_UABS_G1 265 /* Dir. MOVZ imm. from bits 31:16. */
25762576+#define R_AARCH64_MOVW_UABS_G1_NC 266 /* Likewise for MOVK; no check. */
25772577+#define R_AARCH64_MOVW_UABS_G2 267 /* Dir. MOVZ imm. from bits 47:32. */
25782578+#define R_AARCH64_MOVW_UABS_G2_NC 268 /* Likewise for MOVK; no check. */
25792579+#define R_AARCH64_MOVW_UABS_G3 269 /* Dir. MOV{K,Z} imm. from 63:48. */
25802580+#define R_AARCH64_MOVW_SABS_G0 270 /* Dir. MOV{N,Z} imm. from 15:0. */
25812581+#define R_AARCH64_MOVW_SABS_G1 271 /* Dir. MOV{N,Z} imm. from 31:16. */
25822582+#define R_AARCH64_MOVW_SABS_G2 272 /* Dir. MOV{N,Z} imm. from 47:32. */
25832583+#define R_AARCH64_LD_PREL_LO19 273 /* PC-rel. LD imm. from bits 20:2. */
25842584+#define R_AARCH64_ADR_PREL_LO21 274 /* PC-rel. ADR imm. from bits 20:0. */
25852585+#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page-rel. ADRP imm. from 32:12. */
25862586+#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Likewise; no overflow check. */
25872587+#define R_AARCH64_ADD_ABS_LO12_NC 277 /* Dir. ADD imm. from bits 11:0. */
25882588+#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* Likewise for LD/ST; no check. */
25892589+#define R_AARCH64_TSTBR14 279 /* PC-rel. TBZ/TBNZ imm. from 15:2. */
25902590+#define R_AARCH64_CONDBR19 280 /* PC-rel. cond. br. imm. from 20:2. */
25912591+#define R_AARCH64_JUMP26 282 /* PC-rel. B imm. from bits 27:2. */
25922592+#define R_AARCH64_CALL26 283 /* Likewise for CALL. */
25932593+#define R_AARCH64_LDST16_ABS_LO12_NC 284 /* Dir. ADD imm. from bits 11:1. */
25942594+#define R_AARCH64_LDST32_ABS_LO12_NC 285 /* Likewise for bits 11:2. */
25952595+#define R_AARCH64_LDST64_ABS_LO12_NC 286 /* Likewise for bits 11:3. */
25962596+#define R_AARCH64_MOVW_PREL_G0 287 /* PC-rel. MOV{N,Z} imm. from 15:0. */
25972597+#define R_AARCH64_MOVW_PREL_G0_NC 288 /* Likewise for MOVK; no check. */
25982598+#define R_AARCH64_MOVW_PREL_G1 289 /* PC-rel. MOV{N,Z} imm. from 31:16. */
25992599+#define R_AARCH64_MOVW_PREL_G1_NC 290 /* Likewise for MOVK; no check. */
26002600+#define R_AARCH64_MOVW_PREL_G2 291 /* PC-rel. MOV{N,Z} imm. from 47:32. */
26012601+#define R_AARCH64_MOVW_PREL_G2_NC 292 /* Likewise for MOVK; no check. */
26022602+#define R_AARCH64_MOVW_PREL_G3 293 /* PC-rel. MOV{N,Z} imm. from 63:48. */
26032603+#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* Dir. ADD imm. from bits 11:4. */
26042604+#define R_AARCH64_MOVW_GOTOFF_G0 300 /* GOT-rel. off. MOV{N,Z} imm. 15:0. */
26052605+#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* Likewise for MOVK; no check. */
26062606+#define R_AARCH64_MOVW_GOTOFF_G1 302 /* GOT-rel. o. MOV{N,Z} imm. 31:16. */
26072607+#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* Likewise for MOVK; no check. */
26082608+#define R_AARCH64_MOVW_GOTOFF_G2 304 /* GOT-rel. o. MOV{N,Z} imm. 47:32. */
26092609+#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* Likewise for MOVK; no check. */
26102610+#define R_AARCH64_MOVW_GOTOFF_G3 306 /* GOT-rel. o. MOV{N,Z} imm. 63:48. */
26112611+#define R_AARCH64_GOTREL64 307 /* GOT-relative 64-bit. */
26122612+#define R_AARCH64_GOTREL32 308 /* GOT-relative 32-bit. */
26132613+#define R_AARCH64_GOT_LD_PREL19 309 /* PC-rel. GOT off. load imm. 20:2. */
26142614+#define R_AARCH64_LD64_GOTOFF_LO15 310 /* GOT-rel. off. LD/ST imm. 14:3. */
26152615+#define R_AARCH64_ADR_GOT_PAGE 311 /* P-page-rel. GOT off. ADRP 32:12. */
26162616+#define R_AARCH64_LD64_GOT_LO12_NC 312 /* Dir. GOT off. LD/ST imm. 11:3. */
26172617+#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* GOT-page-rel. GOT off. LD/ST 14:3 */
26182618+#define R_AARCH64_TLSGD_ADR_PREL21 512 /* PC-relative ADR imm. 20:0. */
26192619+#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* page-rel. ADRP imm. 32:12. */
26202620+#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* direct ADD imm. from 11:0. */
26212621+#define R_AARCH64_TLSGD_MOVW_G1 515 /* GOT-rel. MOV{N,Z} 31:16. */
26222622+#define R_AARCH64_TLSGD_MOVW_G0_NC 516 /* GOT-rel. MOVK imm. 15:0. */
26232623+#define R_AARCH64_TLSLD_ADR_PREL21 517 /* Like 512; local dynamic model. */
26242624+#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Like 513; local dynamic model. */
26252625+#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* Like 514; local dynamic model. */
26262626+#define R_AARCH64_TLSLD_MOVW_G1 520 /* Like 515; local dynamic model. */
26272627+#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* Like 516; local dynamic model. */
26282628+#define R_AARCH64_TLSLD_LD_PREL19 522 /* TLS PC-rel. load imm. 20:2. */
26292629+#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* TLS DTP-rel. MOV{N,Z} 47:32. */
26302630+#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* TLS DTP-rel. MOV{N,Z} 31:16. */
26312631+#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* Likewise; MOVK; no check. */
26322632+#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* TLS DTP-rel. MOV{N,Z} 15:0. */
26332633+#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 /* Likewise; MOVK; no check. */
26342634+#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTP-rel. ADD imm. from 23:12. */
26352635+#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTP-rel. ADD imm. from 11:0. */
26362636+#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* Likewise; no ovfl. check. */
26372637+#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTP-rel. LD/ST imm. 11:0. */
26382638+#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* Likewise; no check. */
26392639+#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTP-rel. LD/ST imm. 11:1. */
26402640+#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* Likewise; no check. */
26412641+#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTP-rel. LD/ST imm. 11:2. */
26422642+#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* Likewise; no check. */
26432643+#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTP-rel. LD/ST imm. 11:3. */
26442644+#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* Likewise; no check. */
26452645+#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* GOT-rel. MOV{N,Z} 31:16. */
26462646+#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* GOT-rel. MOVK 15:0. */
26472647+#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page-rel. ADRP 32:12. */
26482648+#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* Direct LD off. 11:3. */
26492649+#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* PC-rel. load imm. 20:2. */
26502650+#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TLS TP-rel. MOV{N,Z} 47:32. */
26512651+#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 /* TLS TP-rel. MOV{N,Z} 31:16. */
26522652+#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 /* Likewise; MOVK; no check. */
26532653+#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 /* TLS TP-rel. MOV{N,Z} 15:0. */
26542654+#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 /* Likewise; MOVK; no check. */
26552655+#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 /* TP-rel. ADD imm. 23:12. */
26562656+#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 /* TP-rel. ADD imm. 11:0. */
26572657+#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 /* Likewise; no ovfl. check. */
26582658+#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 /* TP-rel. LD/ST off. 11:0. */
26592659+#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 /* Likewise; no ovfl. check. */
26602660+#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 /* TP-rel. LD/ST off. 11:1. */
26612661+#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 /* Likewise; no check. */
26622662+#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 /* TP-rel. LD/ST off. 11:2. */
26632663+#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 /* Likewise; no check. */
26642664+#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 /* TP-rel. LD/ST off. 11:3. */
26652665+#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 /* Likewise; no check. */
26662666+#define R_AARCH64_TLSDESC_LD_PREL19 560 /* PC-rel. load immediate 20:2. */
26672667+#define R_AARCH64_TLSDESC_ADR_PREL21 561 /* PC-rel. ADR immediate 20:0. */
26682668+#define R_AARCH64_TLSDESC_ADR_PAGE21 562 /* Page-rel. ADRP imm. 32:12. */
26692669+#define R_AARCH64_TLSDESC_LD64_LO12 563 /* Direct LD off. from 11:3. */
26702670+#define R_AARCH64_TLSDESC_ADD_LO12 564 /* Direct ADD imm. from 11:0. */
26712671+#define R_AARCH64_TLSDESC_OFF_G1 565 /* GOT-rel. MOV{N,Z} imm. 31:16. */
26722672+#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* GOT-rel. MOVK imm. 15:0; no ck. */
26732673+#define R_AARCH64_TLSDESC_LDR 567 /* Relax LDR. */
26742674+#define R_AARCH64_TLSDESC_ADD 568 /* Relax ADD. */
26752675+#define R_AARCH64_TLSDESC_CALL 569 /* Relax BLR. */
26762676+#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TP-rel. LD/ST off. 11:4. */
26772677+#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* Likewise; no check. */
26782678+#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTP-rel. LD/ST imm. 11:4. */
26792679+#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* Likewise; no check. */
26802680+#define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */
26812681+#define R_AARCH64_GLOB_DAT 1025 /* Create GOT entry. */
26822682+#define R_AARCH64_JUMP_SLOT 1026 /* Create PLT entry. */
26832683+#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */
26842684+#define R_AARCH64_TLS_DTPMOD 1028 /* Module number, 64 bit. */
26852685+#define R_AARCH64_TLS_DTPREL 1029 /* Module-relative offset, 64 bit. */
26862686+#define R_AARCH64_TLS_TPREL 1030 /* TP-relative offset, 64 bit. */
26872687+#define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */
26882688+#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */
26892689+26902690+/* ARM relocs. */
26912691+26922692+#define R_ARM_NONE 0 /* No reloc */
26932693+#define R_ARM_PC24 1 /* Deprecated PC relative 26
26942694+ bit branch. */
26952695+#define R_ARM_ABS32 2 /* Direct 32 bit */
26962696+#define R_ARM_REL32 3 /* PC relative 32 bit */
26972697+#define R_ARM_PC13 4
26982698+#define R_ARM_ABS16 5 /* Direct 16 bit */
26992699+#define R_ARM_ABS12 6 /* Direct 12 bit */
27002700+#define R_ARM_THM_ABS5 7 /* Direct & 0x7C (LDR, STR). */
27012701+#define R_ARM_ABS8 8 /* Direct 8 bit */
27022702+#define R_ARM_SBREL32 9
27032703+#define R_ARM_THM_PC22 10 /* PC relative 24 bit (Thumb32 BL). */
27042704+#define R_ARM_THM_PC8 11 /* PC relative & 0x3FC
27052705+ (Thumb16 LDR, ADD, ADR). */
27062706+#define R_ARM_AMP_VCALL9 12
27072707+#define R_ARM_SWI24 13 /* Obsolete static relocation. */
27082708+#define R_ARM_TLS_DESC 13 /* Dynamic relocation. */
27092709+#define R_ARM_THM_SWI8 14 /* Reserved. */
27102710+#define R_ARM_XPC25 15 /* Reserved. */
27112711+#define R_ARM_THM_XPC22 16 /* Reserved. */
27122712+#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */
27132713+#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */
27142714+#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */
27152715+#define R_ARM_COPY 20 /* Copy symbol at runtime */
27162716+#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
27172717+#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
27182718+#define R_ARM_RELATIVE 23 /* Adjust by program base */
27192719+#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
27202720+#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
27212721+#define R_ARM_GOT32 26 /* 32 bit GOT entry */
27222722+#define R_ARM_PLT32 27 /* Deprecated, 32 bit PLT address. */
27232723+#define R_ARM_CALL 28 /* PC relative 24 bit (BL, BLX). */
27242724+#define R_ARM_JUMP24 29 /* PC relative 24 bit
27252725+ (B, BL<cond>). */
27262726+#define R_ARM_THM_JUMP24 30 /* PC relative 24 bit (Thumb32 B.W). */
27272727+#define R_ARM_BASE_ABS 31 /* Adjust by program base. */
27282728+#define R_ARM_ALU_PCREL_7_0 32 /* Obsolete. */
27292729+#define R_ARM_ALU_PCREL_15_8 33 /* Obsolete. */
27302730+#define R_ARM_ALU_PCREL_23_15 34 /* Obsolete. */
27312731+#define R_ARM_LDR_SBREL_11_0 35 /* Deprecated, prog. base relative. */
27322732+#define R_ARM_ALU_SBREL_19_12 36 /* Deprecated, prog. base relative. */
27332733+#define R_ARM_ALU_SBREL_27_20 37 /* Deprecated, prog. base relative. */
27342734+#define R_ARM_TARGET1 38
27352735+#define R_ARM_SBREL31 39 /* Program base relative. */
27362736+#define R_ARM_V4BX 40
27372737+#define R_ARM_TARGET2 41
27382738+#define R_ARM_PREL31 42 /* 32 bit PC relative. */
27392739+#define R_ARM_MOVW_ABS_NC 43 /* Direct 16-bit (MOVW). */
27402740+#define R_ARM_MOVT_ABS 44 /* Direct high 16-bit (MOVT). */
27412741+#define R_ARM_MOVW_PREL_NC 45 /* PC relative 16-bit (MOVW). */
27422742+#define R_ARM_MOVT_PREL 46 /* PC relative (MOVT). */
27432743+#define R_ARM_THM_MOVW_ABS_NC 47 /* Direct 16 bit (Thumb32 MOVW). */
27442744+#define R_ARM_THM_MOVT_ABS 48 /* Direct high 16 bit
27452745+ (Thumb32 MOVT). */
27462746+#define R_ARM_THM_MOVW_PREL_NC 49 /* PC relative 16 bit
27472747+ (Thumb32 MOVW). */
27482748+#define R_ARM_THM_MOVT_PREL 50 /* PC relative high 16 bit
27492749+ (Thumb32 MOVT). */
27502750+#define R_ARM_THM_JUMP19 51 /* PC relative 20 bit
27512751+ (Thumb32 B<cond>.W). */
27522752+#define R_ARM_THM_JUMP6 52 /* PC relative X & 0x7E
27532753+ (Thumb16 CBZ, CBNZ). */
27542754+#define R_ARM_THM_ALU_PREL_11_0 53 /* PC relative 12 bit
27552755+ (Thumb32 ADR.W). */
27562756+#define R_ARM_THM_PC12 54 /* PC relative 12 bit
27572757+ (Thumb32 LDR{D,SB,H,SH}). */
27582758+#define R_ARM_ABS32_NOI 55 /* Direct 32-bit. */
27592759+#define R_ARM_REL32_NOI 56 /* PC relative 32-bit. */
27602760+#define R_ARM_ALU_PC_G0_NC 57 /* PC relative (ADD, SUB). */
27612761+#define R_ARM_ALU_PC_G0 58 /* PC relative (ADD, SUB). */
27622762+#define R_ARM_ALU_PC_G1_NC 59 /* PC relative (ADD, SUB). */
27632763+#define R_ARM_ALU_PC_G1 60 /* PC relative (ADD, SUB). */
27642764+#define R_ARM_ALU_PC_G2 61 /* PC relative (ADD, SUB). */
27652765+#define R_ARM_LDR_PC_G1 62 /* PC relative (LDR,STR,LDRB,STRB). */
27662766+#define R_ARM_LDR_PC_G2 63 /* PC relative (LDR,STR,LDRB,STRB). */
27672767+#define R_ARM_LDRS_PC_G0 64 /* PC relative (STR{D,H},
27682768+ LDR{D,SB,H,SH}). */
27692769+#define R_ARM_LDRS_PC_G1 65 /* PC relative (STR{D,H},
27702770+ LDR{D,SB,H,SH}). */
27712771+#define R_ARM_LDRS_PC_G2 66 /* PC relative (STR{D,H},
27722772+ LDR{D,SB,H,SH}). */
27732773+#define R_ARM_LDC_PC_G0 67 /* PC relative (LDC, STC). */
27742774+#define R_ARM_LDC_PC_G1 68 /* PC relative (LDC, STC). */
27752775+#define R_ARM_LDC_PC_G2 69 /* PC relative (LDC, STC). */
27762776+#define R_ARM_ALU_SB_G0_NC 70 /* Program base relative (ADD,SUB). */
27772777+#define R_ARM_ALU_SB_G0 71 /* Program base relative (ADD,SUB). */
27782778+#define R_ARM_ALU_SB_G1_NC 72 /* Program base relative (ADD,SUB). */
27792779+#define R_ARM_ALU_SB_G1 73 /* Program base relative (ADD,SUB). */
27802780+#define R_ARM_ALU_SB_G2 74 /* Program base relative (ADD,SUB). */
27812781+#define R_ARM_LDR_SB_G0 75 /* Program base relative (LDR,
27822782+ STR, LDRB, STRB). */
27832783+#define R_ARM_LDR_SB_G1 76 /* Program base relative
27842784+ (LDR, STR, LDRB, STRB). */
27852785+#define R_ARM_LDR_SB_G2 77 /* Program base relative
27862786+ (LDR, STR, LDRB, STRB). */
27872787+#define R_ARM_LDRS_SB_G0 78 /* Program base relative
27882788+ (LDR, STR, LDRB, STRB). */
27892789+#define R_ARM_LDRS_SB_G1 79 /* Program base relative
27902790+ (LDR, STR, LDRB, STRB). */
27912791+#define R_ARM_LDRS_SB_G2 80 /* Program base relative
27922792+ (LDR, STR, LDRB, STRB). */
27932793+#define R_ARM_LDC_SB_G0 81 /* Program base relative (LDC,STC). */
27942794+#define R_ARM_LDC_SB_G1 82 /* Program base relative (LDC,STC). */
27952795+#define R_ARM_LDC_SB_G2 83 /* Program base relative (LDC,STC). */
27962796+#define R_ARM_MOVW_BREL_NC 84 /* Program base relative 16
27972797+ bit (MOVW). */
27982798+#define R_ARM_MOVT_BREL 85 /* Program base relative high
27992799+ 16 bit (MOVT). */
28002800+#define R_ARM_MOVW_BREL 86 /* Program base relative 16
28012801+ bit (MOVW). */
28022802+#define R_ARM_THM_MOVW_BREL_NC 87 /* Program base relative 16
28032803+ bit (Thumb32 MOVW). */
28042804+#define R_ARM_THM_MOVT_BREL 88 /* Program base relative high
28052805+ 16 bit (Thumb32 MOVT). */
28062806+#define R_ARM_THM_MOVW_BREL 89 /* Program base relative 16
28072807+ bit (Thumb32 MOVW). */
28082808+#define R_ARM_TLS_GOTDESC 90
28092809+#define R_ARM_TLS_CALL 91
28102810+#define R_ARM_TLS_DESCSEQ 92 /* TLS relaxation. */
28112811+#define R_ARM_THM_TLS_CALL 93
28122812+#define R_ARM_PLT32_ABS 94
28132813+#define R_ARM_GOT_ABS 95 /* GOT entry. */
28142814+#define R_ARM_GOT_PREL 96 /* PC relative GOT entry. */
28152815+#define R_ARM_GOT_BREL12 97 /* GOT entry relative to GOT
28162816+ origin (LDR). */
28172817+#define R_ARM_GOTOFF12 98 /* 12 bit, GOT entry relative
28182818+ to GOT origin (LDR, STR). */
28192819+#define R_ARM_GOTRELAX 99
28202820+#define R_ARM_GNU_VTENTRY 100
28212821+#define R_ARM_GNU_VTINHERIT 101
28222822+#define R_ARM_THM_PC11 102 /* PC relative & 0xFFE (Thumb16 B). */
28232823+#define R_ARM_THM_PC9 103 /* PC relative & 0x1FE
28242824+ (Thumb16 B/B<cond>). */
28252825+#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic
28262826+ thread local data */
28272827+#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic
28282828+ thread local data */
28292829+#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS
28302830+ block */
28312831+#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of
28322832+ static TLS block offset */
28332833+#define R_ARM_TLS_LE32 108 /* 32 bit offset relative to static
28342834+ TLS block */
28352835+#define R_ARM_TLS_LDO12 109 /* 12 bit relative to TLS
28362836+ block (LDR, STR). */
28372837+#define R_ARM_TLS_LE12 110 /* 12 bit relative to static
28382838+ TLS block (LDR, STR). */
28392839+#define R_ARM_TLS_IE12GP 111 /* 12 bit GOT entry relative
28402840+ to GOT origin (LDR). */
28412841+#define R_ARM_ME_TOO 128 /* Obsolete. */
28422842+#define R_ARM_THM_TLS_DESCSEQ 129
28432843+#define R_ARM_THM_TLS_DESCSEQ16 129
28442844+#define R_ARM_THM_TLS_DESCSEQ32 130
28452845+#define R_ARM_THM_GOT_BREL12 131 /* GOT entry relative to GOT
28462846+ origin, 12 bit (Thumb32 LDR). */
28472847+#define R_ARM_IRELATIVE 160
28482848+#define R_ARM_RXPC25 249
28492849+#define R_ARM_RSBREL32 250
28502850+#define R_ARM_THM_RPC22 251
28512851+#define R_ARM_RREL32 252
28522852+#define R_ARM_RABS22 253
28532853+#define R_ARM_RPC24 254
28542854+#define R_ARM_RBASE 255
28552855+/* Keep this the last entry. */
28562856+#define R_ARM_NUM 256
28572857+28582858+/* IA-64 specific declarations. */
28592859+28602860+/* Processor specific flags for the Ehdr e_flags field. */
28612861+#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */
28622862+#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */
28632863+#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
28642864+28652865+/* Processor specific values for the Phdr p_type field. */
28662866+#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */
28672867+#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */
28682868+#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12)
28692869+#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13)
28702870+#define PT_IA_64_HP_STACK (PT_LOOS + 0x14)
28712871+28722872+/* Processor specific flags for the Phdr p_flags field. */
28732873+#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */
28742874+28752875+/* Processor specific values for the Shdr sh_type field. */
28762876+#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */
28772877+#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */
28782878+28792879+/* Processor specific flags for the Shdr sh_flags field. */
28802880+#define SHF_IA_64_SHORT 0x10000000 /* section near gp */
28812881+#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */
28822882+28832883+/* Processor specific values for the Dyn d_tag field. */
28842884+#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
28852885+#define DT_IA_64_NUM 1
28862886+28872887+/* IA-64 relocations. */
28882888+#define R_IA64_NONE 0x00 /* none */
28892889+#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */
28902890+#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */
28912891+#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
28922892+#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */
28932893+#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */
28942894+#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */
28952895+#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */
28962896+#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */
28972897+#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */
28982898+#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */
28992899+#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */
29002900+#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */
29012901+#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */
29022902+#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */
29032903+#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */
29042904+#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */
29052905+#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */
29062906+#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */
29072907+#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */
29082908+#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */
29092909+#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */
29102910+#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */
29112911+#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */
29122912+#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */
29132913+#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */
29142914+#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */
29152915+#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */
29162916+#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */
29172917+#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */
29182918+#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */
29192919+#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */
29202920+#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */
29212921+#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */
29222922+#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */
29232923+#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */
29242924+#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */
29252925+#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */
29262926+#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */
29272927+#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */
29282928+#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */
29292929+#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */
29302930+#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */
29312931+#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */
29322932+#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */
29332933+#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */
29342934+#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */
29352935+#define R_IA64_REL32MSB 0x6c /* data 4 + REL */
29362936+#define R_IA64_REL32LSB 0x6d /* data 4 + REL */
29372937+#define R_IA64_REL64MSB 0x6e /* data 8 + REL */
29382938+#define R_IA64_REL64LSB 0x6f /* data 8 + REL */
29392939+#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */
29402940+#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */
29412941+#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */
29422942+#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */
29432943+#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */
29442944+#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */
29452945+#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */
29462946+#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */
29472947+#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */
29482948+#define R_IA64_COPY 0x84 /* copy relocation */
29492949+#define R_IA64_SUB 0x85 /* Addend and symbol difference */
29502950+#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */
29512951+#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */
29522952+#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */
29532953+#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */
29542954+#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */
29552955+#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */
29562956+#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */
29572957+#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */
29582958+#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */
29592959+#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */
29602960+#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */
29612961+#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */
29622962+#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */
29632963+#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */
29642964+#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */
29652965+#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */
29662966+#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */
29672967+#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
29682968+#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
29692969+29702970+/* SH specific declarations */
29712971+29722972+/* Processor specific flags for the ELF header e_flags field. */
29732973+#define EF_SH_MACH_MASK 0x1f
29742974+#define EF_SH_UNKNOWN 0x0
29752975+#define EF_SH1 0x1
29762976+#define EF_SH2 0x2
29772977+#define EF_SH3 0x3
29782978+#define EF_SH_DSP 0x4
29792979+#define EF_SH3_DSP 0x5
29802980+#define EF_SH4AL_DSP 0x6
29812981+#define EF_SH3E 0x8
29822982+#define EF_SH4 0x9
29832983+#define EF_SH2E 0xb
29842984+#define EF_SH4A 0xc
29852985+#define EF_SH2A 0xd
29862986+#define EF_SH4_NOFPU 0x10
29872987+#define EF_SH4A_NOFPU 0x11
29882988+#define EF_SH4_NOMMU_NOFPU 0x12
29892989+#define EF_SH2A_NOFPU 0x13
29902990+#define EF_SH3_NOMMU 0x14
29912991+#define EF_SH2A_SH4_NOFPU 0x15
29922992+#define EF_SH2A_SH3_NOFPU 0x16
29932993+#define EF_SH2A_SH4 0x17
29942994+#define EF_SH2A_SH3E 0x18
29952995+29962996+/* SH relocs. */
29972997+#define R_SH_NONE 0
29982998+#define R_SH_DIR32 1
29992999+#define R_SH_REL32 2
30003000+#define R_SH_DIR8WPN 3
30013001+#define R_SH_IND12W 4
30023002+#define R_SH_DIR8WPL 5
30033003+#define R_SH_DIR8WPZ 6
30043004+#define R_SH_DIR8BP 7
30053005+#define R_SH_DIR8W 8
30063006+#define R_SH_DIR8L 9
30073007+#define R_SH_SWITCH16 25
30083008+#define R_SH_SWITCH32 26
30093009+#define R_SH_USES 27
30103010+#define R_SH_COUNT 28
30113011+#define R_SH_ALIGN 29
30123012+#define R_SH_CODE 30
30133013+#define R_SH_DATA 31
30143014+#define R_SH_LABEL 32
30153015+#define R_SH_SWITCH8 33
30163016+#define R_SH_GNU_VTINHERIT 34
30173017+#define R_SH_GNU_VTENTRY 35
30183018+#define R_SH_TLS_GD_32 144
30193019+#define R_SH_TLS_LD_32 145
30203020+#define R_SH_TLS_LDO_32 146
30213021+#define R_SH_TLS_IE_32 147
30223022+#define R_SH_TLS_LE_32 148
30233023+#define R_SH_TLS_DTPMOD32 149
30243024+#define R_SH_TLS_DTPOFF32 150
30253025+#define R_SH_TLS_TPOFF32 151
30263026+#define R_SH_GOT32 160
30273027+#define R_SH_PLT32 161
30283028+#define R_SH_COPY 162
30293029+#define R_SH_GLOB_DAT 163
30303030+#define R_SH_JMP_SLOT 164
30313031+#define R_SH_RELATIVE 165
30323032+#define R_SH_GOTOFF 166
30333033+#define R_SH_GOTPC 167
30343034+/* Keep this the last entry. */
30353035+#define R_SH_NUM 256
30363036+30373037+/* S/390 specific definitions. */
30383038+30393039+/* Valid values for the e_flags field. */
30403040+30413041+#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed. */
30423042+30433043+/* Additional s390 relocs */
30443044+30453045+#define R_390_NONE 0 /* No reloc. */
30463046+#define R_390_8 1 /* Direct 8 bit. */
30473047+#define R_390_12 2 /* Direct 12 bit. */
30483048+#define R_390_16 3 /* Direct 16 bit. */
30493049+#define R_390_32 4 /* Direct 32 bit. */
30503050+#define R_390_PC32 5 /* PC relative 32 bit. */
30513051+#define R_390_GOT12 6 /* 12 bit GOT offset. */
30523052+#define R_390_GOT32 7 /* 32 bit GOT offset. */
30533053+#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */
30543054+#define R_390_COPY 9 /* Copy symbol at runtime. */
30553055+#define R_390_GLOB_DAT 10 /* Create GOT entry. */
30563056+#define R_390_JMP_SLOT 11 /* Create PLT entry. */
30573057+#define R_390_RELATIVE 12 /* Adjust by program base. */
30583058+#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */
30593059+#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */
30603060+#define R_390_GOT16 15 /* 16 bit GOT offset. */
30613061+#define R_390_PC16 16 /* PC relative 16 bit. */
30623062+#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */
30633063+#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */
30643064+#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */
30653065+#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */
30663066+#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */
30673067+#define R_390_64 22 /* Direct 64 bit. */
30683068+#define R_390_PC64 23 /* PC relative 64 bit. */
30693069+#define R_390_GOT64 24 /* 64 bit GOT offset. */
30703070+#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */
30713071+#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */
30723072+#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */
30733073+#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */
30743074+#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */
30753075+#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */
30763076+#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */
30773077+#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */
30783078+#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */
30793079+#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */
30803080+#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */
30813081+#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */
30823082+#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */
30833083+#define R_390_TLS_GDCALL 38 /* Tag for function call in general
30843084+ dynamic TLS code. */
30853085+#define R_390_TLS_LDCALL 39 /* Tag for function call in local
30863086+ dynamic TLS code. */
30873087+#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic
30883088+ thread local data. */
30893089+#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic
30903090+ thread local data. */
30913091+#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS
30923092+ block offset. */
30933093+#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS
30943094+ block offset. */
30953095+#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS
30963096+ block offset. */
30973097+#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic
30983098+ thread local data in LE code. */
30993099+#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic
31003100+ thread local data in LE code. */
31013101+#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for
31023102+ negated static TLS block offset. */
31033103+#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for
31043104+ negated static TLS block offset. */
31053105+#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for
31063106+ negated static TLS block offset. */
31073107+#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to
31083108+ static TLS block. */
31093109+#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to
31103110+ static TLS block. */
31113111+#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS
31123112+ block. */
31133113+#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS
31143114+ block. */
31153115+#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */
31163116+#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */
31173117+#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS
31183118+ block. */
31193119+#define R_390_20 57 /* Direct 20 bit. */
31203120+#define R_390_GOT20 58 /* 20 bit GOT offset. */
31213121+#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */
31223122+#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS
31233123+ block offset. */
31243124+#define R_390_IRELATIVE 61 /* STT_GNU_IFUNC relocation. */
31253125+/* Keep this the last entry. */
31263126+#define R_390_NUM 62
31273127+31283128+31293129+/* CRIS relocations. */
31303130+#define R_CRIS_NONE 0
31313131+#define R_CRIS_8 1
31323132+#define R_CRIS_16 2
31333133+#define R_CRIS_32 3
31343134+#define R_CRIS_8_PCREL 4
31353135+#define R_CRIS_16_PCREL 5
31363136+#define R_CRIS_32_PCREL 6
31373137+#define R_CRIS_GNU_VTINHERIT 7
31383138+#define R_CRIS_GNU_VTENTRY 8
31393139+#define R_CRIS_COPY 9
31403140+#define R_CRIS_GLOB_DAT 10
31413141+#define R_CRIS_JUMP_SLOT 11
31423142+#define R_CRIS_RELATIVE 12
31433143+#define R_CRIS_16_GOT 13
31443144+#define R_CRIS_32_GOT 14
31453145+#define R_CRIS_16_GOTPLT 15
31463146+#define R_CRIS_32_GOTPLT 16
31473147+#define R_CRIS_32_GOTREL 17
31483148+#define R_CRIS_32_PLT_GOTREL 18
31493149+#define R_CRIS_32_PLT_PCREL 19
31503150+31513151+#define R_CRIS_NUM 20
31523152+31533153+31543154+/* AMD x86-64 relocations. */
31553155+#define R_X86_64_NONE 0 /* No reloc */
31563156+#define R_X86_64_64 1 /* Direct 64 bit */
31573157+#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
31583158+#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
31593159+#define R_X86_64_PLT32 4 /* 32 bit PLT address */
31603160+#define R_X86_64_COPY 5 /* Copy symbol at runtime */
31613161+#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
31623162+#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
31633163+#define R_X86_64_RELATIVE 8 /* Adjust by program base */
31643164+#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative
31653165+ offset to GOT */
31663166+#define R_X86_64_32 10 /* Direct 32 bit zero extended */
31673167+#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
31683168+#define R_X86_64_16 12 /* Direct 16 bit zero extended */
31693169+#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
31703170+#define R_X86_64_8 14 /* Direct 8 bit sign extended */
31713171+#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
31723172+#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
31733173+#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */
31743174+#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */
31753175+#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset
31763176+ to two GOT entries for GD symbol */
31773177+#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset
31783178+ to two GOT entries for LD symbol */
31793179+#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
31803180+#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset
31813181+ to GOT entry for IE symbol */
31823182+#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */
31833183+#define R_X86_64_PC64 24 /* PC relative 64 bit */
31843184+#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */
31853185+#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative
31863186+ offset to GOT */
31873187+#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */
31883188+#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset
31893189+ to GOT entry */
31903190+#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */
31913191+#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */
31923192+#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset
31933193+ to PLT entry */
31943194+#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */
31953195+#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */
31963196+#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor. */
31973197+#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS
31983198+ descriptor. */
31993199+#define R_X86_64_TLSDESC 36 /* TLS descriptor. */
32003200+#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */
32013201+#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */
32023202+ /* 39 Reserved was R_X86_64_PC32_BND */
32033203+ /* 40 Reserved was R_X86_64_PLT32_BND */
32043204+#define R_X86_64_GOTPCRELX 41 /* Load from 32 bit signed pc relative
32053205+ offset to GOT entry without REX
32063206+ prefix, relaxable. */
32073207+#define R_X86_64_REX_GOTPCRELX 42 /* Load from 32 bit signed pc relative
32083208+ offset to GOT entry with REX prefix,
32093209+ relaxable. */
32103210+#define R_X86_64_NUM 43
32113211+32123212+32133213+/* AM33 relocations. */
32143214+#define R_MN10300_NONE 0 /* No reloc. */
32153215+#define R_MN10300_32 1 /* Direct 32 bit. */
32163216+#define R_MN10300_16 2 /* Direct 16 bit. */
32173217+#define R_MN10300_8 3 /* Direct 8 bit. */
32183218+#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */
32193219+#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */
32203220+#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */
32213221+#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */
32223222+#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */
32233223+#define R_MN10300_24 9 /* Direct 24 bit. */
32243224+#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */
32253225+#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */
32263226+#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */
32273227+#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */
32283228+#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */
32293229+#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */
32303230+#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */
32313231+#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */
32323232+#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */
32333233+#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */
32343234+#define R_MN10300_COPY 20 /* Copy symbol at runtime. */
32353235+#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */
32363236+#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */
32373237+#define R_MN10300_RELATIVE 23 /* Adjust by program base. */
32383238+#define R_MN10300_TLS_GD 24 /* 32-bit offset for global dynamic. */
32393239+#define R_MN10300_TLS_LD 25 /* 32-bit offset for local dynamic. */
32403240+#define R_MN10300_TLS_LDO 26 /* Module-relative offset. */
32413241+#define R_MN10300_TLS_GOTIE 27 /* GOT offset for static TLS block
32423242+ offset. */
32433243+#define R_MN10300_TLS_IE 28 /* GOT address for static TLS block
32443244+ offset. */
32453245+#define R_MN10300_TLS_LE 29 /* Offset relative to static TLS
32463246+ block. */
32473247+#define R_MN10300_TLS_DTPMOD 30 /* ID of module containing symbol. */
32483248+#define R_MN10300_TLS_DTPOFF 31 /* Offset in module TLS block. */
32493249+#define R_MN10300_TLS_TPOFF 32 /* Offset in static TLS block. */
32503250+#define R_MN10300_SYM_DIFF 33 /* Adjustment for next reloc as needed
32513251+ by linker relaxation. */
32523252+#define R_MN10300_ALIGN 34 /* Alignment requirement for linker
32533253+ relaxation. */
32543254+#define R_MN10300_NUM 35
32553255+32563256+32573257+/* M32R relocs. */
32583258+#define R_M32R_NONE 0 /* No reloc. */
32593259+#define R_M32R_16 1 /* Direct 16 bit. */
32603260+#define R_M32R_32 2 /* Direct 32 bit. */
32613261+#define R_M32R_24 3 /* Direct 24 bit. */
32623262+#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */
32633263+#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */
32643264+#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */
32653265+#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */
32663266+#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */
32673267+#define R_M32R_LO16 9 /* Low 16 bit. */
32683268+#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */
32693269+#define R_M32R_GNU_VTINHERIT 11
32703270+#define R_M32R_GNU_VTENTRY 12
32713271+/* M32R relocs use SHT_RELA. */
32723272+#define R_M32R_16_RELA 33 /* Direct 16 bit. */
32733273+#define R_M32R_32_RELA 34 /* Direct 32 bit. */
32743274+#define R_M32R_24_RELA 35 /* Direct 24 bit. */
32753275+#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */
32763276+#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */
32773277+#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */
32783278+#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */
32793279+#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */
32803280+#define R_M32R_LO16_RELA 41 /* Low 16 bit */
32813281+#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */
32823282+#define R_M32R_RELA_GNU_VTINHERIT 43
32833283+#define R_M32R_RELA_GNU_VTENTRY 44
32843284+#define R_M32R_REL32 45 /* PC relative 32 bit. */
32853285+32863286+#define R_M32R_GOT24 48 /* 24 bit GOT entry */
32873287+#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */
32883288+#define R_M32R_COPY 50 /* Copy symbol at runtime */
32893289+#define R_M32R_GLOB_DAT 51 /* Create GOT entry */
32903290+#define R_M32R_JMP_SLOT 52 /* Create PLT entry */
32913291+#define R_M32R_RELATIVE 53 /* Adjust by program base */
32923292+#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */
32933293+#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */
32943294+#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned
32953295+ low */
32963296+#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed
32973297+ low */
32983298+#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */
32993299+#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to
33003300+ GOT with unsigned low */
33013301+#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to
33023302+ GOT with signed low */
33033303+#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to
33043304+ GOT */
33053305+#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT
33063306+ with unsigned low */
33073307+#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT
33083308+ with signed low */
33093309+#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */
33103310+#define R_M32R_NUM 256 /* Keep this the last entry. */
33113311+33123312+/* MicroBlaze relocations */
33133313+#define R_MICROBLAZE_NONE 0 /* No reloc. */
33143314+#define R_MICROBLAZE_32 1 /* Direct 32 bit. */
33153315+#define R_MICROBLAZE_32_PCREL 2 /* PC relative 32 bit. */
33163316+#define R_MICROBLAZE_64_PCREL 3 /* PC relative 64 bit. */
33173317+#define R_MICROBLAZE_32_PCREL_LO 4 /* Low 16 bits of PCREL32. */
33183318+#define R_MICROBLAZE_64 5 /* Direct 64 bit. */
33193319+#define R_MICROBLAZE_32_LO 6 /* Low 16 bit. */
33203320+#define R_MICROBLAZE_SRO32 7 /* Read-only small data area. */
33213321+#define R_MICROBLAZE_SRW32 8 /* Read-write small data area. */
33223322+#define R_MICROBLAZE_64_NONE 9 /* No reloc. */
33233323+#define R_MICROBLAZE_32_SYM_OP_SYM 10 /* Symbol Op Symbol relocation. */
33243324+#define R_MICROBLAZE_GNU_VTINHERIT 11 /* GNU C++ vtable hierarchy. */
33253325+#define R_MICROBLAZE_GNU_VTENTRY 12 /* GNU C++ vtable member usage. */
33263326+#define R_MICROBLAZE_GOTPC_64 13 /* PC-relative GOT offset. */
33273327+#define R_MICROBLAZE_GOT_64 14 /* GOT entry offset. */
33283328+#define R_MICROBLAZE_PLT_64 15 /* PLT offset (PC-relative). */
33293329+#define R_MICROBLAZE_REL 16 /* Adjust by program base. */
33303330+#define R_MICROBLAZE_JUMP_SLOT 17 /* Create PLT entry. */
33313331+#define R_MICROBLAZE_GLOB_DAT 18 /* Create GOT entry. */
33323332+#define R_MICROBLAZE_GOTOFF_64 19 /* 64 bit offset to GOT. */
33333333+#define R_MICROBLAZE_GOTOFF_32 20 /* 32 bit offset to GOT. */
33343334+#define R_MICROBLAZE_COPY 21 /* Runtime copy. */
33353335+#define R_MICROBLAZE_TLS 22 /* TLS Reloc. */
33363336+#define R_MICROBLAZE_TLSGD 23 /* TLS General Dynamic. */
33373337+#define R_MICROBLAZE_TLSLD 24 /* TLS Local Dynamic. */
33383338+#define R_MICROBLAZE_TLSDTPMOD32 25 /* TLS Module ID. */
33393339+#define R_MICROBLAZE_TLSDTPREL32 26 /* TLS Offset Within TLS Block. */
33403340+#define R_MICROBLAZE_TLSDTPREL64 27 /* TLS Offset Within TLS Block. */
33413341+#define R_MICROBLAZE_TLSGOTTPREL32 28 /* TLS Offset From Thread Pointer. */
33423342+#define R_MICROBLAZE_TLSTPREL32 29 /* TLS Offset From Thread Pointer. */
33433343+33443344+/* Legal values for d_tag (dynamic entry type). */
33453345+#define DT_NIOS2_GP 0x70000002 /* Address of _gp. */
33463346+33473347+/* Nios II relocations. */
33483348+#define R_NIOS2_NONE 0 /* No reloc. */
33493349+#define R_NIOS2_S16 1 /* Direct signed 16 bit. */
33503350+#define R_NIOS2_U16 2 /* Direct unsigned 16 bit. */
33513351+#define R_NIOS2_PCREL16 3 /* PC relative 16 bit. */
33523352+#define R_NIOS2_CALL26 4 /* Direct call. */
33533353+#define R_NIOS2_IMM5 5 /* 5 bit constant expression. */
33543354+#define R_NIOS2_CACHE_OPX 6 /* 5 bit expression, shift 22. */
33553355+#define R_NIOS2_IMM6 7 /* 6 bit constant expression. */
33563356+#define R_NIOS2_IMM8 8 /* 8 bit constant expression. */
33573357+#define R_NIOS2_HI16 9 /* High 16 bit. */
33583358+#define R_NIOS2_LO16 10 /* Low 16 bit. */
33593359+#define R_NIOS2_HIADJ16 11 /* High 16 bit, adjusted. */
33603360+#define R_NIOS2_BFD_RELOC_32 12 /* 32 bit symbol value + addend. */
33613361+#define R_NIOS2_BFD_RELOC_16 13 /* 16 bit symbol value + addend. */
33623362+#define R_NIOS2_BFD_RELOC_8 14 /* 8 bit symbol value + addend. */
33633363+#define R_NIOS2_GPREL 15 /* 16 bit GP pointer offset. */
33643364+#define R_NIOS2_GNU_VTINHERIT 16 /* GNU C++ vtable hierarchy. */
33653365+#define R_NIOS2_GNU_VTENTRY 17 /* GNU C++ vtable member usage. */
33663366+#define R_NIOS2_UJMP 18 /* Unconditional branch. */
33673367+#define R_NIOS2_CJMP 19 /* Conditional branch. */
33683368+#define R_NIOS2_CALLR 20 /* Indirect call through register. */
33693369+#define R_NIOS2_ALIGN 21 /* Alignment requirement for
33703370+ linker relaxation. */
33713371+#define R_NIOS2_GOT16 22 /* 16 bit GOT entry. */
33723372+#define R_NIOS2_CALL16 23 /* 16 bit GOT entry for function. */
33733373+#define R_NIOS2_GOTOFF_LO 24 /* %lo of offset to GOT pointer. */
33743374+#define R_NIOS2_GOTOFF_HA 25 /* %hiadj of offset to GOT pointer. */
33753375+#define R_NIOS2_PCREL_LO 26 /* %lo of PC relative offset. */
33763376+#define R_NIOS2_PCREL_HA 27 /* %hiadj of PC relative offset. */
33773377+#define R_NIOS2_TLS_GD16 28 /* 16 bit GOT offset for TLS GD. */
33783378+#define R_NIOS2_TLS_LDM16 29 /* 16 bit GOT offset for TLS LDM. */
33793379+#define R_NIOS2_TLS_LDO16 30 /* 16 bit module relative offset. */
33803380+#define R_NIOS2_TLS_IE16 31 /* 16 bit GOT offset for TLS IE. */
33813381+#define R_NIOS2_TLS_LE16 32 /* 16 bit LE TP-relative offset. */
33823382+#define R_NIOS2_TLS_DTPMOD 33 /* Module number. */
33833383+#define R_NIOS2_TLS_DTPREL 34 /* Module-relative offset. */
33843384+#define R_NIOS2_TLS_TPREL 35 /* TP-relative offset. */
33853385+#define R_NIOS2_COPY 36 /* Copy symbol at runtime. */
33863386+#define R_NIOS2_GLOB_DAT 37 /* Create GOT entry. */
33873387+#define R_NIOS2_JUMP_SLOT 38 /* Create PLT entry. */
33883388+#define R_NIOS2_RELATIVE 39 /* Adjust by program base. */
33893389+#define R_NIOS2_GOTOFF 40 /* 16 bit offset to GOT pointer. */
33903390+#define R_NIOS2_CALL26_NOAT 41 /* Direct call in .noat section. */
33913391+#define R_NIOS2_GOT_LO 42 /* %lo() of GOT entry. */
33923392+#define R_NIOS2_GOT_HA 43 /* %hiadj() of GOT entry. */
33933393+#define R_NIOS2_CALL_LO 44 /* %lo() of function GOT entry. */
33943394+#define R_NIOS2_CALL_HA 45 /* %hiadj() of function GOT entry. */
33953395+33963396+/* TILEPro relocations. */
33973397+#define R_TILEPRO_NONE 0 /* No reloc */
33983398+#define R_TILEPRO_32 1 /* Direct 32 bit */
33993399+#define R_TILEPRO_16 2 /* Direct 16 bit */
34003400+#define R_TILEPRO_8 3 /* Direct 8 bit */
34013401+#define R_TILEPRO_32_PCREL 4 /* PC relative 32 bit */
34023402+#define R_TILEPRO_16_PCREL 5 /* PC relative 16 bit */
34033403+#define R_TILEPRO_8_PCREL 6 /* PC relative 8 bit */
34043404+#define R_TILEPRO_LO16 7 /* Low 16 bit */
34053405+#define R_TILEPRO_HI16 8 /* High 16 bit */
34063406+#define R_TILEPRO_HA16 9 /* High 16 bit, adjusted */
34073407+#define R_TILEPRO_COPY 10 /* Copy relocation */
34083408+#define R_TILEPRO_GLOB_DAT 11 /* Create GOT entry */
34093409+#define R_TILEPRO_JMP_SLOT 12 /* Create PLT entry */
34103410+#define R_TILEPRO_RELATIVE 13 /* Adjust by program base */
34113411+#define R_TILEPRO_BROFF_X1 14 /* X1 pipe branch offset */
34123412+#define R_TILEPRO_JOFFLONG_X1 15 /* X1 pipe jump offset */
34133413+#define R_TILEPRO_JOFFLONG_X1_PLT 16 /* X1 pipe jump offset to PLT */
34143414+#define R_TILEPRO_IMM8_X0 17 /* X0 pipe 8-bit */
34153415+#define R_TILEPRO_IMM8_Y0 18 /* Y0 pipe 8-bit */
34163416+#define R_TILEPRO_IMM8_X1 19 /* X1 pipe 8-bit */
34173417+#define R_TILEPRO_IMM8_Y1 20 /* Y1 pipe 8-bit */
34183418+#define R_TILEPRO_MT_IMM15_X1 21 /* X1 pipe mtspr */
34193419+#define R_TILEPRO_MF_IMM15_X1 22 /* X1 pipe mfspr */
34203420+#define R_TILEPRO_IMM16_X0 23 /* X0 pipe 16-bit */
34213421+#define R_TILEPRO_IMM16_X1 24 /* X1 pipe 16-bit */
34223422+#define R_TILEPRO_IMM16_X0_LO 25 /* X0 pipe low 16-bit */
34233423+#define R_TILEPRO_IMM16_X1_LO 26 /* X1 pipe low 16-bit */
34243424+#define R_TILEPRO_IMM16_X0_HI 27 /* X0 pipe high 16-bit */
34253425+#define R_TILEPRO_IMM16_X1_HI 28 /* X1 pipe high 16-bit */
34263426+#define R_TILEPRO_IMM16_X0_HA 29 /* X0 pipe high 16-bit, adjusted */
34273427+#define R_TILEPRO_IMM16_X1_HA 30 /* X1 pipe high 16-bit, adjusted */
34283428+#define R_TILEPRO_IMM16_X0_PCREL 31 /* X0 pipe PC relative 16 bit */
34293429+#define R_TILEPRO_IMM16_X1_PCREL 32 /* X1 pipe PC relative 16 bit */
34303430+#define R_TILEPRO_IMM16_X0_LO_PCREL 33 /* X0 pipe PC relative low 16 bit */
34313431+#define R_TILEPRO_IMM16_X1_LO_PCREL 34 /* X1 pipe PC relative low 16 bit */
34323432+#define R_TILEPRO_IMM16_X0_HI_PCREL 35 /* X0 pipe PC relative high 16 bit */
34333433+#define R_TILEPRO_IMM16_X1_HI_PCREL 36 /* X1 pipe PC relative high 16 bit */
34343434+#define R_TILEPRO_IMM16_X0_HA_PCREL 37 /* X0 pipe PC relative ha() 16 bit */
34353435+#define R_TILEPRO_IMM16_X1_HA_PCREL 38 /* X1 pipe PC relative ha() 16 bit */
34363436+#define R_TILEPRO_IMM16_X0_GOT 39 /* X0 pipe 16-bit GOT offset */
34373437+#define R_TILEPRO_IMM16_X1_GOT 40 /* X1 pipe 16-bit GOT offset */
34383438+#define R_TILEPRO_IMM16_X0_GOT_LO 41 /* X0 pipe low 16-bit GOT offset */
34393439+#define R_TILEPRO_IMM16_X1_GOT_LO 42 /* X1 pipe low 16-bit GOT offset */
34403440+#define R_TILEPRO_IMM16_X0_GOT_HI 43 /* X0 pipe high 16-bit GOT offset */
34413441+#define R_TILEPRO_IMM16_X1_GOT_HI 44 /* X1 pipe high 16-bit GOT offset */
34423442+#define R_TILEPRO_IMM16_X0_GOT_HA 45 /* X0 pipe ha() 16-bit GOT offset */
34433443+#define R_TILEPRO_IMM16_X1_GOT_HA 46 /* X1 pipe ha() 16-bit GOT offset */
34443444+#define R_TILEPRO_MMSTART_X0 47 /* X0 pipe mm "start" */
34453445+#define R_TILEPRO_MMEND_X0 48 /* X0 pipe mm "end" */
34463446+#define R_TILEPRO_MMSTART_X1 49 /* X1 pipe mm "start" */
34473447+#define R_TILEPRO_MMEND_X1 50 /* X1 pipe mm "end" */
34483448+#define R_TILEPRO_SHAMT_X0 51 /* X0 pipe shift amount */
34493449+#define R_TILEPRO_SHAMT_X1 52 /* X1 pipe shift amount */
34503450+#define R_TILEPRO_SHAMT_Y0 53 /* Y0 pipe shift amount */
34513451+#define R_TILEPRO_SHAMT_Y1 54 /* Y1 pipe shift amount */
34523452+#define R_TILEPRO_DEST_IMM8_X1 55 /* X1 pipe destination 8-bit */
34533453+/* Relocs 56-59 are currently not defined. */
34543454+#define R_TILEPRO_TLS_GD_CALL 60 /* "jal" for TLS GD */
34553455+#define R_TILEPRO_IMM8_X0_TLS_GD_ADD 61 /* X0 pipe "addi" for TLS GD */
34563456+#define R_TILEPRO_IMM8_X1_TLS_GD_ADD 62 /* X1 pipe "addi" for TLS GD */
34573457+#define R_TILEPRO_IMM8_Y0_TLS_GD_ADD 63 /* Y0 pipe "addi" for TLS GD */
34583458+#define R_TILEPRO_IMM8_Y1_TLS_GD_ADD 64 /* Y1 pipe "addi" for TLS GD */
34593459+#define R_TILEPRO_TLS_IE_LOAD 65 /* "lw_tls" for TLS IE */
34603460+#define R_TILEPRO_IMM16_X0_TLS_GD 66 /* X0 pipe 16-bit TLS GD offset */
34613461+#define R_TILEPRO_IMM16_X1_TLS_GD 67 /* X1 pipe 16-bit TLS GD offset */
34623462+#define R_TILEPRO_IMM16_X0_TLS_GD_LO 68 /* X0 pipe low 16-bit TLS GD offset */
34633463+#define R_TILEPRO_IMM16_X1_TLS_GD_LO 69 /* X1 pipe low 16-bit TLS GD offset */
34643464+#define R_TILEPRO_IMM16_X0_TLS_GD_HI 70 /* X0 pipe high 16-bit TLS GD offset */
34653465+#define R_TILEPRO_IMM16_X1_TLS_GD_HI 71 /* X1 pipe high 16-bit TLS GD offset */
34663466+#define R_TILEPRO_IMM16_X0_TLS_GD_HA 72 /* X0 pipe ha() 16-bit TLS GD offset */
34673467+#define R_TILEPRO_IMM16_X1_TLS_GD_HA 73 /* X1 pipe ha() 16-bit TLS GD offset */
34683468+#define R_TILEPRO_IMM16_X0_TLS_IE 74 /* X0 pipe 16-bit TLS IE offset */
34693469+#define R_TILEPRO_IMM16_X1_TLS_IE 75 /* X1 pipe 16-bit TLS IE offset */
34703470+#define R_TILEPRO_IMM16_X0_TLS_IE_LO 76 /* X0 pipe low 16-bit TLS IE offset */
34713471+#define R_TILEPRO_IMM16_X1_TLS_IE_LO 77 /* X1 pipe low 16-bit TLS IE offset */
34723472+#define R_TILEPRO_IMM16_X0_TLS_IE_HI 78 /* X0 pipe high 16-bit TLS IE offset */
34733473+#define R_TILEPRO_IMM16_X1_TLS_IE_HI 79 /* X1 pipe high 16-bit TLS IE offset */
34743474+#define R_TILEPRO_IMM16_X0_TLS_IE_HA 80 /* X0 pipe ha() 16-bit TLS IE offset */
34753475+#define R_TILEPRO_IMM16_X1_TLS_IE_HA 81 /* X1 pipe ha() 16-bit TLS IE offset */
34763476+#define R_TILEPRO_TLS_DTPMOD32 82 /* ID of module containing symbol */
34773477+#define R_TILEPRO_TLS_DTPOFF32 83 /* Offset in TLS block */
34783478+#define R_TILEPRO_TLS_TPOFF32 84 /* Offset in static TLS block */
34793479+#define R_TILEPRO_IMM16_X0_TLS_LE 85 /* X0 pipe 16-bit TLS LE offset */
34803480+#define R_TILEPRO_IMM16_X1_TLS_LE 86 /* X1 pipe 16-bit TLS LE offset */
34813481+#define R_TILEPRO_IMM16_X0_TLS_LE_LO 87 /* X0 pipe low 16-bit TLS LE offset */
34823482+#define R_TILEPRO_IMM16_X1_TLS_LE_LO 88 /* X1 pipe low 16-bit TLS LE offset */
34833483+#define R_TILEPRO_IMM16_X0_TLS_LE_HI 89 /* X0 pipe high 16-bit TLS LE offset */
34843484+#define R_TILEPRO_IMM16_X1_TLS_LE_HI 90 /* X1 pipe high 16-bit TLS LE offset */
34853485+#define R_TILEPRO_IMM16_X0_TLS_LE_HA 91 /* X0 pipe ha() 16-bit TLS LE offset */
34863486+#define R_TILEPRO_IMM16_X1_TLS_LE_HA 92 /* X1 pipe ha() 16-bit TLS LE offset */
34873487+34883488+#define R_TILEPRO_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */
34893489+#define R_TILEPRO_GNU_VTENTRY 129 /* GNU C++ vtable member usage */
34903490+34913491+#define R_TILEPRO_NUM 130
34923492+34933493+34943494+/* TILE-Gx relocations. */
34953495+#define R_TILEGX_NONE 0 /* No reloc */
34963496+#define R_TILEGX_64 1 /* Direct 64 bit */
34973497+#define R_TILEGX_32 2 /* Direct 32 bit */
34983498+#define R_TILEGX_16 3 /* Direct 16 bit */
34993499+#define R_TILEGX_8 4 /* Direct 8 bit */
35003500+#define R_TILEGX_64_PCREL 5 /* PC relative 64 bit */
35013501+#define R_TILEGX_32_PCREL 6 /* PC relative 32 bit */
35023502+#define R_TILEGX_16_PCREL 7 /* PC relative 16 bit */
35033503+#define R_TILEGX_8_PCREL 8 /* PC relative 8 bit */
35043504+#define R_TILEGX_HW0 9 /* hword 0 16-bit */
35053505+#define R_TILEGX_HW1 10 /* hword 1 16-bit */
35063506+#define R_TILEGX_HW2 11 /* hword 2 16-bit */
35073507+#define R_TILEGX_HW3 12 /* hword 3 16-bit */
35083508+#define R_TILEGX_HW0_LAST 13 /* last hword 0 16-bit */
35093509+#define R_TILEGX_HW1_LAST 14 /* last hword 1 16-bit */
35103510+#define R_TILEGX_HW2_LAST 15 /* last hword 2 16-bit */
35113511+#define R_TILEGX_COPY 16 /* Copy relocation */
35123512+#define R_TILEGX_GLOB_DAT 17 /* Create GOT entry */
35133513+#define R_TILEGX_JMP_SLOT 18 /* Create PLT entry */
35143514+#define R_TILEGX_RELATIVE 19 /* Adjust by program base */
35153515+#define R_TILEGX_BROFF_X1 20 /* X1 pipe branch offset */
35163516+#define R_TILEGX_JUMPOFF_X1 21 /* X1 pipe jump offset */
35173517+#define R_TILEGX_JUMPOFF_X1_PLT 22 /* X1 pipe jump offset to PLT */
35183518+#define R_TILEGX_IMM8_X0 23 /* X0 pipe 8-bit */
35193519+#define R_TILEGX_IMM8_Y0 24 /* Y0 pipe 8-bit */
35203520+#define R_TILEGX_IMM8_X1 25 /* X1 pipe 8-bit */
35213521+#define R_TILEGX_IMM8_Y1 26 /* Y1 pipe 8-bit */
35223522+#define R_TILEGX_DEST_IMM8_X1 27 /* X1 pipe destination 8-bit */
35233523+#define R_TILEGX_MT_IMM14_X1 28 /* X1 pipe mtspr */
35243524+#define R_TILEGX_MF_IMM14_X1 29 /* X1 pipe mfspr */
35253525+#define R_TILEGX_MMSTART_X0 30 /* X0 pipe mm "start" */
35263526+#define R_TILEGX_MMEND_X0 31 /* X0 pipe mm "end" */
35273527+#define R_TILEGX_SHAMT_X0 32 /* X0 pipe shift amount */
35283528+#define R_TILEGX_SHAMT_X1 33 /* X1 pipe shift amount */
35293529+#define R_TILEGX_SHAMT_Y0 34 /* Y0 pipe shift amount */
35303530+#define R_TILEGX_SHAMT_Y1 35 /* Y1 pipe shift amount */
35313531+#define R_TILEGX_IMM16_X0_HW0 36 /* X0 pipe hword 0 */
35323532+#define R_TILEGX_IMM16_X1_HW0 37 /* X1 pipe hword 0 */
35333533+#define R_TILEGX_IMM16_X0_HW1 38 /* X0 pipe hword 1 */
35343534+#define R_TILEGX_IMM16_X1_HW1 39 /* X1 pipe hword 1 */
35353535+#define R_TILEGX_IMM16_X0_HW2 40 /* X0 pipe hword 2 */
35363536+#define R_TILEGX_IMM16_X1_HW2 41 /* X1 pipe hword 2 */
35373537+#define R_TILEGX_IMM16_X0_HW3 42 /* X0 pipe hword 3 */
35383538+#define R_TILEGX_IMM16_X1_HW3 43 /* X1 pipe hword 3 */
35393539+#define R_TILEGX_IMM16_X0_HW0_LAST 44 /* X0 pipe last hword 0 */
35403540+#define R_TILEGX_IMM16_X1_HW0_LAST 45 /* X1 pipe last hword 0 */
35413541+#define R_TILEGX_IMM16_X0_HW1_LAST 46 /* X0 pipe last hword 1 */
35423542+#define R_TILEGX_IMM16_X1_HW1_LAST 47 /* X1 pipe last hword 1 */
35433543+#define R_TILEGX_IMM16_X0_HW2_LAST 48 /* X0 pipe last hword 2 */
35443544+#define R_TILEGX_IMM16_X1_HW2_LAST 49 /* X1 pipe last hword 2 */
35453545+#define R_TILEGX_IMM16_X0_HW0_PCREL 50 /* X0 pipe PC relative hword 0 */
35463546+#define R_TILEGX_IMM16_X1_HW0_PCREL 51 /* X1 pipe PC relative hword 0 */
35473547+#define R_TILEGX_IMM16_X0_HW1_PCREL 52 /* X0 pipe PC relative hword 1 */
35483548+#define R_TILEGX_IMM16_X1_HW1_PCREL 53 /* X1 pipe PC relative hword 1 */
35493549+#define R_TILEGX_IMM16_X0_HW2_PCREL 54 /* X0 pipe PC relative hword 2 */
35503550+#define R_TILEGX_IMM16_X1_HW2_PCREL 55 /* X1 pipe PC relative hword 2 */
35513551+#define R_TILEGX_IMM16_X0_HW3_PCREL 56 /* X0 pipe PC relative hword 3 */
35523552+#define R_TILEGX_IMM16_X1_HW3_PCREL 57 /* X1 pipe PC relative hword 3 */
35533553+#define R_TILEGX_IMM16_X0_HW0_LAST_PCREL 58 /* X0 pipe PC-rel last hword 0 */
35543554+#define R_TILEGX_IMM16_X1_HW0_LAST_PCREL 59 /* X1 pipe PC-rel last hword 0 */
35553555+#define R_TILEGX_IMM16_X0_HW1_LAST_PCREL 60 /* X0 pipe PC-rel last hword 1 */
35563556+#define R_TILEGX_IMM16_X1_HW1_LAST_PCREL 61 /* X1 pipe PC-rel last hword 1 */
35573557+#define R_TILEGX_IMM16_X0_HW2_LAST_PCREL 62 /* X0 pipe PC-rel last hword 2 */
35583558+#define R_TILEGX_IMM16_X1_HW2_LAST_PCREL 63 /* X1 pipe PC-rel last hword 2 */
35593559+#define R_TILEGX_IMM16_X0_HW0_GOT 64 /* X0 pipe hword 0 GOT offset */
35603560+#define R_TILEGX_IMM16_X1_HW0_GOT 65 /* X1 pipe hword 0 GOT offset */
35613561+#define R_TILEGX_IMM16_X0_HW0_PLT_PCREL 66 /* X0 pipe PC-rel PLT hword 0 */
35623562+#define R_TILEGX_IMM16_X1_HW0_PLT_PCREL 67 /* X1 pipe PC-rel PLT hword 0 */
35633563+#define R_TILEGX_IMM16_X0_HW1_PLT_PCREL 68 /* X0 pipe PC-rel PLT hword 1 */
35643564+#define R_TILEGX_IMM16_X1_HW1_PLT_PCREL 69 /* X1 pipe PC-rel PLT hword 1 */
35653565+#define R_TILEGX_IMM16_X0_HW2_PLT_PCREL 70 /* X0 pipe PC-rel PLT hword 2 */
35663566+#define R_TILEGX_IMM16_X1_HW2_PLT_PCREL 71 /* X1 pipe PC-rel PLT hword 2 */
35673567+#define R_TILEGX_IMM16_X0_HW0_LAST_GOT 72 /* X0 pipe last hword 0 GOT offset */
35683568+#define R_TILEGX_IMM16_X1_HW0_LAST_GOT 73 /* X1 pipe last hword 0 GOT offset */
35693569+#define R_TILEGX_IMM16_X0_HW1_LAST_GOT 74 /* X0 pipe last hword 1 GOT offset */
35703570+#define R_TILEGX_IMM16_X1_HW1_LAST_GOT 75 /* X1 pipe last hword 1 GOT offset */
35713571+#define R_TILEGX_IMM16_X0_HW3_PLT_PCREL 76 /* X0 pipe PC-rel PLT hword 3 */
35723572+#define R_TILEGX_IMM16_X1_HW3_PLT_PCREL 77 /* X1 pipe PC-rel PLT hword 3 */
35733573+#define R_TILEGX_IMM16_X0_HW0_TLS_GD 78 /* X0 pipe hword 0 TLS GD offset */
35743574+#define R_TILEGX_IMM16_X1_HW0_TLS_GD 79 /* X1 pipe hword 0 TLS GD offset */
35753575+#define R_TILEGX_IMM16_X0_HW0_TLS_LE 80 /* X0 pipe hword 0 TLS LE offset */
35763576+#define R_TILEGX_IMM16_X1_HW0_TLS_LE 81 /* X1 pipe hword 0 TLS LE offset */
35773577+#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE 82 /* X0 pipe last hword 0 LE off */
35783578+#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE 83 /* X1 pipe last hword 0 LE off */
35793579+#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE 84 /* X0 pipe last hword 1 LE off */
35803580+#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE 85 /* X1 pipe last hword 1 LE off */
35813581+#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD 86 /* X0 pipe last hword 0 GD off */
35823582+#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD 87 /* X1 pipe last hword 0 GD off */
35833583+#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD 88 /* X0 pipe last hword 1 GD off */
35843584+#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD 89 /* X1 pipe last hword 1 GD off */
35853585+/* Relocs 90-91 are currently not defined. */
35863586+#define R_TILEGX_IMM16_X0_HW0_TLS_IE 92 /* X0 pipe hword 0 TLS IE offset */
35873587+#define R_TILEGX_IMM16_X1_HW0_TLS_IE 93 /* X1 pipe hword 0 TLS IE offset */
35883588+#define R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL 94 /* X0 pipe PC-rel PLT last hword 0 */
35893589+#define R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL 95 /* X1 pipe PC-rel PLT last hword 0 */
35903590+#define R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL 96 /* X0 pipe PC-rel PLT last hword 1 */
35913591+#define R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL 97 /* X1 pipe PC-rel PLT last hword 1 */
35923592+#define R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL 98 /* X0 pipe PC-rel PLT last hword 2 */
35933593+#define R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL 99 /* X1 pipe PC-rel PLT last hword 2 */
35943594+#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE 100 /* X0 pipe last hword 0 IE off */
35953595+#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE 101 /* X1 pipe last hword 0 IE off */
35963596+#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE 102 /* X0 pipe last hword 1 IE off */
35973597+#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE 103 /* X1 pipe last hword 1 IE off */
35983598+/* Relocs 104-105 are currently not defined. */
35993599+#define R_TILEGX_TLS_DTPMOD64 106 /* 64-bit ID of symbol's module */
36003600+#define R_TILEGX_TLS_DTPOFF64 107 /* 64-bit offset in TLS block */
36013601+#define R_TILEGX_TLS_TPOFF64 108 /* 64-bit offset in static TLS block */
36023602+#define R_TILEGX_TLS_DTPMOD32 109 /* 32-bit ID of symbol's module */
36033603+#define R_TILEGX_TLS_DTPOFF32 110 /* 32-bit offset in TLS block */
36043604+#define R_TILEGX_TLS_TPOFF32 111 /* 32-bit offset in static TLS block */
36053605+#define R_TILEGX_TLS_GD_CALL 112 /* "jal" for TLS GD */
36063606+#define R_TILEGX_IMM8_X0_TLS_GD_ADD 113 /* X0 pipe "addi" for TLS GD */
36073607+#define R_TILEGX_IMM8_X1_TLS_GD_ADD 114 /* X1 pipe "addi" for TLS GD */
36083608+#define R_TILEGX_IMM8_Y0_TLS_GD_ADD 115 /* Y0 pipe "addi" for TLS GD */
36093609+#define R_TILEGX_IMM8_Y1_TLS_GD_ADD 116 /* Y1 pipe "addi" for TLS GD */
36103610+#define R_TILEGX_TLS_IE_LOAD 117 /* "ld_tls" for TLS IE */
36113611+#define R_TILEGX_IMM8_X0_TLS_ADD 118 /* X0 pipe "addi" for TLS GD/IE */
36123612+#define R_TILEGX_IMM8_X1_TLS_ADD 119 /* X1 pipe "addi" for TLS GD/IE */
36133613+#define R_TILEGX_IMM8_Y0_TLS_ADD 120 /* Y0 pipe "addi" for TLS GD/IE */
36143614+#define R_TILEGX_IMM8_Y1_TLS_ADD 121 /* Y1 pipe "addi" for TLS GD/IE */
36153615+36163616+#define R_TILEGX_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */
36173617+#define R_TILEGX_GNU_VTENTRY 129 /* GNU C++ vtable member usage */
36183618+36193619+#define R_TILEGX_NUM 130
36203620+36213621+/* BPF specific declarations. */
36223622+36233623+#define R_BPF_NONE 0 /* No reloc */
36243624+#define R_BPF_MAP_FD 1 /* Map fd to pointer */
36253625+36263626+/* Imagination Meta specific relocations. */
36273627+36283628+#define R_METAG_HIADDR16 0
36293629+#define R_METAG_LOADDR16 1
36303630+#define R_METAG_ADDR32 2 /* 32bit absolute address */
36313631+#define R_METAG_NONE 3 /* No reloc */
36323632+#define R_METAG_RELBRANCH 4
36333633+#define R_METAG_GETSETOFF 5
36343634+36353635+/* Backward compatability */
36363636+#define R_METAG_REG32OP1 6
36373637+#define R_METAG_REG32OP2 7
36383638+#define R_METAG_REG32OP3 8
36393639+#define R_METAG_REG16OP1 9
36403640+#define R_METAG_REG16OP2 10
36413641+#define R_METAG_REG16OP3 11
36423642+#define R_METAG_REG32OP4 12
36433643+36443644+#define R_METAG_HIOG 13
36453645+#define R_METAG_LOOG 14
36463646+36473647+#define R_METAG_REL8 15
36483648+#define R_METAG_REL16 16
36493649+36503650+/* GNU */
36513651+#define R_METAG_GNU_VTINHERIT 30
36523652+#define R_METAG_GNU_VTENTRY 31
36533653+36543654+/* PIC relocations */
36553655+#define R_METAG_HI16_GOTOFF 32
36563656+#define R_METAG_LO16_GOTOFF 33
36573657+#define R_METAG_GETSET_GOTOFF 34
36583658+#define R_METAG_GETSET_GOT 35
36593659+#define R_METAG_HI16_GOTPC 36
36603660+#define R_METAG_LO16_GOTPC 37
36613661+#define R_METAG_HI16_PLT 38
36623662+#define R_METAG_LO16_PLT 39
36633663+#define R_METAG_RELBRANCH_PLT 40
36643664+#define R_METAG_GOTOFF 41
36653665+#define R_METAG_PLT 42
36663666+#define R_METAG_COPY 43
36673667+#define R_METAG_JMP_SLOT 44
36683668+#define R_METAG_RELATIVE 45
36693669+#define R_METAG_GLOB_DAT 46
36703670+36713671+/* TLS relocations */
36723672+#define R_METAG_TLS_GD 47
36733673+#define R_METAG_TLS_LDM 48
36743674+#define R_METAG_TLS_LDO_HI16 49
36753675+#define R_METAG_TLS_LDO_LO16 50
36763676+#define R_METAG_TLS_LDO 51
36773677+#define R_METAG_TLS_IE 52
36783678+#define R_METAG_TLS_IENONPIC 53
36793679+#define R_METAG_TLS_IENONPIC_HI16 54
36803680+#define R_METAG_TLS_IENONPIC_LO16 55
36813681+#define R_METAG_TLS_TPOFF 56
36823682+#define R_METAG_TLS_DTPMOD 57
36833683+#define R_METAG_TLS_DTPOFF 58
36843684+#define R_METAG_TLS_LE 59
36853685+#define R_METAG_TLS_LE_HI16 60
36863686+#define R_METAG_TLS_LE_LO16 61
36873687+36883688+__END_DECLS
36893689+36903690+#endif /* elf.h */
+397
src/libelfloader/loader.c
···11+/*
22+ * Darling
33+ * Copyright (C) 2017 Lubos Dolezel
44+ *
55+ * This program is free software; you can redistribute it and/or
66+ * modify it under the terms of the GNU General Public License
77+ * as published by the Free Software Foundation; either version 2
88+ * of the License, or (at your option) any later version.
99+ *
1010+ * This program is distributed in the hope that it will be useful,
1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313+ * GNU General Public License for more details.
1414+ *
1515+ * You should have received a copy of the GNU General Public License
1616+ * along with this program; if not, write to the Free Software
1717+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818+ */
1919+2020+#include <unistd.h>
2121+#include <sys/mman.h>
2222+#include <sys/types.h>
2323+#include <fcntl.h>
2424+#include <string.h>
2525+#include <stdio.h>
2626+#include <stdlib.h>
2727+#include <stdbool.h>
2828+#include <setjmp.h>
2929+#include <sys/random.h>
3030+#include "elf.h"
3131+#include "auxvec.h"
3232+#include "loader.h"
3333+#include "native/elfcalls.h"
3434+3535+#ifdef __APPLE__
3636+extern int getentropy(void* buf, size_t len);
3737+#endif
3838+3939+#define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type)
4040+#define _ElfW(e,w,t) _ElfW_1 (e, w, _##t)
4141+#define _ElfW_1(e,w,t) e##w##t
4242+4343+#if defined(__x86_64__) || defined(__arm64__)
4444+# define DUMMY_PATH "/usr/libexec/elfloader_dummy64"
4545+# define MY_ELF_CLASS ELFCLASS64
4646+# define __ELF_NATIVE_CLASS 64
4747+#else
4848+# define DUMMY_PATH "/usr/libexec/elfloader_dummy32"
4949+# define MY_ELF_CLASS ELFCLASS32
5050+# define __ELF_NATIVE_CLASS 32
5151+#endif
5252+5353+#define ELF_MIN_ALIGN 0x1000
5454+#define ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(ELF_MIN_ALIGN-1))
5555+#define ELF_PAGEOFFSET(_v) ((_v) & (ELF_MIN_ALIGN-1))
5656+#define ELF_PAGEALIGN(_v) (((_v) + ELF_MIN_ALIGN - 1) & ~(ELF_MIN_ALIGN - 1))
5757+5858+extern char** environ;
5959+6060+struct loader_context
6161+{
6262+ uintptr_t interp_entry;
6363+ uintptr_t exec_entry;
6464+ uintptr_t exec_phstart;
6565+ uintptr_t exec_phentsize;
6666+ uintptr_t exec_phnum;
6767+ uintptr_t interp_base;
6868+};
6969+7070+static void run(const char* path);
7171+static void load(const char* path, struct loader_context* lc, bool isInterp);
7272+static void loader_return(void);
7373+static const char SYSTEM_ROOT[] = "/Volumes/SystemRoot";
7474+7575+static jmp_buf jmpbuf;
7676+static struct elf_calls elfcalls;
7777+7878+#ifndef TEST
7979+__attribute__((constructor))
8080+ static void runDummy(void)
8181+{
8282+ run(DUMMY_PATH);
8383+}
8484+#endif
8585+8686+void run(const char* path)
8787+{
8888+ struct loader_context lc;
8989+ unsigned long *stack, *stackmem;
9090+ int ptrcount, pos = 0;
9191+ uint8_t entropy[16];
9292+ char pointer1[20];
9393+ char pointer2[20];
9494+9595+ load(path, &lc, false);
9696+ if (!lc.interp_entry)
9797+ return;
9898+9999+ stackmem = (unsigned long*) mmap(NULL, 4096*4, PROT_READ | PROT_WRITE,
100100+ MAP_PRIVATE | MAP_ANON, -1, 0);
101101+102102+ if (stackmem == MAP_FAILED)
103103+ perror("mmap");
104104+105105+ stack = (unsigned long*) (((char*) stackmem) + 4096*4 - sizeof(unsigned long));
106106+107107+ // AT_*
108108+ ptrcount = 10*2;
109109+ ptrcount++; // argc
110110+ ptrcount += 4; // argv
111111+112112+ // environ
113113+ for (int i = 0; environ[i] != NULL; i++)
114114+ ptrcount++;
115115+ ptrcount++;
116116+117117+ stack -= ptrcount;
118118+119119+ stack[pos++] = 3; // argc
120120+ stack[pos++] = (unsigned long) "elfloader_dummy";
121121+122122+ snprintf(pointer1, sizeof(pointer1), "%lx", (unsigned long) &elfcalls);
123123+ stack[pos++] = (unsigned long) pointer1;
124124+125125+ snprintf(pointer2, sizeof(pointer2), "%lx", (unsigned long) loader_return);
126126+ stack[pos++] = (unsigned long) pointer2;
127127+ stack[pos++] = 0;
128128+129129+130130+ for (int i = 0; environ[i] != NULL; i++)
131131+ stack[pos++] = (unsigned long) environ[i];
132132+133133+#ifdef __linux__ // For testing
134134+ getrandom(entropy, sizeof(entropy), 0);
135135+#else // Darwin
136136+ getentropy(entropy, sizeof(entropy));
137137+#endif
138138+139139+ stack[pos++] = 0;
140140+141141+ stack[pos++] = AT_PHDR;
142142+ stack[pos++] = lc.exec_phstart;
143143+144144+ stack[pos++] = AT_PHENT;
145145+ stack[pos++] = lc.exec_phentsize;
146146+147147+ stack[pos++] = AT_PHNUM;
148148+ stack[pos++] = lc.exec_phnum;
149149+150150+ stack[pos++] = AT_ENTRY;
151151+ stack[pos++] = lc.exec_entry;
152152+153153+ stack[pos++] = AT_BASE;
154154+ stack[pos++] = lc.interp_base;
155155+156156+ stack[pos++] = AT_PAGESZ;
157157+ stack[pos++] = 4096;
158158+159159+ stack[pos++] = AT_FLAGS;
160160+ stack[pos++] = 0;
161161+162162+ stack[pos++] = AT_RANDOM;
163163+ stack[pos++] = (unsigned long) entropy;
164164+165165+ stack[pos++] = AT_NULL;
166166+ stack[pos++] = 0;
167167+168168+ // TODO: AT_EXECFN?
169169+#ifdef __x86_64__
170170+# define JUMPX(stack, addr) __asm__ volatile("mov %1, %%rsp; jmpq *%0" :: "m"(addr), "r"(stack) :)
171171+#elif defined(__i386__)
172172+# define JUMPX(stack, addr) __asm__ volatile("mov %1, %%esp; jmp *%0" :: "m"(addr), "r"(stack) :)
173173+#else
174174+# error Unsupported platform!
175175+#endif
176176+177177+ if (!setjmp(jmpbuf))
178178+ JUMPX(stack, lc.interp_entry);
179179+ else
180180+ {
181181+ puts("Back from loaded binary");
182182+ }
183183+}
184184+185185+// AT_PHDR -> loadaddr + phoff
186186+// AT_PHENT -> e_phentsize
187187+// AT_PHNUM -> e_phnum
188188+// AT_ENTRY -> exec->e_entry
189189+// AT_BASE -> interp_loadaddr
190190+// AT_EXECFN -> apple[0]
191191+// AT_PAGESZ -> PAGE_SIZE
192192+// AT_FLAGS -> 0
193193+// AT_NULL
194194+195195+void load(const char* path, struct loader_context* lc, bool isInterp)
196196+{
197197+ ElfW(Ehdr) elfHdr;
198198+ void* phdrs = NULL;
199199+200200+ int fd = open(path, O_RDONLY);
201201+ uintptr_t slide, base;
202202+203203+ if (fd == -1)
204204+ {
205205+ perror("open");
206206+ return;
207207+ }
208208+209209+ if (read(fd, &elfHdr, sizeof(elfHdr)) != sizeof(elfHdr))
210210+ {
211211+ perror("read");
212212+ goto out;
213213+ }
214214+215215+ if (memcmp(elfHdr.e_ident, ELFMAG, SELFMAG) != 0 || elfHdr.e_ident[EI_CLASS] != MY_ELF_CLASS)
216216+ {
217217+ fprintf(stderr, "Wrong ELF signature\n");
218218+ goto out;
219219+ }
220220+221221+ if (elfHdr.e_type != ET_DYN)
222222+ {
223223+ fprintf(stderr, "Only position independent ELF are supported\n");
224224+ goto out;
225225+ }
226226+ if (!elfHdr.e_phoff)
227227+ {
228228+ fprintf(stderr, "ELF is not loadable\n");
229229+ goto out;
230230+ }
231231+232232+ phdrs = malloc(elfHdr.e_phentsize * elfHdr.e_phnum);
233233+ if (pread(fd, phdrs, elfHdr.e_phentsize * elfHdr.e_phnum, elfHdr.e_phoff) != elfHdr.e_phentsize * elfHdr.e_phnum)
234234+ {
235235+ fprintf(stderr, "Failed to read Elf phdrs\n");
236236+ goto out;
237237+ }
238238+239239+ // First, get total virtual range needed
240240+ uintptr_t minAddr = UINTPTR_MAX, maxAddr = 0;
241241+242242+ for (int i = 0; i < elfHdr.e_phnum; i++)
243243+ {
244244+ ElfW(Phdr)* phdr = (ElfW(Phdr)*) (((char*) phdrs) + (i * elfHdr.e_phentsize));
245245+246246+ if (phdr->p_type == PT_LOAD)
247247+ {
248248+ if (phdr->p_vaddr < minAddr)
249249+ minAddr = ELF_PAGESTART(phdr->p_vaddr);
250250+ if (phdr->p_vaddr + phdr->p_memsz > maxAddr)
251251+ maxAddr = phdr->p_vaddr + phdr->p_memsz;
252252+ }
253253+ else if (phdr->p_type == PT_INTERP && isInterp)
254254+ {
255255+ fprintf(stderr, "Interp with PT_INTERP?\n");
256256+ goto out;
257257+ }
258258+ }
259259+ if (maxAddr == 0)
260260+ {
261261+ fprintf(stderr, "No PT_LOAD headers?\n");
262262+ goto out;
263263+ }
264264+265265+ base = (uintptr_t) mmap(NULL, maxAddr-minAddr, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0);
266266+ if (base == (uintptr_t) MAP_FAILED)
267267+ {
268268+ perror("mmap");
269269+ fprintf(stderr, "Cannot reserve 0x%lx bytes in memory\n", maxAddr-minAddr);
270270+ goto out;
271271+ }
272272+ slide = base - minAddr;
273273+274274+ for (int i = 0; i < elfHdr.e_phnum; i++)
275275+ {
276276+ ElfW(Phdr)* phdr = (ElfW(Phdr)*) (((char*) phdrs) + (i * elfHdr.e_phentsize));
277277+278278+ if (phdr->p_type == PT_LOAD)
279279+ {
280280+ int prot = 0;
281281+ int flags = MAP_FIXED;
282282+ void* result;
283283+284284+ uintptr_t addr = phdr->p_vaddr + slide;
285285+ uintptr_t size = phdr->p_filesz + ELF_PAGEOFFSET(phdr->p_vaddr);
286286+ uintptr_t memsize = phdr->p_memsz + ELF_PAGEOFFSET(phdr->p_vaddr);
287287+ uintptr_t off = phdr->p_offset - ELF_PAGEOFFSET(phdr->p_vaddr);
288288+289289+ addr = ELF_PAGESTART(addr);
290290+ size = ELF_PAGEALIGN(size);
291291+292292+ if (phdr->p_flags & PF_X)
293293+ prot |= PROT_EXEC;
294294+ if (phdr->p_flags & PF_W)
295295+ prot |= PROT_WRITE;
296296+ if (phdr->p_flags & PF_R)
297297+ prot |= PROT_READ;
298298+299299+ if (phdr->p_flags & PF_W)
300300+ flags |= MAP_PRIVATE;
301301+ else
302302+ flags |= MAP_SHARED;
303303+304304+ if (mprotect((void*) (addr), memsize, prot) == -1)
305305+ {
306306+ perror("mprotect");
307307+ }
308308+309309+ result = mmap((void*) addr, size, prot, flags, fd, off);
310310+ if (result == MAP_FAILED)
311311+ {
312312+ perror("mmap");
313313+ goto out;
314314+ }
315315+316316+ /*
317317+ if (phdr->p_filesz < phdr->p_memsz)
318318+ {
319319+ if (mprotect((void*) (addr + phdr->p_filesz), phdr->p_memsz - phdr->p_filesz, prot) == -1)
320320+ {
321321+ perror("mprotect");
322322+ goto out;
323323+ }
324324+ }
325325+ */
326326+ }
327327+ else if (phdr->p_type == PT_INTERP)
328328+ {
329329+ char* interp = malloc(phdr->p_filesz + 1);
330330+331331+ if (pread(fd, interp, phdr->p_filesz, phdr->p_offset) != phdr->p_filesz)
332332+ {
333333+ free(interp);
334334+ perror("reading PT_INTERP");
335335+ goto out;
336336+ }
337337+ interp[phdr->p_filesz] = '\0';
338338+339339+ // Load interpreter
340340+ if (access(interp, F_OK) != 0)
341341+ {
342342+ char* prefixed = (char*) malloc(phdr->p_filesz + sizeof(SYSTEM_ROOT));
343343+344344+ strcpy(prefixed, SYSTEM_ROOT);
345345+ strcat(prefixed, interp);
346346+347347+ free(interp);
348348+ interp = prefixed;
349349+ }
350350+351351+ if (access(interp, F_OK) != 0)
352352+ {
353353+ fprintf(stderr, "Cannot load interpreter at %s\n", interp);
354354+ free(interp);
355355+ goto out;
356356+ }
357357+358358+ load(interp, lc, true);
359359+360360+ free(interp);
361361+ }
362362+ }
363363+364364+ if (isInterp)
365365+ {
366366+ lc->interp_base = base;
367367+ lc->interp_entry = slide + elfHdr.e_entry;
368368+ }
369369+ else
370370+ {
371371+ lc->exec_phstart = slide + elfHdr.e_phoff;
372372+ lc->exec_phentsize = elfHdr.e_phentsize;
373373+ lc->exec_phnum = elfHdr.e_phnum;
374374+ lc->exec_entry = slide + elfHdr.e_entry;
375375+ }
376376+377377+out:
378378+ free(phdrs);
379379+ close(fd);
380380+}
381381+382382+void loader_return(void)
383383+{
384384+ longjmp(jmpbuf, 1);
385385+}
386386+387387+#ifdef TEST
388388+389389+int main(int argc, const char** argv)
390390+{
391391+ if (argc > 1)
392392+ run(argv[1]);
393393+ return 0;
394394+}
395395+396396+#endif
397397+
+25
src/libelfloader/loader.h
···11+/*
22+ * Darling
33+ * Copyright (C) 2017 Lubos Dolezel
44+ *
55+ * This program is free software; you can redistribute it and/or
66+ * modify it under the terms of the GNU General Public License
77+ * as published by the Free Software Foundation; either version 2
88+ * of the License, or (at your option) any later version.
99+ *
1010+ * This program is distributed in the hope that it will be useful,
1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313+ * GNU General Public License for more details.
1414+ *
1515+ * You should have received a copy of the GNU General Public License
1616+ * along with this program; if not, write to the Free Software
1717+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818+ */
1919+2020+#ifndef _LOADER_H
2121+#define _LOADER_H
2222+2323+#endif
2424+2525+
···11+#ifndef _ELFCALLS_H_
22+#define _ELFCALLS_H_
33+#include <stdint.h>
44+55+struct elf_calls
66+{
77+ // ELF dynamic loader access
88+ void* (*dlopen)(const char* name);
99+ int (*dlclose)(void* lib);
1010+ void* (*dlsym)(void* lib, const char* name);
1111+ char* (*dlerror)(void);
1212+1313+ // pthread wrapping
1414+ void* (*darling_thread_create)(unsigned long stack_size, unsigned long pthobj_size,
1515+ void* entry_point, uintptr_t arg3,
1616+ uintptr_t arg4, uintptr_t arg5, uintptr_t arg6,
1717+ int (*thread_self_trap)());
1818+ int (*darling_thread_terminate)(void* stackaddr,
1919+ unsigned long freesize, unsigned long pthobj_size);
2020+ void* (*darling_thread_get_stack)(void);
2121+2222+ // The same as above, except they abort() in case of failure
2323+ void* (*dlopen_fatal)(const char* name);
2424+ int (*dlclose_fatal)(void* lib);
2525+ void* (*dlsym_fatal)(void* lib, const char* name);
2626+2727+ // POSIX semaphore APIs
2828+ int (*get_errno)(void);
2929+ int* (*sem_open)(const char* name, int oflag, unsigned short mode, unsigned int value);
3030+ int (*sem_wait)(int* sem);
3131+ int (*sem_trywait)(int* sem);
3232+ int (*sem_post)(int* sem);
3333+ int (*sem_close)(int* sem);
3434+ int (*sem_unlink)(const char* name);
3535+3636+ // POSIX SHM APIs
3737+ int (*shm_open)(const char* name, int oflag, unsigned short mode);
3838+ int (*shm_unlink)(const char* name);
3939+};
4040+4141+#endif
4242+
+281
src/libelfloader/native/threads.c
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2015 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#include "threads.h"
2121+#include <pthread.h>
2222+#include <sys/mman.h>
2323+#include <semaphore.h>
2424+#include <string.h>
2525+#include <stdbool.h>
2626+#include <stdlib.h>
2727+#include <signal.h>
2828+#include <unistd.h>
2929+#include <sys/syscall.h>
3030+3131+// The point of this file is build macOS threads on top of native libc's threads,
3232+// otherwise it would not be possible to make native calls from these threads.
3333+3434+typedef void (*thread_ep)(void**, int, ...);
3535+struct arg_struct
3636+{
3737+ thread_ep entry_point;
3838+ uintptr_t arg3;
3939+ uintptr_t arg4;
4040+ uintptr_t arg5;
4141+ uintptr_t arg6;
4242+ union
4343+ {
4444+ int (*thread_self_trap)();
4545+ int port;
4646+ };
4747+ unsigned long pth_obj_size;
4848+ void* pth;
4949+};
5050+struct reaper_item
5151+{
5252+ struct reaper_item* next;
5353+ pthread_t thread;
5454+ void* stack;
5555+ size_t stacksize;
5656+};
5757+5858+static void* darling_thread_entry(void* p);
5959+static void start_reaper();
6060+6161+static sem_t reaper_sem;
6262+static pthread_mutex_t reaper_mutex = PTHREAD_MUTEX_INITIALIZER;
6363+static struct reaper_item *reaper_items_front = NULL, *reaper_items_end = NULL;
6464+static void reaper_item_push(struct reaper_item* item);
6565+static struct reaper_item* reaper_item_pop(void);
6666+6767+#ifndef PTHREAD_STACK_MIN
6868+# define PTHREAD_STACK_MIN 16384
6969+#endif
7070+7171+void* __darling_thread_create(unsigned long stack_size, unsigned long pth_obj_size,
7272+ void* entry_point, uintptr_t arg3,
7373+ uintptr_t arg4, uintptr_t arg5, uintptr_t arg6,
7474+ int (*thread_self_trap)())
7575+{
7676+ static pthread_once_t reaper_once = PTHREAD_ONCE_INIT;
7777+7878+ struct arg_struct args = { (thread_ep) entry_point, arg3,
7979+ arg4, arg5, arg6, thread_self_trap, pth_obj_size, NULL };
8080+ pthread_attr_t attr;
8181+ pthread_t nativeLibcThread;
8282+ void* pth;
8383+8484+ pthread_once(&reaper_once, start_reaper);
8585+8686+ pthread_attr_init(&attr);
8787+ //pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
8888+ // pthread_attr_setstacksize(&attr, stack_size);
8989+9090+ pth = mmap(NULL, stack_size + pth_obj_size + 0x1000, PROT_READ | PROT_WRITE,
9191+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
9292+9393+ // pthread_attr_setstack is buggy. The documentation states we should provide the lowest
9494+ // address of the stack, yet some versions regard it as the highest address instead.
9595+ // Therefore it's better to just make the pthread stack as small as possible and then switch
9696+ // to our own stack instead.
9797+ //pthread_attr_setstack(&attr, ((char*)pth) + pth_obj_size, stack_size - pth_obj_size - 0x1000);
9898+9999+ // std::cout << "Allocated stack at " << pth << ", size " << stack_size << std::endl;
100100+ pth = ((char*) pth) + stack_size + 0x1000;
101101+ pthread_attr_setstacksize(&attr, 4096);
102102+103103+ args.pth = pth;
104104+ pthread_create(&nativeLibcThread, &attr, darling_thread_entry, &args);
105105+ pthread_attr_destroy(&attr);
106106+107107+ while (args.pth != NULL)
108108+ sched_yield();
109109+110110+ return pth;
111111+}
112112+113113+static void* darling_thread_entry(void* p)
114114+{
115115+ struct arg_struct* in_args = (struct arg_struct*) p;
116116+ struct arg_struct args;
117117+118118+ memcpy(&args, in_args, sizeof(args));
119119+120120+ args.port = args.thread_self_trap();
121121+ in_args->pth = NULL;
122122+123123+#ifdef __x86_64__
124124+ __asm__ __volatile__ (
125125+ "movq %1, %%rdi\n"
126126+ "movq %%rdi, %%rsp\n"
127127+ "movq 40(%0), %%rsi\n"
128128+ "movq 8(%0), %%rdx\n"
129129+ "testq %%rdx, %%rdx\n"
130130+ "jnz 1f\n"
131131+ "movq %%rsp, %%rdx\n" // wqthread hack: if 3rd arg is null, we pass sp
132132+ "1:\n"
133133+ "movq 16(%0), %%rcx\n"
134134+ "movq 24(%0), %%r8\n"
135135+ "movq 32(%0), %%r9\n"
136136+ "movq %%rdi, 56(%0)\n"
137137+ "movq (%0), %%rax\n"
138138+ "andq $-0x10, %%rsp\n"
139139+ "pushq $0\n"
140140+ "pushq $0\n"
141141+ "jmpq *%%rax\n"
142142+ :: "a" (&args), "di" (args.pth));
143143+#elif defined(__i386__) // args in eax, ebx, ecx, edx, edi, esi
144144+ __asm__ __volatile__ (
145145+ "movl (%0), %%eax\n"
146146+ "movl (%1), %%esp\n"
147147+ "pushl %%eax\n" // address to be jumped to
148148+ "movl %1, 28(%0)\n"
149149+ "movl %1, %%eax\n" // 1st arg
150150+ "movl 20(%0), %%ebx\n" // 2nd arg
151151+ "movl 8(%0), %%edx\n" // 4th arg
152152+ "movl 12(%0), %%edi\n" // 5th arg
153153+ "movl 16(%0), %%esi\n" // 6th arg
154154+ "movl 4(%0), %%ecx\n" // 3rd arg
155155+ "testl %%ecx, %%ecx\n" // FIXME: clobbered ecx!
156156+ "jnz 1f\n"
157157+ "movl %%esp, %%ecx\n"
158158+ "1:\n"
159159+ "ret\n" // Jump to the address pushed at the beginning
160160+ :: "c" (&args), "d" (args.pth));
161161+#endif
162162+ return NULL;
163163+}
164164+165165+int __darling_thread_terminate(void* stackaddr,
166166+ unsigned long freesize, unsigned long pthobj_size)
167167+{
168168+ if (getpid() == syscall(SYS_gettid))
169169+ {
170170+ // dispatch_main() calls pthread_exit(NULL) on the main thread,
171171+ // which turns the our process into a zombie.
172172+ // Let's just hang around forever.
173173+ sigset_t mask;
174174+ memset(&mask, 0, sizeof(mask));
175175+176176+ while (1)
177177+ sigsuspend(&mask);
178178+ }
179179+180180+ struct reaper_item* item = (struct reaper_item*) malloc(sizeof(struct reaper_item));
181181+ item->thread = pthread_self();
182182+ item->stack = stackaddr;
183183+ item->stacksize = freesize;
184184+ reaper_item_push(item);
185185+186186+ sem_post(&reaper_sem);
187187+188188+ pthread_exit(NULL);
189189+190190+ __builtin_unreachable();
191191+}
192192+193193+void* __darling_thread_get_stack(void)
194194+{
195195+ pthread_attr_t attr;
196196+ void* stackaddr;
197197+ size_t stacksize;
198198+199199+ pthread_getattr_np(pthread_self(), &attr);
200200+ pthread_attr_getstack(&attr, &stackaddr, &stacksize);
201201+202202+ return ((char*)stackaddr) + stacksize - 0x2000;
203203+}
204204+205205+static void* reaper_entry(void* unused)
206206+{
207207+ while (true)
208208+ {
209209+ struct reaper_item* item;
210210+211211+ sem_wait(&reaper_sem);
212212+213213+ item = reaper_item_pop();
214214+ if (!item)
215215+ continue; // Should not happen!
216216+217217+ // std::cout << "Reaping thread " << (void*)item.thread << "; Free stack at " << item.stack << ", " << item.stacksize << " bytes\n";
218218+219219+ // Wait for thread to terminate
220220+ pthread_join(item->thread, NULL);
221221+222222+ // Free its stack in the extended range requested by Darwin's libc
223223+ munmap(item->stack, item->stacksize);
224224+225225+ free(item);
226226+ }
227227+}
228228+229229+static void start_reaper()
230230+{
231231+ pthread_attr_t attr;
232232+ pthread_t thread;
233233+234234+ pthread_attr_init(&attr);
235235+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
236236+237237+ sem_init(&reaper_sem, 0, 0);
238238+ pthread_create(&thread, &attr, reaper_entry, NULL);
239239+ pthread_attr_destroy(&attr);
240240+}
241241+242242+static void reaper_item_push(struct reaper_item* item)
243243+{
244244+ pthread_mutex_lock(&reaper_mutex);
245245+246246+ item->next = NULL;
247247+ if (reaper_items_end != NULL)
248248+ {
249249+ reaper_items_end->next = item;
250250+ reaper_items_end = item;
251251+ }
252252+ else
253253+ {
254254+ reaper_items_front = reaper_items_end = item;
255255+ }
256256+257257+ pthread_mutex_unlock(&reaper_mutex);
258258+}
259259+260260+static struct reaper_item* reaper_item_pop(void)
261261+{
262262+ struct reaper_item* e;
263263+ pthread_mutex_lock(&reaper_mutex);
264264+265265+ if (reaper_items_front != NULL)
266266+ {
267267+ e = reaper_items_front;
268268+269269+ if (reaper_items_front == reaper_items_end)
270270+ reaper_items_front = reaper_items_end = NULL; // The list is now empty
271271+ else
272272+ reaper_items_front = e->next;
273273+ }
274274+ else
275275+ e = NULL;
276276+277277+ pthread_mutex_unlock(&reaper_mutex);
278278+279279+ return e;
280280+}
281281+
+41
src/libelfloader/native/threads.h
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2015 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef DYLD_THREADS_H
2121+#define DYLD_THREADS_H
2222+#include <stdint.h>
2323+2424+#ifdef __cplusplus
2525+extern "C" {
2626+#endif
2727+2828+void* __darling_thread_create(unsigned long stack_size, unsigned long pthobj_size,
2929+ void* entry_point, uintptr_t arg3,
3030+ uintptr_t arg4, uintptr_t arg5, uintptr_t arg6,
3131+ int (*thread_self_trap)());
3232+int __darling_thread_terminate(void* stackaddr,
3333+ unsigned long freesize, unsigned long pthobj_size);
3434+void* __darling_thread_get_stack(void);
3535+3636+#ifdef __cplusplus
3737+}
3838+#endif
3939+4040+#endif
4141+