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