xref: /onnv-gate/usr/src/cmd/sgs/libconv/common/relocate_amd64.c (revision 1976:f0691a145b7e)
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
51618Srie  * Common Development and Distribution License (the "License").
61618Srie  * 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 /*
231618Srie  * 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 /*
290Sstevel@tonic-gate  * String conversion routine for relocation types.
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate #include	<stdio.h>
320Sstevel@tonic-gate #include	<sys/elf_amd64.h>
33*1976Sab196087 #include	"relocate_amd64_msg.h"
340Sstevel@tonic-gate #include	"_conv.h"
350Sstevel@tonic-gate 
360Sstevel@tonic-gate /*
371169Srie  * AMD64 specific relocations.
380Sstevel@tonic-gate  */
391169Srie static const Msg rels[R_AMD64_NUM] = {
401169Srie 	MSG_R_AMD64_NONE,		MSG_R_AMD64_64,
411169Srie 	MSG_R_AMD64_PC32,		MSG_R_AMD64_GOT32,
421169Srie 	MSG_R_AMD64_PLT32,		MSG_R_AMD64_COPY,
431169Srie 	MSG_R_AMD64_GLOB_DATA,		MSG_R_AMD64_JUMP_SLOT,
441169Srie 	MSG_R_AMD64_RELATIVE,		MSG_R_AMD64_GOTPCREL,
451169Srie 	MSG_R_AMD64_32,			MSG_R_AMD64_32S,
461169Srie 	MSG_R_AMD64_16,			MSG_R_AMD64_PC16,
471169Srie 	MSG_R_AMD64_8,			MSG_R_AMD64_PC8,
481169Srie 	MSG_R_AMD64_DTPMOD64,		MSG_R_AMD64_DTPOFF64,
491169Srie 	MSG_R_AMD64_TPOFF64,		MSG_R_AMD64_TLSGD,
501169Srie 	MSG_R_AMD64_TLSLD,		MSG_R_AMD64_DTPOFF32,
511169Srie 	MSG_R_AMD64_GOTTPOFF,		MSG_R_AMD64_TPOFF32,
521169Srie 	MSG_R_AMD64_PC64,		MSG_R_AMD64_GOTOFF64,
531169Srie 	MSG_R_AMD64_GOTPC32,		MSG_R_AMD64_GOT64,
541169Srie 	MSG_R_AMD64_GOTPCREL64,		MSG_R_AMD64_GOTPC64,
551169Srie 	MSG_R_AMD64_GOTPLT64,		MSG_R_AMD64_PLTOFF64
560Sstevel@tonic-gate };
570Sstevel@tonic-gate 
581169Srie #if	(R_AMD64_NUM != (R_AMD64_PLTOFF64 + 1))
591169Srie #error	"R_AMD64_NUM has grown"
601169Srie #endif
611169Srie 
620Sstevel@tonic-gate const char *
63*1976Sab196087 conv_reloc_amd64_type(Word type, int fmt_flags)
640Sstevel@tonic-gate {
651618Srie 	static char	string[CONV_INV_STRSIZE];
660Sstevel@tonic-gate 
671169Srie 	if (type >= R_AMD64_NUM)
68*1976Sab196087 		return (conv_invalid_val(string, CONV_INV_STRSIZE,
69*1976Sab196087 			type, fmt_flags));
701169Srie 	return (MSG_ORIG(rels[type]));
710Sstevel@tonic-gate }
72