xref: /illumos-gate/usr/src/uts/sparc/krtld/kobj_convrelstr.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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  * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include	<sys/types.h>
29 #include	"reloc.h"
30 
31 
32 #ifdef	KOBJ_DEBUG
33 static const char	*rels[] = {
34 	"R_SPARC_NONE    ",
35 	"R_SPARC_8       ",
36 	"R_SPARC_16      ",
37 	"R_SPARC_32      ",
38 	"R_SPARC_DISP8   ",
39 	"R_SPARC_DISP16  ",
40 	"R_SPARC_DISP32  ",
41 	"R_SPARC_WDISP30 ",
42 	"R_SPARC_WDISP22 ",
43 	"R_SPARC_HI22    ",
44 	"R_SPARC_22      ",
45 	"R_SPARC_13      ",
46 	"R_SPARC_LO10    ",
47 	"R_SPARC_GOT10   ",
48 	"R_SPARC_GOT13   ",
49 	"R_SPARC_GOT22   ",
50 	"R_SPARC_PC10    ",
51 	"R_SPARC_PC22    ",
52 	"R_SPARC_WPLT30  ",
53 	"R_SPARC_COPY    ",
54 	"R_SPARC_GLOB_DAT",
55 	"R_SPARC_JMP_SLOT",
56 	"R_SPARC_RELATIVE",
57 	"R_SPARC_UA32    ",
58 	"R_SPARC_PLT32   ",
59 	"R_SPARC_HIPLT22 ",
60 	"R_SPARC_LOPLT10 ",
61 	"R_SPARC_PCPLT32 ",
62 	"R_SPARC_PCPLT22 ",
63 	"R_SPARC_PCPLT10 ",
64 	"R_SPARC_10      ",
65 	"R_SPARC_11      ",
66 	"R_SPARC_64      ",
67 	"R_SPARC_OLO10   ",
68 	"R_SPARC_HH22    ",
69 	"R_SPARC_HM10    ",
70 	"R_SPARC_LM22    ",
71 	"R_SPARC_PC_HH22 ",
72 	"R_SPARC_PC_HM10 ",
73 	"R_SPARC_PC_LM22 ",
74 	"R_SPARC_WDISP16 ",
75 	"R_SPARC_WDISP19 ",
76 	"R_SPARC_GLOB_JMP",
77 	"R_SPARC_7       ",
78 	"R_SPARC_5       ",
79 	"R_SPARC_6       "
80 };
81 #endif
82 
83 /*
84  * This is a 'stub' of the orignal version defined in liblddbg.so
85  * This stub just returns the 'int string' of the relocation in question
86  * instead of converting it to it's full syntax.
87  */
88 const char *
89 conv_reloc_SPARC_type_str(Word rtype)
90 {
91 #ifdef	KOBJ_DEBUG
92 	if (rtype < R_SPARC_NUM)
93 		return (rels[rtype]);
94 	else {
95 #endif
96 		static char 	strbuf[32];
97 		int		ndx = 31;
98 		strbuf[ndx--] = '\0';
99 		do {
100 			strbuf[ndx--] = '0' + (rtype % 10);
101 			rtype = rtype / 10;
102 		} while ((ndx >= (int)0) && (rtype > (Word)0));
103 		return (&strbuf[ndx + 1]);
104 #ifdef	KOBJ_DEBUG
105 	}
106 #endif
107 }
108