xref: /titanic_41/usr/src/uts/sparc/krtld/kobj_convrelstr.c (revision 602ca9ea8f9ce0933f0944601cc5d230e91a950d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include	<sys/types.h>
29 #include	"krtld/reloc.h"
30 
31 static const char	*rels[R_SPARC_NUM] = {
32 	"R_SPARC_NONE",			"R_SPARC_8",
33 	"R_SPARC_16",			"R_SPARC_32",
34 	"R_SPARC_DISP8",		"R_SPARC_DISP16",
35 	"R_SPARC_DISP32",		"R_SPARC_WDISP30",
36 	"R_SPARC_WDISP22",		"R_SPARC_HI22",
37 	"R_SPARC_22",			"R_SPARC_13",
38 	"R_SPARC_LO10",			"R_SPARC_GOT10",
39 	"R_SPARC_GOT13",		"R_SPARC_GOT22",
40 	"R_SPARC_PC10",			"R_SPARC_PC22",
41 	"R_SPARC_WPLT30",		"R_SPARC_COPY",
42 	"R_SPARC_GLOB_DAT",		"R_SPARC_JMP_SLOT",
43 	"R_SPARC_RELATIVE",		"R_SPARC_UA32",
44 	"R_SPARC_PLT32",		"R_SPARC_HIPLT22",
45 	"R_SPARC_LOPLT10",		"R_SPARC_PCPLT32",
46 	"R_SPARC_PCPLT22",		"R_SPARC_PCPLT10",
47 	"R_SPARC_10",			"R_SPARC_11",
48 	"R_SPARC_64",			"R_SPARC_OLO10",
49 	"R_SPARC_HH22",			"R_SPARC_HM10",
50 	"R_SPARC_LM22",			"R_SPARC_PC_HH22",
51 	"R_SPARC_PC_HM10",		"R_SPARC_PC_LM22",
52 	"R_SPARC_WDISP16",		"R_SPARC_WDISP19",
53 	"R_SPARC_GLOB_JMP",		"R_SPARC_7",
54 	"R_SPARC_5",			"R_SPARC_6",
55 	"R_SPARC_DISP64",		"R_SPARC_PLT64",
56 	"R_SPARC_HIX22",		"R_SPARC_LOX10",
57 	"R_SPARC_H44",			"R_SPARC_M44",
58 	"R_SPARC_L44",			"R_SPARC_REGISTER",
59 	"R_SPARC_UA64",			"R_SPARC_UA16",
60 	"R_SPARC_TLS_GD_HI22",		"R_SPARC_TLS_GD_LO10",
61 	"R_SPARC_TLS_GD_ADD",		"R_SPARC_TLS_GD_CALL",
62 	"R_SPARC_TLS_LDM_HI22",		"R_SPARC_TLS_LDM_LO10",
63 	"R_SPARC_TLS_LDM_ADD",		"R_SPARC_TLS_LDM_CALL",
64 	"R_SPARC_TLS_LDO_HIX22",	"R_SPARC_TLS_LDO_LOX10",
65 	"R_SPARC_TLS_LDO_ADD",		"R_SPARC_TLS_IE_HI22",
66 	"R_SPARC_TLS_IE_LO10",		"R_SPARC_TLS_IE_LD",
67 	"R_SPARC_TLS_IE_LDX",		"R_SPARC_TLS_IE_ADD",
68 	"R_SPARC_TLS_LE_HIX22",		"R_SPARC_TLS_LE_LOX10",
69 	"R_SPARC_TLS_DTPMOD32",		"R_SPARC_TLS_DTPMOD64",
70 	"R_SPARC_TLS_DTPOFF32",		"R_SPARC_TLS_DTPOFF64",
71 	"R_SPARC_TLS_TPOFF32",		"R_SPARC_TLS_TPOFF64",
72 	"R_SPARC_GOTDATA_HIX22",	"R_SPARC_GOTDATA_LOX10",
73 	"R_SPARC_GOTDATA_OP_HIX22",	"R_SPARC_GOTDATA_OP_LOX10",
74 	"R_SPARC_GOTDATA_OP",		"R_SPARC_H34",
75 	"R_SPARC_SIZE32",		"R_SPARC_SIZE64"
76 };
77 
78 #if	(R_SPARC_NUM != (R_SPARC_SIZE64 + 1))
79 #error	"R_SPARC_NUM has grown"
80 #endif
81 
82 /*
83  * This is a 'stub' of the orignal version defined in liblddbg.so.  This stub
84  * returns the 'int string' of the relocation in question instead of converting
85  * the relocation to it's full syntax.
86  */
87 const char *
88 conv_reloc_SPARC_type(Word type)
89 {
90 	static char 	strbuf[32];
91 	int		ndx = 31;
92 
93 	if (type < R_SPARC_NUM)
94 		return (rels[type]);
95 
96 	strbuf[ndx--] = '\0';
97 	do {
98 		strbuf[ndx--] = '0' + (type % 10);
99 		type = type / 10;
100 	} while ((ndx >= (int)0) && (type > (Word)0));
101 
102 	return (&strbuf[ndx + 1]);
103 }
104