xref: /titanic_53/usr/src/uts/common/krtld/reloc.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_RELOC_DOT_H
28*7c478bd9Sstevel@tonic-gate #define	_RELOC_DOT_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
33*7c478bd9Sstevel@tonic-gate #include <sys/machelf.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/bootconf.h>
35*7c478bd9Sstevel@tonic-gate #include <sys/kobj.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/kobj_impl.h>
37*7c478bd9Sstevel@tonic-gate #else
38*7c478bd9Sstevel@tonic-gate #include <machdep.h>
39*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #include <relmach.h>
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
44*7c478bd9Sstevel@tonic-gate extern "C" {
45*7c478bd9Sstevel@tonic-gate #endif
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate  * Global include file for relocation common code.
49*7c478bd9Sstevel@tonic-gate  *
50*7c478bd9Sstevel@tonic-gate  * Flags for reloc_entry->re_flags
51*7c478bd9Sstevel@tonic-gate  */
52*7c478bd9Sstevel@tonic-gate #define	FLG_RE_NOTREL		0x00000000
53*7c478bd9Sstevel@tonic-gate #define	FLG_RE_GOTADD		0x00000001	/* create a GOT entry */
54*7c478bd9Sstevel@tonic-gate #define	FLG_RE_GOTREL		0x00000002	/* GOT based */
55*7c478bd9Sstevel@tonic-gate #define	FLG_RE_GOTPC		0x00000004	/* GOT - P */
56*7c478bd9Sstevel@tonic-gate #define	FLG_RE_GOTOPINS		0x00000008	/* GOTOP instruction */
57*7c478bd9Sstevel@tonic-gate #define	FLG_RE_PCREL		0x00000010
58*7c478bd9Sstevel@tonic-gate #define	FLG_RE_PLTREL		0x00000020
59*7c478bd9Sstevel@tonic-gate #define	FLG_RE_VERIFY		0x00000040	/* verify value fits */
60*7c478bd9Sstevel@tonic-gate #define	FLG_RE_UNALIGN		0x00000080	/* offset is not aligned */
61*7c478bd9Sstevel@tonic-gate #define	FLG_RE_WDISP16		0x00000100	/* funky sparc DISP16 rel */
62*7c478bd9Sstevel@tonic-gate #define	FLG_RE_SIGN		0x00000200	/* value is signed */
63*7c478bd9Sstevel@tonic-gate #define	FLG_RE_ADDRELATIVE	0x00000400	/* RELATIVE relocation */
64*7c478bd9Sstevel@tonic-gate 						/* required for non-fixed */
65*7c478bd9Sstevel@tonic-gate 						/* objects */
66*7c478bd9Sstevel@tonic-gate #define	FLG_RE_EXTOFFSET	0x00000800	/* extra offset required */
67*7c478bd9Sstevel@tonic-gate #define	FLG_RE_REGISTER		0x00001000	/* relocation initializes */
68*7c478bd9Sstevel@tonic-gate 						/*    a REGISTER by OLO10 */
69*7c478bd9Sstevel@tonic-gate #define	FLG_RE_MSB		0x00002000	/* merced MSB data field */
70*7c478bd9Sstevel@tonic-gate #define	FLG_RE_LSB		0x00004000	/* merced LSB data field */
71*7c478bd9Sstevel@tonic-gate #define	FLG_RE_ADDFIELD		0x00008000	/* add contents of field at */
72*7c478bd9Sstevel@tonic-gate 						/*    r_offset to value */
73*7c478bd9Sstevel@tonic-gate #define	FLG_RE_NOTSUP		0x00010000	/* relocation not supported */
74*7c478bd9Sstevel@tonic-gate #define	FLG_RE_FRMOFF		0x00020000	/* offset contains islot */
75*7c478bd9Sstevel@tonic-gate 						/*    value (IA64) */
76*7c478bd9Sstevel@tonic-gate #define	FLG_RE_SEGREL		0x00040000	/* Segment relative */
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate #define	FLG_RE_SECREL		0x00080000	/* Section relative */
79*7c478bd9Sstevel@tonic-gate #define	FLG_RE_TLSINS		0x00100000	/* TLS instructino rel */
80*7c478bd9Sstevel@tonic-gate #define	FLG_RE_TLSGD		0x00200000	/* TLS GD relocation */
81*7c478bd9Sstevel@tonic-gate #define	FLG_RE_TLSLD		0x00400000	/* TLS LD relocation */
82*7c478bd9Sstevel@tonic-gate #define	FLG_RE_TLSIE		0x00800000	/* TLS IE relocation */
83*7c478bd9Sstevel@tonic-gate #define	FLG_RE_TLSLE		0x01000000	/* TLS LE relocation */
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate #define	FLG_RE_LOCLBND		0x02000000	/* relocation must bind */
86*7c478bd9Sstevel@tonic-gate 						/*  locally */
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate /*
89*7c478bd9Sstevel@tonic-gate  * Macros for testing relocation table flags
90*7c478bd9Sstevel@tonic-gate  */
91*7c478bd9Sstevel@tonic-gate extern	const Rel_entry		reloc_table[];
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate #define	IS_PLT(X)		((reloc_table[(X)].re_flags & \
94*7c478bd9Sstevel@tonic-gate 					FLG_RE_PLTREL) != 0)
95*7c478bd9Sstevel@tonic-gate #define	IS_GOT_RELATIVE(X)	((reloc_table[(X)].re_flags & \
96*7c478bd9Sstevel@tonic-gate 					FLG_RE_GOTADD) != 0)
97*7c478bd9Sstevel@tonic-gate #define	IS_GOT_PC(X)		((reloc_table[(X)].re_flags & \
98*7c478bd9Sstevel@tonic-gate 					FLG_RE_GOTPC) != 0)
99*7c478bd9Sstevel@tonic-gate #define	IS_GOTPCREL(X)		((reloc_table[(X)].re_flags & \
100*7c478bd9Sstevel@tonic-gate 					(FLG_RE_GOTPC | FLG_RE_GOTADD)) == \
101*7c478bd9Sstevel@tonic-gate 					(FLG_RE_GOTPC | FLG_RE_GOTADD))
102*7c478bd9Sstevel@tonic-gate #define	IS_GOT_BASED(X)		((reloc_table[(X)].re_flags & \
103*7c478bd9Sstevel@tonic-gate 					FLG_RE_GOTREL) != 0)
104*7c478bd9Sstevel@tonic-gate #define	IS_GOT_INS(X)		((reloc_table[(X)].re_flags &\
105*7c478bd9Sstevel@tonic-gate 					FLG_RE_GOTOPINS) != 0)
106*7c478bd9Sstevel@tonic-gate #define	IS_PC_RELATIVE(X)	((reloc_table[(X)].re_flags & \
107*7c478bd9Sstevel@tonic-gate 					FLG_RE_PCREL) != 0)
108*7c478bd9Sstevel@tonic-gate #define	IS_ADD_RELATIVE(X)	((reloc_table[(X)].re_flags & \
109*7c478bd9Sstevel@tonic-gate 					FLG_RE_ADDRELATIVE) != 0)
110*7c478bd9Sstevel@tonic-gate #define	IS_REGISTER(X)		((reloc_table[(X)].re_flags & \
111*7c478bd9Sstevel@tonic-gate 					FLG_RE_REGISTER) != 0)
112*7c478bd9Sstevel@tonic-gate #define	IS_FORMOFF(X)		((reloc_table[(X)].re_flags &\
113*7c478bd9Sstevel@tonic-gate 					FLG_RE_FRMOFF) != 0)
114*7c478bd9Sstevel@tonic-gate #define	IS_NOTSUP(X)		((reloc_table[(X)].re_flags &\
115*7c478bd9Sstevel@tonic-gate 					FLG_RE_NOTSUP) != 0)
116*7c478bd9Sstevel@tonic-gate #define	IS_SEG_RELATIVE(X)	((reloc_table[(X)].re_flags &\
117*7c478bd9Sstevel@tonic-gate 					FLG_RE_SEGREL) != 0)
118*7c478bd9Sstevel@tonic-gate #define	IS_EXTOFFSET(X)		((reloc_table[(X)].re_flags &\
119*7c478bd9Sstevel@tonic-gate 					FLG_RE_EXTOFFSET) != 0)
120*7c478bd9Sstevel@tonic-gate #define	IS_SEC_RELATIVE(X)	((reloc_table[(X)].re_flags &\
121*7c478bd9Sstevel@tonic-gate 					FLG_RE_SECREL) != 0)
122*7c478bd9Sstevel@tonic-gate #define	IS_TLS_INS(X)		((reloc_table[(X)].re_flags &\
123*7c478bd9Sstevel@tonic-gate 					FLG_RE_TLSINS) != 0)
124*7c478bd9Sstevel@tonic-gate #define	IS_TLS_GD(X)		((reloc_table[(X)].re_flags &\
125*7c478bd9Sstevel@tonic-gate 					FLG_RE_TLSGD) != 0)
126*7c478bd9Sstevel@tonic-gate #define	IS_TLS_LD(X)		((reloc_table[(X)].re_flags &\
127*7c478bd9Sstevel@tonic-gate 					FLG_RE_TLSLD) != 0)
128*7c478bd9Sstevel@tonic-gate #define	IS_TLS_IE(X)		((reloc_table[(X)].re_flags &\
129*7c478bd9Sstevel@tonic-gate 					FLG_RE_TLSIE) != 0)
130*7c478bd9Sstevel@tonic-gate #define	IS_TLS_LE(X)		((reloc_table[(X)].re_flags &\
131*7c478bd9Sstevel@tonic-gate 					FLG_RE_TLSLE) != 0)
132*7c478bd9Sstevel@tonic-gate #define	IS_TLS(X)		((reloc_table[(X)].re_flags &\
133*7c478bd9Sstevel@tonic-gate 					(FLG_RE_TLSINS|FLG_RE_TLSGD| \
134*7c478bd9Sstevel@tonic-gate 					FLG_RE_TLSLD|FLG_RE_TLSIE| \
135*7c478bd9Sstevel@tonic-gate 					FLG_RE_TLSLE)) != 0)
136*7c478bd9Sstevel@tonic-gate #define	IS_LOCALBND(X)		((reloc_table[(X)].re_flags &\
137*7c478bd9Sstevel@tonic-gate 					FLG_RE_LOCLBND) != 0)
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate /*
140*7c478bd9Sstevel@tonic-gate  * Functions.
141*7c478bd9Sstevel@tonic-gate  */
142*7c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__ia64) || defined(__amd64)
143*7c478bd9Sstevel@tonic-gate extern	int	do_reloc(unsigned char, unsigned char *, Xword *,
144*7c478bd9Sstevel@tonic-gate 			const char *, const char *);
145*7c478bd9Sstevel@tonic-gate #elif defined(__sparc)
146*7c478bd9Sstevel@tonic-gate extern	int	do_reloc(unsigned char, unsigned char *, Xword *,
147*7c478bd9Sstevel@tonic-gate 			const char *, const char *);
148*7c478bd9Sstevel@tonic-gate #endif
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate /*
152*7c478bd9Sstevel@tonic-gate  * NOTE - this CONVRELOC macro is only used
153*7c478bd9Sstevel@tonic-gate  * in the REL_ERR_NOFIT() macro below.  For Intel
154*7c478bd9Sstevel@tonic-gate  * this macro is only referenced from the amd64 side - it's
155*7c478bd9Sstevel@tonic-gate  * not relevant for i386.  So - we just define AMD64 for i386
156*7c478bd9Sstevel@tonic-gate  * and sparc is sparc.
157*7c478bd9Sstevel@tonic-gate  */
158*7c478bd9Sstevel@tonic-gate #if defined(__amd64) || defined(__i386)
159*7c478bd9Sstevel@tonic-gate #define	CONVRELOC conv_reloc_amd64_type_str
160*7c478bd9Sstevel@tonic-gate #elif defined(__sparc)
161*7c478bd9Sstevel@tonic-gate #define	CONVRELOC   conv_reloc_SPARC_type_str
162*7c478bd9Sstevel@tonic-gate #else
163*7c478bd9Sstevel@tonic-gate #error platform not defined!
164*7c478bd9Sstevel@tonic-gate #endif
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
167*7c478bd9Sstevel@tonic-gate /*
168*7c478bd9Sstevel@tonic-gate  * These are macro's that are only needed for krtld.  Many of these
169*7c478bd9Sstevel@tonic-gate  * are already defined in the sgs/include files referenced by
170*7c478bd9Sstevel@tonic-gate  * ld and rtld
171*7c478bd9Sstevel@tonic-gate  */
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate #define	S_MASK(n)	((1l << (n)) - 1l)
174*7c478bd9Sstevel@tonic-gate #define	S_INRANGE(v, n)	(((-(1l << (n)) - 1l) < (v)) && ((v) < (1l << (n))))
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate /*
177*7c478bd9Sstevel@tonic-gate  * This converts the sgs eprintf() routine into the _printf()
178*7c478bd9Sstevel@tonic-gate  * as used by krtld.
179*7c478bd9Sstevel@tonic-gate  */
180*7c478bd9Sstevel@tonic-gate #define	eprintf		_kobj_printf
181*7c478bd9Sstevel@tonic-gate #define	ERR_FATAL	ops
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate /*
184*7c478bd9Sstevel@tonic-gate  * Message strings used by doreloc()
185*7c478bd9Sstevel@tonic-gate  */
186*7c478bd9Sstevel@tonic-gate #define	MSG_ORIG(x)		x
187*7c478bd9Sstevel@tonic-gate #define	MSG_INTL(x)		x
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate #define	MSG_STR_UNKNOWN		"(unknown)"
190*7c478bd9Sstevel@tonic-gate #define	MSG_REL_UNSUPSZ		"relocation error: %s: file %s: symbol %s: " \
191*7c478bd9Sstevel@tonic-gate 				"offset size (%d bytes) is not supported"
192*7c478bd9Sstevel@tonic-gate #define	MSG_REL_ERR_STR		"relocation error: %s:"
193*7c478bd9Sstevel@tonic-gate #define	MSG_REL_ERR_WITH_FILE	"relocation error: file %s: "
194*7c478bd9Sstevel@tonic-gate #define	MSG_REL_ERR_FILE	" file %s: "
195*7c478bd9Sstevel@tonic-gate #define	MSG_REL_ERR_SYM		" symbol %s: "
196*7c478bd9Sstevel@tonic-gate #define	MSG_REL_ERR_VALUE	" value 0x%llx"
197*7c478bd9Sstevel@tonic-gate #define	MSG_REL_ERR_OFF		" offset 0x%llx\n"
198*7c478bd9Sstevel@tonic-gate #define	MSG_REL_UNIMPL		" unimplemented relocation type: %d"
199*7c478bd9Sstevel@tonic-gate #define	MSG_REL_NONALIGN	" offset 0x%llx is non-aligned\n"
200*7c478bd9Sstevel@tonic-gate #define	MSG_REL_UNNOBITS	" unsupported number of bits: %d"
201*7c478bd9Sstevel@tonic-gate #define	MSG_REL_NOFIT		" value 0x%llx does not fit\n"
202*7c478bd9Sstevel@tonic-gate #define	MSG_REL_LOSEBITS	" loses %d bits at"
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate extern const char *conv_reloc_SPARC_type_str(Word rtype);
205*7c478bd9Sstevel@tonic-gate extern const char *conv_reloc_386_type_str(Word rtype);
206*7c478bd9Sstevel@tonic-gate extern const char *conv_reloc_amd64_type_str(Word rtype);
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate /*
209*7c478bd9Sstevel@tonic-gate  * Note:  Related to bug 4128755, dlerror() only keeps track
210*7c478bd9Sstevel@tonic-gate  * of a single error string, and therefore must have errors
211*7c478bd9Sstevel@tonic-gate  * reported through a single eprintf() call.  The kernel's
212*7c478bd9Sstevel@tonic-gate  * printf is somewhat more limited, and must receive messages
213*7c478bd9Sstevel@tonic-gate  * with only one arguement to the format string.  The following
214*7c478bd9Sstevel@tonic-gate  * macros are to straighted all this out because krtld and
215*7c478bd9Sstevel@tonic-gate  * rtld share do_reloc().
216*7c478bd9Sstevel@tonic-gate  */
217*7c478bd9Sstevel@tonic-gate #define	REL_ERR_UNIMPL(file, sym, rtype) \
218*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_WITH_FILE, (file)); \
219*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_SYM, \
220*7c478bd9Sstevel@tonic-gate 	    ((sym) ? (sym) : MSG_STR_UNKNOWN)); \
221*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL,  MSG_REL_UNIMPL, \
222*7c478bd9Sstevel@tonic-gate 	    (int)(rtype))
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate #define	REL_ERR_NONALIGN(file, sym, rtype, off) \
225*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_STR, \
226*7c478bd9Sstevel@tonic-gate 	    conv_reloc_SPARC_type_str((rtype))); \
227*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_FILE, (file)); \
228*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_SYM, \
229*7c478bd9Sstevel@tonic-gate 	    ((sym) ? (sym) : MSG_STR_UNKNOWN)); \
230*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_NONALIGN, \
231*7c478bd9Sstevel@tonic-gate 	    EC_OFF((off)))
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate #define	REL_ERR_UNNOBITS(file, sym, rtype, nbits) \
234*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_STR, \
235*7c478bd9Sstevel@tonic-gate 	    conv_reloc_SPARC_type_str((rtype))); \
236*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_FILE, (file)); \
237*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_SYM, \
238*7c478bd9Sstevel@tonic-gate 	    ((sym) ? (sym) : MSG_STR_UNKNOWN)); \
239*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_UNNOBITS, (nbits))
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate #define	REL_ERR_LOSEBITS(file, sym, rtype, uvalue, nbits, off) \
242*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL,  MSG_REL_ERR_STR, \
243*7c478bd9Sstevel@tonic-gate 	    conv_reloc_SPARC_type_str((rtype))); \
244*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL,  MSG_REL_ERR_FILE, (file)); \
245*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL,  MSG_REL_ERR_SYM, \
246*7c478bd9Sstevel@tonic-gate 	    ((sym) ? (sym) : MSG_STR_UNKNOWN)); \
247*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL,  MSG_REL_ERR_VALUE, EC_XWORD((uvalue))); \
248*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL,  MSG_REL_LOSEBITS, (nbits)); \
249*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL,  MSG_REL_ERR_OFF, EC_ADDR((off)))
250*7c478bd9Sstevel@tonic-gate 
251*7c478bd9Sstevel@tonic-gate #define	REL_ERR_NOFIT(file, sym, rtype, uvalue) \
252*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_STR, \
253*7c478bd9Sstevel@tonic-gate 	    CONVRELOC((rtype))); \
254*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_FILE, (file)); \
255*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_ERR_SYM, \
256*7c478bd9Sstevel@tonic-gate 	    ((sym) ? (sym) : MSG_STR_UNKNOWN)); \
257*7c478bd9Sstevel@tonic-gate 	eprintf(ERR_FATAL, MSG_REL_NOFIT, EC_XWORD((uvalue)))
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate #else	/* !_KERNEL */
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate extern	const char *demangle(const char *);
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate #define	REL_ERR_UNIMPL(file, sym, rtype) \
265*7c478bd9Sstevel@tonic-gate 	(eprintf(ERR_FATAL, MSG_INTL(MSG_REL_UNIMPL), \
266*7c478bd9Sstevel@tonic-gate 	    (file), ((sym) ? demangle(sym) : MSG_INTL(MSG_STR_UNKNOWN)), \
267*7c478bd9Sstevel@tonic-gate 	    (int)(rtype)))
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate #define	REL_ERR_NONALIGN(file, sym, rtype, off) \
270*7c478bd9Sstevel@tonic-gate 	(eprintf(ERR_FATAL, MSG_INTL(MSG_REL_NONALIGN), \
271*7c478bd9Sstevel@tonic-gate 	    conv_reloc_SPARC_type_str(rtype), (file), \
272*7c478bd9Sstevel@tonic-gate 	    ((sym) ? demangle(sym) : MSG_INTL(MSG_STR_UNKNOWN)), \
273*7c478bd9Sstevel@tonic-gate 	    EC_OFF((off))))
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate #define	REL_ERR_UNNOBITS(file, sym, rtype, nbits) \
276*7c478bd9Sstevel@tonic-gate 	(eprintf(ERR_FATAL, MSG_INTL(MSG_REL_UNNOBITS), \
277*7c478bd9Sstevel@tonic-gate 	    conv_reloc_SPARC_type_str(rtype), (file), \
278*7c478bd9Sstevel@tonic-gate 	    ((sym) ? demangle(sym) : MSG_INTL(MSG_STR_UNKNOWN)), (nbits)))
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate #define	REL_ERR_LOSEBITS(file, sym, rtype, uvalue, nbits, off) \
281*7c478bd9Sstevel@tonic-gate 	(eprintf(ERR_FATAL,  MSG_INTL(MSG_REL_LOSEBITS), \
282*7c478bd9Sstevel@tonic-gate 	    conv_reloc_SPARC_type_str((rtype)), (file), \
283*7c478bd9Sstevel@tonic-gate 	    ((sym) ? demangle(sym) : MSG_INTL(MSG_STR_UNKNOWN)), \
284*7c478bd9Sstevel@tonic-gate 	    EC_XWORD((uvalue)), (nbits), EC_ADDR((off))))
285*7c478bd9Sstevel@tonic-gate 
286*7c478bd9Sstevel@tonic-gate #define	REL_ERR_NOFIT(file, sym, rtype, uvalue) \
287*7c478bd9Sstevel@tonic-gate 	(eprintf(ERR_FATAL, MSG_INTL(MSG_REL_NOFIT), \
288*7c478bd9Sstevel@tonic-gate 	    CONVRELOC((rtype)), (file), \
289*7c478bd9Sstevel@tonic-gate 	    ((sym) ? demangle(sym) : MSG_INTL(MSG_STR_UNKNOWN)), \
290*7c478bd9Sstevel@tonic-gate 	    EC_XWORD((uvalue))))
291*7c478bd9Sstevel@tonic-gate 
292*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
293*7c478bd9Sstevel@tonic-gate 
294*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
295*7c478bd9Sstevel@tonic-gate }
296*7c478bd9Sstevel@tonic-gate #endif
297*7c478bd9Sstevel@tonic-gate 
298*7c478bd9Sstevel@tonic-gate #endif /* _RELOC_DOT_H */
299