elftc_reloc_type_str.c revision 300334
1/*-
2 * Copyright (c) 2009-2015 Kai Wang
3 * Copyright (c) 2016 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Ed Maste under sponsorship
7 * of the FreeBSD Foundation.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <libelftc.h>
32#include <stdio.h>
33
34/* Backwards compatability for older FreeBSD releases. */
35#ifndef EM_IAMCU
36#define EM_IAMCU 6
37#endif
38#ifndef EM_RISCV
39#define EM_RISCV 243
40#endif
41
42const char *
43elftc_reloc_type_str(unsigned int mach, unsigned int type)
44{
45	static char s_type[32];
46
47	switch(mach) {
48	case EM_386:
49	case EM_IAMCU:
50		switch(type) {
51		case 0: return "R_386_NONE";
52		case 1: return "R_386_32";
53		case 2: return "R_386_PC32";
54		case 3: return "R_386_GOT32";
55		case 4: return "R_386_PLT32";
56		case 5: return "R_386_COPY";
57		case 6: return "R_386_GLOB_DAT";
58		case 7: return "R_386_JUMP_SLOT";
59		case 8: return "R_386_RELATIVE";
60		case 9: return "R_386_GOTOFF";
61		case 10: return "R_386_GOTPC";
62		case 11: return "R_386_32PLT"; /* Not in psabi */
63		case 14: return "R_386_TLS_TPOFF";
64		case 15: return "R_386_TLS_IE";
65		case 16: return "R_386_TLS_GOTIE";
66		case 17: return "R_386_TLS_LE";
67		case 18: return "R_386_TLS_GD";
68		case 19: return "R_386_TLS_LDM";
69		case 20: return "R_386_16";
70		case 21: return "R_386_PC16";
71		case 22: return "R_386_8";
72		case 23: return "R_386_PC8";
73		case 24: return "R_386_TLS_GD_32";
74		case 25: return "R_386_TLS_GD_PUSH";
75		case 26: return "R_386_TLS_GD_CALL";
76		case 27: return "R_386_TLS_GD_POP";
77		case 28: return "R_386_TLS_LDM_32";
78		case 29: return "R_386_TLS_LDM_PUSH";
79		case 30: return "R_386_TLS_LDM_CALL";
80		case 31: return "R_386_TLS_LDM_POP";
81		case 32: return "R_386_TLS_LDO_32";
82		case 33: return "R_386_TLS_IE_32";
83		case 34: return "R_386_TLS_LE_32";
84		case 35: return "R_386_TLS_DTPMOD32";
85		case 36: return "R_386_TLS_DTPOFF32";
86		case 37: return "R_386_TLS_TPOFF32";
87		case 38: return "R_386_SIZE32";
88		case 39: return "R_386_TLS_GOTDESC";
89		case 40: return "R_386_TLS_DESC_CALL";
90		case 41: return "R_386_TLS_DESC";
91		case 42: return "R_386_IRELATIVE";
92		case 43: return "R_386_GOT32X";
93		}
94		break;
95	case EM_AARCH64:
96		switch(type) {
97		case 0: return "R_AARCH64_NONE";
98		case 257: return "R_AARCH64_ABS64";
99		case 258: return "R_AARCH64_ABS32";
100		case 259: return "R_AARCH64_ABS16";
101		case 260: return "R_AARCH64_PREL64";
102		case 261: return "R_AARCH64_PREL32";
103		case 262: return "R_AARCH64_PREL16";
104		case 263: return "R_AARCH64_MOVW_UABS_G0";
105		case 264: return "R_AARCH64_MOVW_UABS_G0_NC";
106		case 265: return "R_AARCH64_MOVW_UABS_G1";
107		case 266: return "R_AARCH64_MOVW_UABS_G1_NC";
108		case 267: return "R_AARCH64_MOVW_UABS_G2";
109		case 268: return "R_AARCH64_MOVW_UABS_G2_NC";
110		case 269: return "R_AARCH64_MOVW_UABS_G3";
111		case 270: return "R_AARCH64_MOVW_SABS_G0";
112		case 271: return "R_AARCH64_MOVW_SABS_G1";
113		case 272: return "R_AARCH64_MOVW_SABS_G2";
114		case 273: return "R_AARCH64_LD_PREL_LO19";
115		case 274: return "R_AARCH64_ADR_PREL_LO21";
116		case 275: return "R_AARCH64_ADR_PREL_PG_HI21";
117		case 276: return "R_AARCH64_ADR_PREL_PG_HI21_NC";
118		case 277: return "R_AARCH64_ADD_ABS_LO12_NC";
119		case 278: return "R_AARCH64_LDST8_ABS_LO12_NC";
120		case 279: return "R_AARCH64_TSTBR14";
121		case 280: return "R_AARCH64_CONDBR19";
122		case 282: return "R_AARCH64_JUMP26";
123		case 283: return "R_AARCH64_CALL26";
124		case 284: return "R_AARCH64_LDST16_ABS_LO12_NC";
125		case 285: return "R_AARCH64_LDST32_ABS_LO12_NC";
126		case 286: return "R_AARCH64_LDST64_ABS_LO12_NC";
127		case 287: return "R_AARCH64_MOVW_PREL_G0";
128		case 288: return "R_AARCH64_MOVW_PREL_G0_NC";
129		case 289: return "R_AARCH64_MOVW_PREL_G1";
130		case 290: return "R_AARCH64_MOVW_PREL_G1_NC";
131		case 291: return "R_AARCH64_MOVW_PREL_G2";
132		case 292: return "R_AARCH64_MOVW_PREL_G2_NC";
133		case 293: return "R_AARCH64_MOVW_PREL_G3";
134		case 299: return "R_AARCH64_LDST128_ABS_LO12_NC";
135		case 300: return "R_AARCH64_MOVW_GOTOFF_G0";
136		case 301: return "R_AARCH64_MOVW_GOTOFF_G0_NC";
137		case 302: return "R_AARCH64_MOVW_GOTOFF_G1";
138		case 303: return "R_AARCH64_MOVW_GOTOFF_G1_NC";
139		case 304: return "R_AARCH64_MOVW_GOTOFF_G2";
140		case 305: return "R_AARCH64_MOVW_GOTOFF_G2_NC";
141		case 306: return "R_AARCH64_MOVW_GOTOFF_G3";
142		case 307: return "R_AARCH64_GOTREL64";
143		case 308: return "R_AARCH64_GOTREL32";
144		case 309: return "R_AARCH64_GOT_LD_PREL19";
145		case 310: return "R_AARCH64_LD64_GOTOFF_LO15";
146		case 311: return "R_AARCH64_ADR_GOT_PAGE";
147		case 312: return "R_AARCH64_LD64_GOT_LO12_NC";
148		case 313: return "R_AARCH64_LD64_GOTPAGE_LO15";
149		case 560: return "R_AARCH64_TLSDESC_LD_PREL19";
150		case 561: return "R_AARCH64_TLSDESC_ADR_PREL21";
151		case 562: return "R_AARCH64_TLSDESC_ADR_PAGE21";
152		case 563: return "R_AARCH64_TLSDESC_LD64_LO12";
153		case 564: return "R_AARCH64_TLSDESC_ADD_LO12";
154		case 565: return "R_AARCH64_TLSDESC_OFF_G1";
155		case 566: return "R_AARCH64_TLSDESC_OFF_G0_NC";
156		case 567: return "R_AARCH64_TLSDESC_LDR";
157		case 568: return "R_AARCH64_TLSDESC_ADD";
158		case 569: return "R_AARCH64_TLSDESC_CALL";
159		case 1024: return "R_AARCH64_COPY";
160		case 1025: return "R_AARCH64_GLOB_DAT";
161		case 1026: return "R_AARCH64_JUMP_SLOT";
162		case 1027: return "R_AARCH64_RELATIVE";
163		case 1028: return "R_AARCH64_TLS_DTPREL64";
164		case 1029: return "R_AARCH64_TLS_DTPMOD64";
165		case 1030: return "R_AARCH64_TLS_TPREL64";
166		case 1031: return "R_AARCH64_TLSDESC";
167		case 1032: return "R_AARCH64_IRELATIVE";
168		}
169		break;
170	case EM_ARM:
171		switch(type) {
172		case 0: return "R_ARM_NONE";
173		case 1: return "R_ARM_PC24"; /* Deprecated */
174		case 2: return "R_ARM_ABS32";
175		case 3: return "R_ARM_REL32";
176		case 4: return "R_ARM_LDR_PC_G0"; /* Also R_ARM_PC13 */
177		case 5: return "R_ARM_ABS16";
178		case 6: return "R_ARM_ABS12";
179		case 7: return "R_ARM_THM_ABS5";
180		case 8: return "R_ARM_ABS8";
181		case 9: return "R_ARM_SBREL32";
182		case 10: return "R_ARM_THM_CALL"; /* Also R_ARM_THM_PC22 */
183		case 11: return "R_ARM_THM_PC8";
184		case 12: return "R_ARM_BREL_ADJ"; /* Also R_ARM_AMP_VCALL9 */
185		case 13: return "R_ARM_TLS_DESC"; /* Also R_ARM_SWI24 */
186		case 14: return "R_ARM_THM_SWI8"; /* Obsolete */
187		case 15: return "R_ARM_XPC25"; /* Obsolete */
188		case 16: return "R_ARM_THM_XPC22"; /* Obsolete */
189		case 17: return "R_ARM_TLS_DTPMOD32";
190		case 18: return "R_ARM_TLS_DTPOFF32";
191		case 19: return "R_ARM_TLS_TPOFF32";
192		case 20: return "R_ARM_COPY";
193		case 21: return "R_ARM_GLOB_DAT";
194		case 22: return "R_ARM_JUMP_SLOT";
195		case 23: return "R_ARM_RELATIVE";
196		case 24: return "R_ARM_GOTOFF32"; /* Also R_ARM_GOTOFF */
197		case 25: return "R_ARM_BASE_PREL"; /* GNU R_ARM_GOTPC */
198		case 26: return "R_ARM_GOT_BREL"; /* GNU R_ARM_GOT32 */
199		case 27: return "R_ARM_PLT32"; /* Deprecated */
200		case 28: return "R_ARM_CALL";
201		case 29: return "R_ARM_JUMP24";
202		case 30: return "R_ARM_THM_JUMP24";
203		case 31: return "R_ARM_BASE_ABS";
204		case 32: return "R_ARM_ALU_PCREL_7_0"; /* Obsolete */
205		case 33: return "R_ARM_ALU_PCREL_15_8"; /* Obsolete */
206		case 34: return "R_ARM_ALU_PCREL_23_15"; /* Obsolete */
207		case 35: return "R_ARM_LDR_SBREL_11_0_NC"; /* Deprecated */
208		case 36: return "R_ARM_ALU_SBREL_19_12_NC"; /* Deprecated */
209		case 37: return "R_ARM_ALU_SBREL_27_20_CK"; /* Deprecated */
210		case 38: return "R_ARM_TARGET1";
211		case 39: return "R_ARM_SBREL31"; /* Deprecated. */
212		case 40: return "R_ARM_V4BX";
213		case 41: return "R_ARM_TARGET2";
214		case 42: return "R_ARM_PREL31";
215		case 43: return "R_ARM_MOVW_ABS_NC";
216		case 44: return "R_ARM_MOVT_ABS";
217		case 45: return "R_ARM_MOVW_PREL_NC";
218		case 46: return "R_ARM_MOVT_PREL";
219		case 47: return "R_ARM_THM_MOVW_ABS_NC";
220		case 48: return "R_ARM_THM_MOVT_ABS";
221		case 49: return "R_ARM_THM_MOVW_PREL_NC";
222		case 50: return "R_ARM_THM_MOVT_PREL";
223		case 51: return "R_ARM_THM_JUMP19";
224		case 52: return "R_ARM_THM_JUMP6";
225		case 53: return "R_ARM_THM_ALU_PREL_11_0";
226		case 54: return "R_ARM_THM_PC12";
227		case 55: return "R_ARM_ABS32_NOI";
228		case 56: return "R_ARM_REL32_NOI";
229		case 57: return "R_ARM_ALU_PC_G0_NC";
230		case 58: return "R_ARM_ALU_PC_G0";
231		case 59: return "R_ARM_ALU_PC_G1_NC";
232		case 60: return "R_ARM_ALU_PC_G1";
233		case 61: return "R_ARM_ALU_PC_G2";
234		case 62: return "R_ARM_LDR_PC_G1";
235		case 63: return "R_ARM_LDR_PC_G2";
236		case 64: return "R_ARM_LDRS_PC_G0";
237		case 65: return "R_ARM_LDRS_PC_G1";
238		case 66: return "R_ARM_LDRS_PC_G2";
239		case 67: return "R_ARM_LDC_PC_G0";
240		case 68: return "R_ARM_LDC_PC_G1";
241		case 69: return "R_ARM_LDC_PC_G2";
242		case 70: return "R_ARM_ALU_SB_G0_NC";
243		case 71: return "R_ARM_ALU_SB_G0";
244		case 72: return "R_ARM_ALU_SB_G1_NC";
245		case 73: return "R_ARM_ALU_SB_G1";
246		case 74: return "R_ARM_ALU_SB_G2";
247		case 75: return "R_ARM_LDR_SB_G0";
248		case 76: return "R_ARM_LDR_SB_G1";
249		case 77: return "R_ARM_LDR_SB_G2";
250		case 78: return "R_ARM_LDRS_SB_G0";
251		case 79: return "R_ARM_LDRS_SB_G1";
252		case 80: return "R_ARM_LDRS_SB_G2";
253		case 81: return "R_ARM_LDC_SB_G0";
254		case 82: return "R_ARM_LDC_SB_G1";
255		case 83: return "R_ARM_LDC_SB_G2";
256		case 84: return "R_ARM_MOVW_BREL_NC";
257		case 85: return "R_ARM_MOVT_BREL";
258		case 86: return "R_ARM_MOVW_BREL";
259		case 87: return "R_ARM_THM_MOVW_BREL_NC";
260		case 88: return "R_ARM_THM_MOVT_BREL";
261		case 89: return "R_ARM_THM_MOVW_BREL";
262		case 90: return "R_ARM_TLS_GOTDESC";
263		case 91: return "R_ARM_TLS_CALL";
264		case 92: return "R_ARM_TLS_DESCSEQ";
265		case 93: return "R_ARM_THM_TLS_CALL";
266		case 94: return "R_ARM_PLT32_ABS";
267		case 95: return "R_ARM_GOT_ABS";
268		case 96: return "R_ARM_GOT_PREL";
269		case 97: return "R_ARM_GOT_BREL12";
270		case 98: return "R_ARM_GOTOFF12";
271		case 99: return "R_ARM_GOTRELAX";
272		case 100: return "R_ARM_GNU_VTENTRY";
273		case 101: return "R_ARM_GNU_VTINHERIT";
274		case 102: return "R_ARM_THM_JUMP11"; /* Also R_ARM_THM_PC11 */
275		case 103: return "R_ARM_THM_JUMP8"; /* Also R_ARM_THM_PC9 */
276		case 104: return "R_ARM_TLS_GD32";
277		case 105: return "R_ARM_TLS_LDM32";
278		case 106: return "R_ARM_TLS_LDO32";
279		case 107: return "R_ARM_TLS_IE32";
280		case 108: return "R_ARM_TLS_LE32";
281		case 109: return "R_ARM_TLS_LDO12";
282		case 110: return "R_ARM_TLS_LE12";
283		case 111: return "R_ARM_TLS_IE12GP";
284		/* 112-127 R_ARM_PRIVATE_<n> */
285		case 128: return "R_ARM_ME_TOO"; /* Obsolete */
286		case 129: return "R_ARM_THM_TLS_DESCSEQ16";
287		case 130: return "R_ARM_THM_TLS_DESCSEQ32";
288		case 131: return "R_ARM_THM_GOT_BREL12";
289		case 132: return "R_ARM_THM_ALU_ABS_G0_NC";
290		case 133: return "R_ARM_THM_ALU_ABS_G1_NC";
291		case 134: return "R_ARM_THM_ALU_ABS_G2_NC";
292		case 135: return "R_ARM_THM_ALU_ABS_G3";
293		/* 136-159 Reserved for future allocation. */
294		case 160: return "R_ARM_IRELATIVE";
295		/* 161-255 Reserved for future allocation. */
296		case 249: return "R_ARM_RXPC25";
297		case 250: return "R_ARM_RSBREL32";
298		case 251: return "R_ARM_THM_RPC22";
299		case 252: return "R_ARM_RREL32";
300		case 253: return "R_ARM_RABS32";
301		case 254: return "R_ARM_RPC24";
302		case 255: return "R_ARM_RBASE";
303		}
304		break;
305	case EM_IA_64:
306		switch(type) {
307		case 0: return "R_IA_64_NONE";
308		case 33: return "R_IA_64_IMM14";
309		case 34: return "R_IA_64_IMM22";
310		case 35: return "R_IA_64_IMM64";
311		case 36: return "R_IA_64_DIR32MSB";
312		case 37: return "R_IA_64_DIR32LSB";
313		case 38: return "R_IA_64_DIR64MSB";
314		case 39: return "R_IA_64_DIR64LSB";
315		case 42: return "R_IA_64_GPREL22";
316		case 43: return "R_IA_64_GPREL64I";
317		case 44: return "R_IA_64_GPREL32MSB";
318		case 45: return "R_IA_64_GPREL32LSB";
319		case 46: return "R_IA_64_GPREL64MSB";
320		case 47: return "R_IA_64_GPREL64LSB";
321		case 50: return "R_IA_64_LTOFF22";
322		case 51: return "R_IA_64_LTOFF64I";
323		case 58: return "R_IA_64_PLTOFF22";
324		case 59: return "R_IA_64_PLTOFF64I";
325		case 62: return "R_IA_64_PLTOFF64MSB";
326		case 63: return "R_IA_64_PLTOFF64LSB";
327		case 67: return "R_IA_64_FPTR64I";
328		case 68: return "R_IA_64_FPTR32MSB";
329		case 69: return "R_IA_64_FPTR32LSB";
330		case 70: return "R_IA_64_FPTR64MSB";
331		case 71: return "R_IA_64_FPTR64LSB";
332		case 72: return "R_IA_64_PCREL60B";
333		case 73: return "R_IA_64_PCREL21B";
334		case 74: return "R_IA_64_PCREL21M";
335		case 75: return "R_IA_64_PCREL21F";
336		case 76: return "R_IA_64_PCREL32MSB";
337		case 77: return "R_IA_64_PCREL32LSB";
338		case 78: return "R_IA_64_PCREL64MSB";
339		case 79: return "R_IA_64_PCREL64LSB";
340		case 82: return "R_IA_64_LTOFF_FPTR22";
341		case 83: return "R_IA_64_LTOFF_FPTR64I";
342		case 84: return "R_IA_64_LTOFF_FPTR32MSB";
343		case 85: return "R_IA_64_LTOFF_FPTR32LSB";
344		case 86: return "R_IA_64_LTOFF_FPTR64MSB";
345		case 87: return "R_IA_64_LTOFF_FPTR64LSB";
346		case 92: return "R_IA_64_SEGREL32MSB";
347		case 93: return "R_IA_64_SEGREL32LSB";
348		case 94: return "R_IA_64_SEGREL64MSB";
349		case 95: return "R_IA_64_SEGREL64LSB";
350		case 100: return "R_IA_64_SECREL32MSB";
351		case 101: return "R_IA_64_SECREL32LSB";
352		case 102: return "R_IA_64_SECREL64MSB";
353		case 103: return "R_IA_64_SECREL64LSB";
354		case 108: return "R_IA_64_REL32MSB";
355		case 109: return "R_IA_64_REL32LSB";
356		case 110: return "R_IA_64_REL64MSB";
357		case 111: return "R_IA_64_REL64LSB";
358		case 116: return "R_IA_64_LTV32MSB";
359		case 117: return "R_IA_64_LTV32LSB";
360		case 118: return "R_IA_64_LTV64MSB";
361		case 119: return "R_IA_64_LTV64LSB";
362		case 121: return "R_IA_64_PCREL21BI";
363		case 122: return "R_IA_64_PCREL22";
364		case 123: return "R_IA_64_PCREL64I";
365		case 128: return "R_IA_64_IPLTMSB";
366		case 129: return "R_IA_64_IPLTLSB";
367		case 133: return "R_IA_64_SUB";
368		case 134: return "R_IA_64_LTOFF22X";
369		case 135: return "R_IA_64_LDXMOV";
370		case 145: return "R_IA_64_TPREL14";
371		case 146: return "R_IA_64_TPREL22";
372		case 147: return "R_IA_64_TPREL64I";
373		case 150: return "R_IA_64_TPREL64MSB";
374		case 151: return "R_IA_64_TPREL64LSB";
375		case 154: return "R_IA_64_LTOFF_TPREL22";
376		case 166: return "R_IA_64_DTPMOD64MSB";
377		case 167: return "R_IA_64_DTPMOD64LSB";
378		case 170: return "R_IA_64_LTOFF_DTPMOD22";
379		case 177: return "R_IA_64_DTPREL14";
380		case 178: return "R_IA_64_DTPREL22";
381		case 179: return "R_IA_64_DTPREL64I";
382		case 180: return "R_IA_64_DTPREL32MSB";
383		case 181: return "R_IA_64_DTPREL32LSB";
384		case 182: return "R_IA_64_DTPREL64MSB";
385		case 183: return "R_IA_64_DTPREL64LSB";
386		case 186: return "R_IA_64_LTOFF_DTPREL22";
387		}
388		break;
389	case EM_MIPS:
390		switch(type) {
391		case 0: return "R_MIPS_NONE";
392		case 1: return "R_MIPS_16";
393		case 2: return "R_MIPS_32";
394		case 3: return "R_MIPS_REL32";
395		case 4: return "R_MIPS_26";
396		case 5: return "R_MIPS_HI16";
397		case 6: return "R_MIPS_LO16";
398		case 7: return "R_MIPS_GPREL16";
399		case 8: return "R_MIPS_LITERAL";
400		case 9: return "R_MIPS_GOT16";
401		case 10: return "R_MIPS_PC16";
402		case 11: return "R_MIPS_CALL16";
403		case 12: return "R_MIPS_GPREL32";
404		case 16: return "R_MIPS_SHIFT5";
405		case 17: return "R_MIPS_SHIFT6";
406		case 18: return "R_MIPS_64";
407		case 19: return "R_MIPS_GOT_DISP";
408		case 20: return "R_MIPS_GOT_PAGE";
409		case 21: return "R_MIPS_GOT_OFST";
410		case 22: return "R_MIPS_GOT_HI16";
411		case 23: return "R_MIPS_GOT_LO16";
412		case 24: return "R_MIPS_SUB";
413		case 30: return "R_MIPS_CALLHI16";
414		case 31: return "R_MIPS_CALLLO16";
415		case 37: return "R_MIPS_JALR";
416		case 38: return "R_MIPS_TLS_DTPMOD32";
417		case 39: return "R_MIPS_TLS_DTPREL32";
418		case 40: return "R_MIPS_TLS_DTPMOD64";
419		case 41: return "R_MIPS_TLS_DTPREL64";
420		case 42: return "R_MIPS_TLS_GD";
421		case 43: return "R_MIPS_TLS_LDM";
422		case 44: return "R_MIPS_TLS_DTPREL_HI16";
423		case 45: return "R_MIPS_TLS_DTPREL_LO16";
424		case 46: return "R_MIPS_TLS_GOTTPREL";
425		case 47: return "R_MIPS_TLS_TPREL32";
426		case 48: return "R_MIPS_TLS_TPREL64";
427		case 49: return "R_MIPS_TLS_TPREL_HI16";
428		case 50: return "R_MIPS_TLS_TPREL_LO16";
429		}
430		break;
431	case EM_PPC:
432		switch(type) {
433		case 0: return "R_PPC_NONE";
434		case 1: return "R_PPC_ADDR32";
435		case 2: return "R_PPC_ADDR24";
436		case 3: return "R_PPC_ADDR16";
437		case 4: return "R_PPC_ADDR16_LO";
438		case 5: return "R_PPC_ADDR16_HI";
439		case 6: return "R_PPC_ADDR16_HA";
440		case 7: return "R_PPC_ADDR14";
441		case 8: return "R_PPC_ADDR14_BRTAKEN";
442		case 9: return "R_PPC_ADDR14_BRNTAKEN";
443		case 10: return "R_PPC_REL24";
444		case 11: return "R_PPC_REL14";
445		case 12: return "R_PPC_REL14_BRTAKEN";
446		case 13: return "R_PPC_REL14_BRNTAKEN";
447		case 14: return "R_PPC_GOT16";
448		case 15: return "R_PPC_GOT16_LO";
449		case 16: return "R_PPC_GOT16_HI";
450		case 17: return "R_PPC_GOT16_HA";
451		case 18: return "R_PPC_PLTREL24";
452		case 19: return "R_PPC_COPY";
453		case 20: return "R_PPC_GLOB_DAT";
454		case 21: return "R_PPC_JMP_SLOT";
455		case 22: return "R_PPC_RELATIVE";
456		case 23: return "R_PPC_LOCAL24PC";
457		case 24: return "R_PPC_UADDR32";
458		case 25: return "R_PPC_UADDR16";
459		case 26: return "R_PPC_REL32";
460		case 27: return "R_PPC_PLT32";
461		case 28: return "R_PPC_PLTREL32";
462		case 29: return "R_PPC_PLT16_LO";
463		case 30: return "R_PPC_PLT16_HI";
464		case 31: return "R_PPC_PLT16_HA";
465		case 32: return "R_PPC_SDAREL16";
466		case 33: return "R_PPC_SECTOFF";
467		case 34: return "R_PPC_SECTOFF_LO";
468		case 35: return "R_PPC_SECTOFF_HI";
469		case 36: return "R_PPC_SECTOFF_HA";
470		case 67: return "R_PPC_TLS";
471		case 68: return "R_PPC_DTPMOD32";
472		case 69: return "R_PPC_TPREL16";
473		case 70: return "R_PPC_TPREL16_LO";
474		case 71: return "R_PPC_TPREL16_HI";
475		case 72: return "R_PPC_TPREL16_HA";
476		case 73: return "R_PPC_TPREL32";
477		case 74: return "R_PPC_DTPREL16";
478		case 75: return "R_PPC_DTPREL16_LO";
479		case 76: return "R_PPC_DTPREL16_HI";
480		case 77: return "R_PPC_DTPREL16_HA";
481		case 78: return "R_PPC_DTPREL32";
482		case 79: return "R_PPC_GOT_TLSGD16";
483		case 80: return "R_PPC_GOT_TLSGD16_LO";
484		case 81: return "R_PPC_GOT_TLSGD16_HI";
485		case 82: return "R_PPC_GOT_TLSGD16_HA";
486		case 83: return "R_PPC_GOT_TLSLD16";
487		case 84: return "R_PPC_GOT_TLSLD16_LO";
488		case 85: return "R_PPC_GOT_TLSLD16_HI";
489		case 86: return "R_PPC_GOT_TLSLD16_HA";
490		case 87: return "R_PPC_GOT_TPREL16";
491		case 88: return "R_PPC_GOT_TPREL16_LO";
492		case 89: return "R_PPC_GOT_TPREL16_HI";
493		case 90: return "R_PPC_GOT_TPREL16_HA";
494		case 101: return "R_PPC_EMB_NADDR32";
495		case 102: return "R_PPC_EMB_NADDR16";
496		case 103: return "R_PPC_EMB_NADDR16_LO";
497		case 104: return "R_PPC_EMB_NADDR16_HI";
498		case 105: return "R_PPC_EMB_NADDR16_HA";
499		case 106: return "R_PPC_EMB_SDAI16";
500		case 107: return "R_PPC_EMB_SDA2I16";
501		case 108: return "R_PPC_EMB_SDA2REL";
502		case 109: return "R_PPC_EMB_SDA21";
503		case 110: return "R_PPC_EMB_MRKREF";
504		case 111: return "R_PPC_EMB_RELSEC16";
505		case 112: return "R_PPC_EMB_RELST_LO";
506		case 113: return "R_PPC_EMB_RELST_HI";
507		case 114: return "R_PPC_EMB_RELST_HA";
508		case 115: return "R_PPC_EMB_BIT_FLD";
509		case 116: return "R_PPC_EMB_RELSDA";
510		}
511		break;
512	case EM_RISCV:
513		switch(type) {
514		case 0: return "R_RISCV_NONE";
515		case 1: return "R_RISCV_32";
516		case 2: return "R_RISCV_64";
517		case 3: return "R_RISCV_RELATIVE";
518		case 4: return "R_RISCV_COPY";
519		case 5: return "R_RISCV_JUMP_SLOT";
520		case 6: return "R_RISCV_TLS_DTPMOD32";
521		case 7: return "R_RISCV_TLS_DTPMOD64";
522		case 8: return "R_RISCV_TLS_DTPREL32";
523		case 9: return "R_RISCV_TLS_DTPREL64";
524		case 10: return "R_RISCV_TLS_TPREL32";
525		case 11: return "R_RISCV_TLS_TPREL64";
526		case 16: return "R_RISCV_BRANCH";
527		case 17: return "R_RISCV_JAL";
528		case 18: return "R_RISCV_CALL";
529		case 19: return "R_RISCV_CALL_PLT";
530		case 20: return "R_RISCV_GOT_HI20";
531		case 21: return "R_RISCV_TLS_GOT_HI20";
532		case 22: return "R_RISCV_TLS_GD_HI20";
533		case 23: return "R_RISCV_PCREL_HI20";
534		case 24: return "R_RISCV_PCREL_LO12_I";
535		case 25: return "R_RISCV_PCREL_LO12_S";
536		case 26: return "R_RISCV_HI20";
537		case 27: return "R_RISCV_LO12_I";
538		case 28: return "R_RISCV_LO12_S";
539		case 29: return "R_RISCV_TPREL_HI20";
540		case 30: return "R_RISCV_TPREL_LO12_I";
541		case 31: return "R_RISCV_TPREL_LO12_S";
542		case 32: return "R_RISCV_TPREL_ADD";
543		case 33: return "R_RISCV_ADD8";
544		case 34: return "R_RISCV_ADD16";
545		case 35: return "R_RISCV_ADD32";
546		case 36: return "R_RISCV_ADD64";
547		case 37: return "R_RISCV_SUB8";
548		case 38: return "R_RISCV_SUB16";
549		case 39: return "R_RISCV_SUB32";
550		case 40: return "R_RISCV_SUB64";
551		case 41: return "R_RISCV_GNU_VTINHERIT";
552		case 42: return "R_RISCV_GNU_VTENTRY";
553		case 43: return "R_RISCV_ALIGN";
554		case 44: return "R_RISCV_RVC_BRANCH";
555		case 45: return "R_RISCV_RVC_JUMP";
556		}
557		break;
558	case EM_SPARC:
559	case EM_SPARCV9:
560		switch(type) {
561		case 0: return "R_SPARC_NONE";
562		case 1: return "R_SPARC_8";
563		case 2: return "R_SPARC_16";
564		case 3: return "R_SPARC_32";
565		case 4: return "R_SPARC_DISP8";
566		case 5: return "R_SPARC_DISP16";
567		case 6: return "R_SPARC_DISP32";
568		case 7: return "R_SPARC_WDISP30";
569		case 8: return "R_SPARC_WDISP22";
570		case 9: return "R_SPARC_HI22";
571		case 10: return "R_SPARC_22";
572		case 11: return "R_SPARC_13";
573		case 12: return "R_SPARC_LO10";
574		case 13: return "R_SPARC_GOT10";
575		case 14: return "R_SPARC_GOT13";
576		case 15: return "R_SPARC_GOT22";
577		case 16: return "R_SPARC_PC10";
578		case 17: return "R_SPARC_PC22";
579		case 18: return "R_SPARC_WPLT30";
580		case 19: return "R_SPARC_COPY";
581		case 20: return "R_SPARC_GLOB_DAT";
582		case 21: return "R_SPARC_JMP_SLOT";
583		case 22: return "R_SPARC_RELATIVE";
584		case 23: return "R_SPARC_UA32";
585		case 24: return "R_SPARC_PLT32";
586		case 25: return "R_SPARC_HIPLT22";
587		case 26: return "R_SPARC_LOPLT10";
588		case 27: return "R_SPARC_PCPLT32";
589		case 28: return "R_SPARC_PCPLT22";
590		case 29: return "R_SPARC_PCPLT10";
591		case 30: return "R_SPARC_10";
592		case 31: return "R_SPARC_11";
593		case 32: return "R_SPARC_64";
594		case 33: return "R_SPARC_OLO10";
595		case 34: return "R_SPARC_HH22";
596		case 35: return "R_SPARC_HM10";
597		case 36: return "R_SPARC_LM22";
598		case 37: return "R_SPARC_PC_HH22";
599		case 38: return "R_SPARC_PC_HM10";
600		case 39: return "R_SPARC_PC_LM22";
601		case 40: return "R_SPARC_WDISP16";
602		case 41: return "R_SPARC_WDISP19";
603		case 42: return "R_SPARC_GLOB_JMP";
604		case 43: return "R_SPARC_7";
605		case 44: return "R_SPARC_5";
606		case 45: return "R_SPARC_6";
607		case 46: return "R_SPARC_DISP64";
608		case 47: return "R_SPARC_PLT64";
609		case 48: return "R_SPARC_HIX22";
610		case 49: return "R_SPARC_LOX10";
611		case 50: return "R_SPARC_H44";
612		case 51: return "R_SPARC_M44";
613		case 52: return "R_SPARC_L44";
614		case 53: return "R_SPARC_REGISTER";
615		case 54: return "R_SPARC_UA64";
616		case 55: return "R_SPARC_UA16";
617		case 56: return "R_SPARC_TLS_GD_HI22";
618		case 57: return "R_SPARC_TLS_GD_LO10";
619		case 58: return "R_SPARC_TLS_GD_ADD";
620		case 59: return "R_SPARC_TLS_GD_CALL";
621		case 60: return "R_SPARC_TLS_LDM_HI22";
622		case 61: return "R_SPARC_TLS_LDM_LO10";
623		case 62: return "R_SPARC_TLS_LDM_ADD";
624		case 63: return "R_SPARC_TLS_LDM_CALL";
625		case 64: return "R_SPARC_TLS_LDO_HIX22";
626		case 65: return "R_SPARC_TLS_LDO_LOX10";
627		case 66: return "R_SPARC_TLS_LDO_ADD";
628		case 67: return "R_SPARC_TLS_IE_HI22";
629		case 68: return "R_SPARC_TLS_IE_LO10";
630		case 69: return "R_SPARC_TLS_IE_LD";
631		case 70: return "R_SPARC_TLS_IE_LDX";
632		case 71: return "R_SPARC_TLS_IE_ADD";
633		case 72: return "R_SPARC_TLS_LE_HIX22";
634		case 73: return "R_SPARC_TLS_LE_LOX10";
635		case 74: return "R_SPARC_TLS_DTPMOD32";
636		case 75: return "R_SPARC_TLS_DTPMOD64";
637		case 76: return "R_SPARC_TLS_DTPOFF32";
638		case 77: return "R_SPARC_TLS_DTPOFF64";
639		case 78: return "R_SPARC_TLS_TPOFF32";
640		case 79: return "R_SPARC_TLS_TPOFF64";
641		}
642		break;
643	case EM_X86_64:
644		switch(type) {
645		case 0: return "R_X86_64_NONE";
646		case 1: return "R_X86_64_64";
647		case 2: return "R_X86_64_PC32";
648		case 3: return "R_X86_64_GOT32";
649		case 4: return "R_X86_64_PLT32";
650		case 5: return "R_X86_64_COPY";
651		case 6: return "R_X86_64_GLOB_DAT";
652		case 7: return "R_X86_64_JUMP_SLOT";
653		case 8: return "R_X86_64_RELATIVE";
654		case 9: return "R_X86_64_GOTPCREL";
655		case 10: return "R_X86_64_32";
656		case 11: return "R_X86_64_32S";
657		case 12: return "R_X86_64_16";
658		case 13: return "R_X86_64_PC16";
659		case 14: return "R_X86_64_8";
660		case 15: return "R_X86_64_PC8";
661		case 16: return "R_X86_64_DTPMOD64";
662		case 17: return "R_X86_64_DTPOFF64";
663		case 18: return "R_X86_64_TPOFF64";
664		case 19: return "R_X86_64_TLSGD";
665		case 20: return "R_X86_64_TLSLD";
666		case 21: return "R_X86_64_DTPOFF32";
667		case 22: return "R_X86_64_GOTTPOFF";
668		case 23: return "R_X86_64_TPOFF32";
669		case 24: return "R_X86_64_PC64";
670		case 25: return "R_X86_64_GOTOFF64";
671		case 26: return "R_X86_64_GOTPC32";
672		case 27: return "R_X86_64_GOT64";
673		case 28: return "R_X86_64_GOTPCREL64";
674		case 29: return "R_X86_64_GOTPC64";
675		case 30: return "R_X86_64_GOTPLT64";
676		case 31: return "R_X86_64_PLTOFF64";
677		case 32: return "R_X86_64_SIZE32";
678		case 33: return "R_X86_64_SIZE64";
679		case 34: return "R_X86_64_GOTPC32_TLSDESC";
680		case 35: return "R_X86_64_TLSDESC_CALL";
681		case 36: return "R_X86_64_TLSDESC";
682		case 37: return "R_X86_64_IRELATIVE";
683		case 38: return "R_X86_64_RELATIVE64";
684		case 41: return "R_X86_64_GOTPCRELX";
685		case 42: return "R_X86_64_REX_GOTPCRELX";
686		}
687		break;
688	}
689
690	snprintf(s_type, sizeof(s_type), "<unknown: %#x>", type);
691	return (s_type);
692}
693