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