17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21552ff457Srie 
227c478bd9Sstevel@tonic-gate /*
23de777a60Sab  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * String conversion routine for relocation types.
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate #include	<stdio.h>
317c478bd9Sstevel@tonic-gate #include	<sys/elf_386.h>
327c478bd9Sstevel@tonic-gate #include	"_conv.h"
337c478bd9Sstevel@tonic-gate #include	"relocate_i386_msg.h"
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
36552ff457Srie  * 386 specific relocations.
377c478bd9Sstevel@tonic-gate  */
38552ff457Srie static const Msg rels[R_386_NUM] = {
39*a530dbfeSRichard Lowe 	[R_386_NONE]		= MSG_R_386_NONE,
40*a530dbfeSRichard Lowe 	[R_386_32]		= MSG_R_386_32,
41*a530dbfeSRichard Lowe 	[R_386_PC32]		= MSG_R_386_PC32,
42*a530dbfeSRichard Lowe 	[R_386_GOT32]		= MSG_R_386_GOT32,
43*a530dbfeSRichard Lowe 	[R_386_PLT32]		= MSG_R_386_PLT32,
44*a530dbfeSRichard Lowe 	[R_386_COPY]		= MSG_R_386_COPY,
45*a530dbfeSRichard Lowe 	[R_386_GLOB_DAT]	= MSG_R_386_GLOB_DAT,
46*a530dbfeSRichard Lowe 	[R_386_JMP_SLOT]	= MSG_R_386_JMP_SLOT,
47*a530dbfeSRichard Lowe 	[R_386_RELATIVE]	= MSG_R_386_RELATIVE,
48*a530dbfeSRichard Lowe 	[R_386_GOTOFF]		= MSG_R_386_GOTOFF,
49*a530dbfeSRichard Lowe 	[R_386_GOTPC]		= MSG_R_386_GOTPC,
50*a530dbfeSRichard Lowe 	[R_386_32PLT]		= MSG_R_386_32PLT,
51*a530dbfeSRichard Lowe 	[R_386_TLS_GD_PLT]	= MSG_R_386_TLS_GD_PLT,
52*a530dbfeSRichard Lowe 	[R_386_TLS_LDM_PLT]	= MSG_R_386_TLS_LDM_PLT,
53*a530dbfeSRichard Lowe 	[R_386_TLS_TPOFF]	= MSG_R_386_TLS_TPOFF,
54*a530dbfeSRichard Lowe 	[R_386_TLS_IE]		= MSG_R_386_TLS_IE,
55*a530dbfeSRichard Lowe 	[R_386_TLS_GOTIE]	= MSG_R_386_TLS_GOTIE,
56*a530dbfeSRichard Lowe 	[R_386_TLS_LE]		= MSG_R_386_TLS_LE,
57*a530dbfeSRichard Lowe 	[R_386_TLS_GD]		= MSG_R_386_TLS_GD,
58*a530dbfeSRichard Lowe 	[R_386_TLS_LDM]		= MSG_R_386_TLS_LDM,
59*a530dbfeSRichard Lowe 	[R_386_16]		= MSG_R_386_16,
60*a530dbfeSRichard Lowe 	[R_386_PC16]		= MSG_R_386_PC16,
61*a530dbfeSRichard Lowe 	[R_386_8]		= MSG_R_386_8,
62*a530dbfeSRichard Lowe 	[R_386_PC8]		= MSG_R_386_PC8,
63*a530dbfeSRichard Lowe 	[R_386_TLS_GD_32]	= MSG_R_386_TLS_GD_32,
64*a530dbfeSRichard Lowe 	[R_386_TLS_GD_PUSH]	= MSG_R_386_TLS_GD_PUSH,
65*a530dbfeSRichard Lowe 	[R_386_TLS_GD_CALL]	= MSG_R_386_TLS_GD_CALL,
66*a530dbfeSRichard Lowe 	[R_386_TLS_GD_POP]	= MSG_R_386_TLS_GD_POP,
67*a530dbfeSRichard Lowe 	[R_386_TLS_LDM_32]	= MSG_R_386_TLS_LDM_32,
68*a530dbfeSRichard Lowe 	[R_386_TLS_LDM_PUSH]	= MSG_R_386_TLS_LDM_PUSH,
69*a530dbfeSRichard Lowe 	[R_386_TLS_LDM_CALL]	= MSG_R_386_TLS_LDM_CALL,
70*a530dbfeSRichard Lowe 	[R_386_TLS_LDM_POP]	= MSG_R_386_TLS_LDM_POP,
71*a530dbfeSRichard Lowe 	[R_386_TLS_LDO_32]	= MSG_R_386_TLS_LDO_32,
72*a530dbfeSRichard Lowe 	[R_386_TLS_IE_32]	= MSG_R_386_TLS_IE_32,
73*a530dbfeSRichard Lowe 	[R_386_TLS_LE_32]	= MSG_R_386_TLS_LE_32,
74*a530dbfeSRichard Lowe 	[R_386_TLS_DTPMOD32]	= MSG_R_386_TLS_DTPMOD32,
75*a530dbfeSRichard Lowe 	[R_386_TLS_DTPOFF32]	= MSG_R_386_TLS_DTPOFF32,
76*a530dbfeSRichard Lowe 	[R_386_TLS_TPOFF32]	= MSG_R_386_TLS_TPOFF32,
77*a530dbfeSRichard Lowe 	[R_386_SIZE32]		= MSG_R_386_SIZE32,
78*a530dbfeSRichard Lowe 	[R_386_TLS_GOTDESC]	= MSG_R_386_TLS_GOTDESC,
79*a530dbfeSRichard Lowe 	[R_386_TLS_DESC_CALL]	= MSG_R_386_TLS_DESC_CALL,
80*a530dbfeSRichard Lowe 	[R_386_TLS_DESC]	= MSG_R_386_TLS_DESC,
81*a530dbfeSRichard Lowe 	[R_386_IRELATIVE]	= MSG_R_386_RELATIVE,
82*a530dbfeSRichard Lowe 	[R_386_GOT32X]		= MSG_R_386_GOT32X
837c478bd9Sstevel@tonic-gate };
847c478bd9Sstevel@tonic-gate 
85*a530dbfeSRichard Lowe #if	(R_386_NUM != (R_386_GOT32X + 1))
86552ff457Srie #error	"R_386_NUM has grown"
87552ff457Srie #endif
88552ff457Srie 
897c478bd9Sstevel@tonic-gate const char *
conv_reloc_386_type(Word type,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)90d29b2c44Sab conv_reloc_386_type(Word type, Conv_fmt_flags_t fmt_flags,
91d29b2c44Sab     Conv_inv_buf_t *inv_buf)
92*a530dbfeSRichard Lowe {
93*a530dbfeSRichard Lowe 	if (type >= R_386_NUM)
94de777a60Sab 		return (conv_invalid_val(inv_buf, type, fmt_flags));
95552ff457Srie 	return (MSG_ORIG(rels[type]));
967c478bd9Sstevel@tonic-gate }
97