xref: /illumos-gate/usr/src/cmd/sgs/libconv/common/relocate_i386.c (revision dd72704bd9e794056c558153663c739e2012d721)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * String conversion routine for relocation types.
29  */
30 #include	<stdio.h>
31 #include	<sys/elf_386.h>
32 #include	"_conv.h"
33 #include	"relocate_i386_msg.h"
34 
35 /*
36  * 386 specific relocations.
37  */
38 static const Msg rels[R_386_NUM] = {
39 	[R_386_NONE]		= MSG_R_386_NONE,
40 	[R_386_32]		= MSG_R_386_32,
41 	[R_386_PC32]		= MSG_R_386_PC32,
42 	[R_386_GOT32]		= MSG_R_386_GOT32,
43 	[R_386_PLT32]		= MSG_R_386_PLT32,
44 	[R_386_COPY]		= MSG_R_386_COPY,
45 	[R_386_GLOB_DAT]	= MSG_R_386_GLOB_DAT,
46 	[R_386_JMP_SLOT]	= MSG_R_386_JMP_SLOT,
47 	[R_386_RELATIVE]	= MSG_R_386_RELATIVE,
48 	[R_386_GOTOFF]		= MSG_R_386_GOTOFF,
49 	[R_386_GOTPC]		= MSG_R_386_GOTPC,
50 	[R_386_32PLT]		= MSG_R_386_32PLT,
51 	[R_386_TLS_GD_PLT]	= MSG_R_386_TLS_GD_PLT,
52 	[R_386_TLS_LDM_PLT]	= MSG_R_386_TLS_LDM_PLT,
53 	[R_386_TLS_TPOFF]	= MSG_R_386_TLS_TPOFF,
54 	[R_386_TLS_IE]		= MSG_R_386_TLS_IE,
55 	[R_386_TLS_GOTIE]	= MSG_R_386_TLS_GOTIE,
56 	[R_386_TLS_LE]		= MSG_R_386_TLS_LE,
57 	[R_386_TLS_GD]		= MSG_R_386_TLS_GD,
58 	[R_386_TLS_LDM]		= MSG_R_386_TLS_LDM,
59 	[R_386_16]		= MSG_R_386_16,
60 	[R_386_PC16]		= MSG_R_386_PC16,
61 	[R_386_8]		= MSG_R_386_8,
62 	[R_386_PC8]		= MSG_R_386_PC8,
63 	[R_386_TLS_GD_32]	= MSG_R_386_TLS_GD_32,
64 	[R_386_TLS_GD_PUSH]	= MSG_R_386_TLS_GD_PUSH,
65 	[R_386_TLS_GD_CALL]	= MSG_R_386_TLS_GD_CALL,
66 	[R_386_TLS_GD_POP]	= MSG_R_386_TLS_GD_POP,
67 	[R_386_TLS_LDM_32]	= MSG_R_386_TLS_LDM_32,
68 	[R_386_TLS_LDM_PUSH]	= MSG_R_386_TLS_LDM_PUSH,
69 	[R_386_TLS_LDM_CALL]	= MSG_R_386_TLS_LDM_CALL,
70 	[R_386_TLS_LDM_POP]	= MSG_R_386_TLS_LDM_POP,
71 	[R_386_TLS_LDO_32]	= MSG_R_386_TLS_LDO_32,
72 	[R_386_TLS_IE_32]	= MSG_R_386_TLS_IE_32,
73 	[R_386_TLS_LE_32]	= MSG_R_386_TLS_LE_32,
74 	[R_386_TLS_DTPMOD32]	= MSG_R_386_TLS_DTPMOD32,
75 	[R_386_TLS_DTPOFF32]	= MSG_R_386_TLS_DTPOFF32,
76 	[R_386_TLS_TPOFF32]	= MSG_R_386_TLS_TPOFF32,
77 	[R_386_SIZE32]		= MSG_R_386_SIZE32,
78 	[R_386_TLS_GOTDESC]	= MSG_R_386_TLS_GOTDESC,
79 	[R_386_TLS_DESC_CALL]	= MSG_R_386_TLS_DESC_CALL,
80 	[R_386_TLS_DESC]	= MSG_R_386_TLS_DESC,
81 	[R_386_IRELATIVE]	= MSG_R_386_RELATIVE,
82 	[R_386_GOT32X]		= MSG_R_386_GOT32X
83 };
84 
85 #if	(R_386_NUM != (R_386_GOT32X + 1))
86 #error	"R_386_NUM has grown"
87 #endif
88 
89 const char *
90 conv_reloc_386_type(Word type, Conv_fmt_flags_t fmt_flags,
91     Conv_inv_buf_t *inv_buf)
92 {
93 	if (type >= R_386_NUM)
94 		return (conv_invalid_val(inv_buf, type, fmt_flags));
95 	return (MSG_ORIG(rels[type]));
96 }
97