xref: /titanic_41/usr/src/uts/intel/amd64/krtld/kobj_convrelstr.c (revision fd9cb95cbb2f626355a60efb9d02c5f0a33c10e6)
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 2004 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 
32 #ifdef	KOBJ_DEBUG
33 static const char	*rels[] = {
34 	"R_AMD64_NONE",
35 	"R_AMD64_64",
36 	"R_AMD64_PC32",
37 	"R_AMD64_GOT32",
38 	"R_AMD64_PLT32",
39 	"R_AMD64_COPY",
40 	"R_AMD64_GLOB_DATA",
41 	"R_AMD64_JUMP_SLOT",
42 	"R_AMD64_RELATIVE",
43 	"R_AMD64_GOTPCREL",
44 	"R_AMD64_32",
45 	"R_AMD64_32S",
46 	"R_AMD64_16",
47 	"R_AMD64_PC16",
48 	"R_AMD64_8",
49 	"R_AMD64_PC8",
50 	"R_AMD64_DPTMOD64",
51 	"R_AMD64_DTPOFF64",
52 	"R_AMD64_TPOFF64",
53 	"R_AMD64_TLSGD",
54 	"R_AMD64_TLSLD",
55 	"R_AMD64_DTPOFF32",
56 	"R_AMD64_GOTTPOFF",
57 	"R_AMD64_TPOFF32",
58 	"R_AMD64_PC64",
59 	"R_AMD64_GOTOFF64",
60 	"R_AMD64_GOTPC32"
61 };
62 #endif
63 
64 
65 /*
66  * This is a 'stub' of the orignal version defined in liblddbg.so
67  * This stub just returns the 'int string' of the relocation in question
68  * instead of converting it to it's full syntax.
69  */
70 const char *
71 conv_reloc_amd64_type_str(Word rtype)
72 {
73 #ifdef	KOBJ_DEBUG
74 #if	(R_AMD64_NUM != (R_AMD64_GOTPC32 + 1))
75 #error	"R_AMD64_NUM has grown"
76 #endif
77 	if (rtype < R_AMD64_NUM)
78 		return (rels[rtype]);
79 	else {
80 #endif
81 		static char 	strbuf[32];
82 		int		ndx = 31;
83 		strbuf[ndx--] = '\0';
84 		do {
85 			strbuf[ndx--] = '0' + (rtype % 10);
86 			rtype = rtype / 10;
87 		} while ((ndx >= (int)0) && (rtype > (Word)0));
88 		return (&strbuf[ndx + 1]);
89 #ifdef	KOBJ_DEBUG
90 	}
91 #endif
92 }
93