xref: /titanic_51/usr/src/uts/intel/amd64/krtld/kobj_convrelstr.c (revision 2926dd2e801916128855cec712d18656be9bd1c5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21552ff457Srie 
227c478bd9Sstevel@tonic-gate /*
235aefb655Srie  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include	<sys/types.h>
297c478bd9Sstevel@tonic-gate #include	"reloc.h"
307c478bd9Sstevel@tonic-gate 
31552ff457Srie static const char	*rels[R_AMD64_NUM] = {
32552ff457Srie 	"R_AMD64_NONE",			"R_AMD64_64",
33552ff457Srie 	"R_AMD64_PC32",			"R_AMD64_GOT32",
34552ff457Srie 	"R_AMD64_PLT32",		"R_AMD64_COPY",
35552ff457Srie 	"R_AMD64_GLOB_DATA",		"R_AMD64_JUMP_SLOT",
36552ff457Srie 	"R_AMD64_RELATIVE",		"R_AMD64_GOTPCREL",
37552ff457Srie 	"R_AMD64_32",			"R_AMD64_32S",
38552ff457Srie 	"R_AMD64_16",			"R_AMD64_PC16",
39552ff457Srie 	"R_AMD64_8",			"R_AMD64_PC8",
40552ff457Srie 	"R_AMD64_DPTMOD64",		"R_AMD64_DTPOFF64",
41552ff457Srie 	"R_AMD64_TPOFF64",		"R_AMD64_TLSGD",
42552ff457Srie 	"R_AMD64_TLSLD",		"R_AMD64_DTPOFF32",
43552ff457Srie 	"R_AMD64_GOTTPOFF",		"R_AMD64_TPOFF32",
44552ff457Srie 	"R_AMD64_PC64",			"R_AMD64_GOTOFF64",
45552ff457Srie 	"R_AMD64_GOTPC32",		"R_AMD64_GOT64",
46552ff457Srie 	"R_AMD64_GOTPCREL64",		"R_AMD64_GOTPC64",
47*2926dd2eSrie 	"R_AMD64_GOTPLT64",		"R_AMD64_PLTOFF64",
48*2926dd2eSrie 	"R_AMD64_SIZE32",		"R_AMD64_SIZE64"
497c478bd9Sstevel@tonic-gate };
507c478bd9Sstevel@tonic-gate 
51*2926dd2eSrie #if	(R_AMD64_NUM != (R_AMD64_SIZE64 + 1))
527c478bd9Sstevel@tonic-gate #error	"R_AMD64_NUM has grown"
537c478bd9Sstevel@tonic-gate #endif
54552ff457Srie 
55552ff457Srie /*
56552ff457Srie  * This is a 'stub' of the orignal version defined in liblddbg.so.  This stub
57552ff457Srie  * returns the 'int string' of the relocation in question instead of converting
58552ff457Srie  * the relocation to it's full syntax.
59552ff457Srie  */
60552ff457Srie const char *
615aefb655Srie conv_reloc_amd64_type(Word type)
62552ff457Srie {
637c478bd9Sstevel@tonic-gate 	static char 	strbuf[32];
647c478bd9Sstevel@tonic-gate 	int		ndx = 31;
65552ff457Srie 
66552ff457Srie 	if (type < R_AMD64_NUM)
67552ff457Srie 		return (rels[type]);
68552ff457Srie 
697c478bd9Sstevel@tonic-gate 	strbuf[ndx--] = '\0';
707c478bd9Sstevel@tonic-gate 	do {
71552ff457Srie 		strbuf[ndx--] = '0' + (type % 10);
72552ff457Srie 		type = type / 10;
73552ff457Srie 	} while ((ndx >= (int)0) && (type > (Word)0));
74552ff457Srie 
757c478bd9Sstevel@tonic-gate 	return (&strbuf[ndx + 1]);
767c478bd9Sstevel@tonic-gate }
77