xref: /onnv-gate/usr/src/uts/intel/amd64/krtld/kobj_convrelstr.c (revision 1618:8c9a4f31d225)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1618Srie  * Common Development and Distribution License (the "License").
6*1618Srie  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211169Srie 
220Sstevel@tonic-gate /*
23*1618Srie  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include	<sys/types.h>
290Sstevel@tonic-gate #include	"reloc.h"
300Sstevel@tonic-gate 
311169Srie static const char	*rels[R_AMD64_NUM] = {
321169Srie 	"R_AMD64_NONE",			"R_AMD64_64",
331169Srie 	"R_AMD64_PC32",			"R_AMD64_GOT32",
341169Srie 	"R_AMD64_PLT32",		"R_AMD64_COPY",
351169Srie 	"R_AMD64_GLOB_DATA",		"R_AMD64_JUMP_SLOT",
361169Srie 	"R_AMD64_RELATIVE",		"R_AMD64_GOTPCREL",
371169Srie 	"R_AMD64_32",			"R_AMD64_32S",
381169Srie 	"R_AMD64_16",			"R_AMD64_PC16",
391169Srie 	"R_AMD64_8",			"R_AMD64_PC8",
401169Srie 	"R_AMD64_DPTMOD64",		"R_AMD64_DTPOFF64",
411169Srie 	"R_AMD64_TPOFF64",		"R_AMD64_TLSGD",
421169Srie 	"R_AMD64_TLSLD",		"R_AMD64_DTPOFF32",
431169Srie 	"R_AMD64_GOTTPOFF",		"R_AMD64_TPOFF32",
441169Srie 	"R_AMD64_PC64",			"R_AMD64_GOTOFF64",
451169Srie 	"R_AMD64_GOTPC32",		"R_AMD64_GOT64",
461169Srie 	"R_AMD64_GOTPCREL64",		"R_AMD64_GOTPC64",
471169Srie 	"R_AMD64_GOTPLT64",		"R_AMD64_PLTOFF64"
481169Srie };
490Sstevel@tonic-gate 
501169Srie #if	(R_AMD64_NUM != (R_AMD64_PLTOFF64 + 1))
511169Srie #error	"R_AMD64_NUM has grown"
520Sstevel@tonic-gate #endif
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /*
551169Srie  * This is a 'stub' of the orignal version defined in liblddbg.so.  This stub
561169Srie  * returns the 'int string' of the relocation in question instead of converting
571169Srie  * the relocation to it's full syntax.
580Sstevel@tonic-gate  */
590Sstevel@tonic-gate const char *
60*1618Srie conv_reloc_amd64_type(Word type)
610Sstevel@tonic-gate {
621169Srie 	static char 	strbuf[32];
631169Srie 	int		ndx = 31;
641169Srie 
651169Srie 	if (type < R_AMD64_NUM)
661169Srie 		return (rels[type]);
671169Srie 
681169Srie 	strbuf[ndx--] = '\0';
691169Srie 	do {
701169Srie 		strbuf[ndx--] = '0' + (type % 10);
711169Srie 		type = type / 10;
721169Srie 	} while ((ndx >= (int)0) && (type > (Word)0));
731169Srie 
741169Srie 	return (&strbuf[ndx + 1]);
750Sstevel@tonic-gate }
76