xref: /titanic_50/usr/src/cmd/sgs/libconv/common/relocate_sparc.c (revision fb3fb4f3d76d55b64440afd0af72775dfad3bd1d)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * String conversion routine for relocation types.
31  */
32 #include	<stdio.h>
33 #include	<sys/elf_SPARC.h>
34 #include	"_conv.h"
35 #include	"relocate_sparc_msg.h"
36 
37 /*
38  * SPARC specific relocations.
39  */
40 static const Msg rels[R_SPARC_NUM] = {
41 	MSG_R_SPARC_NONE,		MSG_R_SPARC_8,
42 	MSG_R_SPARC_16,			MSG_R_SPARC_32,
43 	MSG_R_SPARC_DISP8,		MSG_R_SPARC_DISP16,
44 	MSG_R_SPARC_DISP32,		MSG_R_SPARC_WDISP30,
45 	MSG_R_SPARC_WDISP22,		MSG_R_SPARC_HI22,
46 	MSG_R_SPARC_22,			MSG_R_SPARC_13,
47 	MSG_R_SPARC_LO10,		MSG_R_SPARC_GOT10,
48 	MSG_R_SPARC_GOT13,		MSG_R_SPARC_GOT22,
49 	MSG_R_SPARC_PC10,		MSG_R_SPARC_PC22,
50 	MSG_R_SPARC_WPLT30,		MSG_R_SPARC_COPY,
51 	MSG_R_SPARC_GLOB_DAT,		MSG_R_SPARC_JMP_SLOT,
52 	MSG_R_SPARC_RELATIVE,		MSG_R_SPARC_UA32,
53 	MSG_R_SPARC_PLT32,		MSG_R_SPARC_HIPLT22,
54 	MSG_R_SPARC_LOPLT10,		MSG_R_SPARC_PCPLT32,
55 	MSG_R_SPARC_PCPLT22,		MSG_R_SPARC_PCPLT10,
56 	MSG_R_SPARC_10,			MSG_R_SPARC_11,
57 	MSG_R_SPARC_64,			MSG_R_SPARC_OLO10,
58 	MSG_R_SPARC_HH22,		MSG_R_SPARC_HM10,
59 	MSG_R_SPARC_LM22,		MSG_R_SPARC_PC_HH22,
60 	MSG_R_SPARC_PC_HM10,		MSG_R_SPARC_PC_LM22,
61 	MSG_R_SPARC_WDISP16,		MSG_R_SPARC_WDISP19,
62 	MSG_R_SPARC_GLOB_JMP,		MSG_R_SPARC_7,
63 	MSG_R_SPARC_5,			MSG_R_SPARC_6,
64 	MSG_R_SPARC_DISP64,		MSG_R_SPARC_PLT64,
65 	MSG_R_SPARC_HIX22,		MSG_R_SPARC_LOX10,
66 	MSG_R_SPARC_H44,		MSG_R_SPARC_M44,
67 	MSG_R_SPARC_L44,		MSG_R_SPARC_REGISTER,
68 	MSG_R_SPARC_UA64,		MSG_R_SPARC_UA16,
69 	MSG_R_SPARC_TLS_GD_HI22,	MSG_R_SPARC_TLS_GD_LO10,
70 	MSG_R_SPARC_TLS_GD_ADD,		MSG_R_SPARC_TLS_GD_CALL,
71 	MSG_R_SPARC_TLS_LDM_HI22,	MSG_R_SPARC_TLS_LDM_LO10,
72 	MSG_R_SPARC_TLS_LDM_ADD,	MSG_R_SPARC_TLS_LDM_CALL,
73 	MSG_R_SPARC_TLS_LDO_HIX22,	MSG_R_SPARC_TLS_LDO_LOX10,
74 	MSG_R_SPARC_TLS_LDO_ADD,	MSG_R_SPARC_TLS_IE_HI22,
75 	MSG_R_SPARC_TLS_IE_LO10,	MSG_R_SPARC_TLS_IE_LD,
76 	MSG_R_SPARC_TLS_IE_LDX,		MSG_R_SPARC_TLS_IE_ADD,
77 	MSG_R_SPARC_TLS_LE_HIX22,	MSG_R_SPARC_TLS_LE_LOX10,
78 	MSG_R_SPARC_TLS_DTPMOD32,	MSG_R_SPARC_TLS_DTPMOD64,
79 	MSG_R_SPARC_TLS_DTPOFF32,	MSG_R_SPARC_TLS_DTPOFF64,
80 	MSG_R_SPARC_TLS_TPOFF32,	MSG_R_SPARC_TLS_TPOFF64,
81 	MSG_R_SPARC_GOTDATA_HIX22,	MSG_R_SPARC_GOTDATA_LOX10,
82 	MSG_R_SPARC_GOTDATA_OP_HIX22,	MSG_R_SPARC_GOTDATA_OP_LOX10,
83 	MSG_R_SPARC_GOTDATA_OP,		MSG_R_SPARC_H34
84 };
85 
86 #if	(R_SPARC_NUM != (R_SPARC_H34 + 1))
87 #error	"R_SPARC_NUM has grown"
88 #endif
89 
90 const char *
91 conv_reloc_SPARC_type_str(uint_t type)
92 {
93 	static char	string[STRSIZE] = { '\0' };
94 
95 	if (type >= R_SPARC_NUM)
96 		return (conv_invalid_str(string, STRSIZE, type, 0));
97 	return (MSG_ORIG(rels[type]));
98 }
99