xref: /titanic_52/usr/src/cmd/sgs/libconv/common/relocate_amd64.c (revision fb3fb4f3d76d55b64440afd0af72775dfad3bd1d)
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 /*
30  * String conversion routine for relocation types.
31  */
32 #include	<stdio.h>
33 #include	<sys/elf_amd64.h>
34 #include	"_conv.h"
35 #include	"relocate_amd64_msg.h"
36 
37 /*
38  * AMD64 specific relocations.
39  */
40 static const Msg rels[R_AMD64_NUM] = {
41 	MSG_R_AMD64_NONE,		MSG_R_AMD64_64,
42 	MSG_R_AMD64_PC32,		MSG_R_AMD64_GOT32,
43 	MSG_R_AMD64_PLT32,		MSG_R_AMD64_COPY,
44 	MSG_R_AMD64_GLOB_DATA,		MSG_R_AMD64_JUMP_SLOT,
45 	MSG_R_AMD64_RELATIVE,		MSG_R_AMD64_GOTPCREL,
46 	MSG_R_AMD64_32,			MSG_R_AMD64_32S,
47 	MSG_R_AMD64_16,			MSG_R_AMD64_PC16,
48 	MSG_R_AMD64_8,			MSG_R_AMD64_PC8,
49 	MSG_R_AMD64_DTPMOD64,		MSG_R_AMD64_DTPOFF64,
50 	MSG_R_AMD64_TPOFF64,		MSG_R_AMD64_TLSGD,
51 	MSG_R_AMD64_TLSLD,		MSG_R_AMD64_DTPOFF32,
52 	MSG_R_AMD64_GOTTPOFF,		MSG_R_AMD64_TPOFF32,
53 	MSG_R_AMD64_PC64,		MSG_R_AMD64_GOTOFF64,
54 	MSG_R_AMD64_GOTPC32,		MSG_R_AMD64_GOT64,
55 	MSG_R_AMD64_GOTPCREL64,		MSG_R_AMD64_GOTPC64,
56 	MSG_R_AMD64_GOTPLT64,		MSG_R_AMD64_PLTOFF64
57 };
58 
59 #if	(R_AMD64_NUM != (R_AMD64_PLTOFF64 + 1))
60 #error	"R_AMD64_NUM has grown"
61 #endif
62 
63 const char *
64 conv_reloc_amd64_type_str(uint_t type)
65 {
66 	static char	string[STRSIZE] = { '\0' };
67 
68 	if (type >= R_AMD64_NUM)
69 		return (conv_invalid_str(string, STRSIZE, type, 0));
70 	return (MSG_ORIG(rels[type]));
71 }
72