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