xref: /onnv-gate/usr/src/cmd/sgs/libconv/common/relocate_amd64.c (revision 5088:26c540f30cd3)
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 /*
234734Sab196087  * Copyright 2007 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>
331976Sab196087 #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,
552850Srie 	MSG_R_AMD64_GOTPLT64,		MSG_R_AMD64_PLTOFF64,
562850Srie 	MSG_R_AMD64_SIZE32,		MSG_R_AMD64_SIZE64
570Sstevel@tonic-gate };
580Sstevel@tonic-gate 
592850Srie #if	(R_AMD64_NUM != (R_AMD64_SIZE64 + 1))
601169Srie #error	"R_AMD64_NUM has grown"
611169Srie #endif
621169Srie 
630Sstevel@tonic-gate const char *
conv_reloc_amd64_type(Word type,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)64*5088Sab196087 conv_reloc_amd64_type(Word type, Conv_fmt_flags_t fmt_flags,
65*5088Sab196087     Conv_inv_buf_t *inv_buf)
660Sstevel@tonic-gate {
671169Srie 	if (type >= R_AMD64_NUM)
684734Sab196087 		return (conv_invalid_val(inv_buf, type, fmt_flags));
691169Srie 	return (MSG_ORIG(rels[type]));
700Sstevel@tonic-gate }
71