xref: /titanic_41/usr/src/uts/intel/ia32/krtld/kobj_convrelstr.c (revision 0adc16190e36914964740716575460dda750de39)
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 #include	<sys/types.h>
30 #include	"reloc.h"
31 
32 static const char	*rels[R_386_NUM] = {
33 	"R_386_NONE",			"R_386_32",
34 	"R_386_PC32",			"R_386_GOT32",
35 	"R_386_PLT32",			"R_386_COPY",
36 	"R_386_GLOB_DAT",		"R_386_JMP_SLOT",
37 	"R_386_RELATIVE",		"R_386_GOTOFF",
38 	"R_386_GOTPC",			"R_386_32PLT",
39 	"R_386_TLS_GD_PLT",		"R_386_TLS_LDM_PLT",
40 	"R_386_TLS_TPOFF",		"R_386_TLS_IE",
41 	"R_386_TLS_GOTIE",		"R_386_TLS_LE",
42 	"R_386_TLS_GD",			"R_386_TLS_LDM",
43 	"R_386_16",			"R_386_PC16",
44 	"R_386_8",			"R_386_PC8",
45 	"R_386_UNKNOWN24",		"R_386_UNKNOWN25",
46 	"R_386_UNKNOWN26",		"R_386_UNKNOWN27",
47 	"R_386_UNKNOWN28",		"R_386_UNKNOWN29",
48 	"R_386_UNKNOWN30",		"R_386_UNKNOWN31",
49 	"R_386_TLS_LDO_32",		"R_386_UNKNOWN33",
50 	"R_386_UNKNOWN34",		"R_386_TLS_DTPMOD32",
51 	"R_386_TLS_DTPOFF32",		"R_386_UNKNOWN37"
52 };
53 
54 #if	(R_386_NUM != (R_386_UNKNOWN37 + 1))
55 #error	"R_386_NUM has grown"
56 #endif
57 
58 /*
59  * This is a 'stub' of the orignal version defined in liblddbg.so.  This stub
60  * returns the 'int string' of the relocation in question instead of converting
61  * the relocation to it's full syntax.
62  */
63 const char *
64 conv_reloc_386_type_str(uint_t type)
65 {
66 	static char 	strbuf[32];
67 	int		ndx = 31;
68 
69 	if (type < R_386_NUM)
70 		return (rels[type]);
71 
72 	strbuf[ndx--] = '\0';
73 	do {
74 		strbuf[ndx--] = '0' + (type % 10);
75 		type = type / 10;
76 	} while ((ndx >= (int)0) && (type > (Word)0));
77 
78 	return (&strbuf[ndx + 1]);
79 }
80