1*ba2be530Sab /*
2*ba2be530Sab  * CDDL HEADER START
3*ba2be530Sab  *
4*ba2be530Sab  * The contents of this file are subject to the terms of the
5*ba2be530Sab  * Common Development and Distribution License (the "License").
6*ba2be530Sab  * You may not use this file except in compliance with the License.
7*ba2be530Sab  *
8*ba2be530Sab  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*ba2be530Sab  * or http://www.opensolaris.org/os/licensing.
10*ba2be530Sab  * See the License for the specific language governing permissions
11*ba2be530Sab  * and limitations under the License.
12*ba2be530Sab  *
13*ba2be530Sab  * When distributing Covered Code, include this CDDL HEADER in each
14*ba2be530Sab  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*ba2be530Sab  * If applicable, add the following below this CDDL HEADER, with the
16*ba2be530Sab  * fields enclosed by brackets "[]" replaced with your own identifying
17*ba2be530Sab  * information: Portions Copyright [yyyy] [name of copyright owner]
18*ba2be530Sab  *
19*ba2be530Sab  * CDDL HEADER END
20*ba2be530Sab  */
21*ba2be530Sab 
22*ba2be530Sab /*
23*ba2be530Sab  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*ba2be530Sab  * Use is subject to license terms.
25*ba2be530Sab  */
26*ba2be530Sab 
27*ba2be530Sab #ifndef	_RELOC_DEFS_DOT_H
28*ba2be530Sab #define	_RELOC_DEFS_DOT_H
29*ba2be530Sab 
30*ba2be530Sab #include <sys/machelf.h>
31*ba2be530Sab 
32*ba2be530Sab #ifdef	__cplusplus
33*ba2be530Sab extern "C" {
34*ba2be530Sab #endif
35*ba2be530Sab 
36*ba2be530Sab /*
37*ba2be530Sab  * Definitions used by the relocation common code.
38*ba2be530Sab  */
39*ba2be530Sab 
40*ba2be530Sab 
41*ba2be530Sab /*
42*ba2be530Sab  * Structure used to build the reloc_table[]
43*ba2be530Sab  */
44*ba2be530Sab typedef struct {
45*ba2be530Sab 	Xword	re_mask;	/* mask to apply to reloc (sparc only) */
46*ba2be530Sab 	Word	re_flags;	/* relocation attributes */
47*ba2be530Sab 	uchar_t	re_fsize;	/* field size (in bytes) */
48*ba2be530Sab 	uchar_t	re_bshift;	/* number of bits to shift (sparc only) */
49*ba2be530Sab 	uchar_t	re_sigbits;	/* number of significant bits */
50*ba2be530Sab } Rel_entry;
51*ba2be530Sab 
52*ba2be530Sab /*
53*ba2be530Sab  * Flags for reloc_entry->re_flags
54*ba2be530Sab  */
55*ba2be530Sab #define	FLG_RE_NOTREL		0x00000000
56*ba2be530Sab #define	FLG_RE_GOTADD		0x00000001	/* create a GOT entry */
57*ba2be530Sab #define	FLG_RE_GOTREL		0x00000002	/* GOT based */
58*ba2be530Sab #define	FLG_RE_GOTPC		0x00000004	/* GOT - P */
59*ba2be530Sab #define	FLG_RE_GOTOPINS		0x00000008	/* GOTOP instruction */
60*ba2be530Sab #define	FLG_RE_PCREL		0x00000010
61*ba2be530Sab #define	FLG_RE_PLTREL		0x00000020
62*ba2be530Sab #define	FLG_RE_VERIFY		0x00000040	/* verify value fits */
63*ba2be530Sab #define	FLG_RE_UNALIGN		0x00000080	/* offset is not aligned */
64*ba2be530Sab #define	FLG_RE_WDISP16		0x00000100	/* funky sparc DISP16 rel */
65*ba2be530Sab #define	FLG_RE_SIGN		0x00000200	/* value is signed */
66*ba2be530Sab #define	FLG_RE_ADDRELATIVE	0x00000400	/* RELATIVE relocation */
67*ba2be530Sab 						/*	required for non- */
68*ba2be530Sab 						/*	fixed objects */
69*ba2be530Sab #define	FLG_RE_EXTOFFSET	0x00000800	/* extra offset required */
70*ba2be530Sab #define	FLG_RE_REGISTER		0x00001000	/* relocation initializes */
71*ba2be530Sab 						/*    a REGISTER by OLO10 */
72*ba2be530Sab #define	FLG_RE_SIZE		0x00002000	/* symbol size required */
73*ba2be530Sab 
74*ba2be530Sab #define	FLG_RE_NOTSUP		0x00010000	/* relocation not supported */
75*ba2be530Sab 
76*ba2be530Sab #define	FLG_RE_SEGREL		0x00040000	/* segment relative */
77*ba2be530Sab #define	FLG_RE_SECREL		0x00080000	/* section relative */
78*ba2be530Sab 
79*ba2be530Sab #define	FLG_RE_TLSGD		0x00200000	/* TLS GD relocation */
80*ba2be530Sab #define	FLG_RE_TLSLD		0x00400000	/* TLS LD relocation */
81*ba2be530Sab #define	FLG_RE_TLSIE		0x00800000	/* TLS IE relocation */
82*ba2be530Sab #define	FLG_RE_TLSLE		0x01000000	/* TLS LE relocation */
83*ba2be530Sab #define	FLG_RE_LOCLBND		0x02000000	/* relocation must bind */
84*ba2be530Sab 						/*    locally */
85*ba2be530Sab 
86*ba2be530Sab /*
87*ba2be530Sab  * Relocation table and macros for testing relocation table flags.
88*ba2be530Sab  */
89*ba2be530Sab 
90*ba2be530Sab #define	RELTAB_IS_PLT(X, _reltab) \
91*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_PLTREL) != 0)
92*ba2be530Sab 
93*ba2be530Sab #define	RELTAB_IS_GOT_RELATIVE(X, _reltab) \
94*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_GOTADD) != 0)
95*ba2be530Sab 
96*ba2be530Sab #define	RELTAB_IS_GOT_PC(X, _reltab) \
97*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_GOTPC) != 0)
98*ba2be530Sab 
99*ba2be530Sab #define	RELTAB_IS_GOTPCREL(X, _reltab) \
100*ba2be530Sab 	((_reltab[(X)].re_flags & (FLG_RE_GOTPC | FLG_RE_GOTADD)) == \
101*ba2be530Sab 	(FLG_RE_GOTPC | FLG_RE_GOTADD))
102*ba2be530Sab 
103*ba2be530Sab #define	RELTAB_IS_GOT_BASED(X, _reltab) \
104*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_GOTREL) != 0)
105*ba2be530Sab 
106*ba2be530Sab #define	RELTAB_IS_GOT_OPINS(X, _reltab) \
107*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_GOTOPINS) != 0)
108*ba2be530Sab 
109*ba2be530Sab #define	RELTAB_IS_GOT_REQUIRED(X, _reltab) \
110*ba2be530Sab 	((_reltab[(X)].re_flags & (FLG_RE_GOTADD | FLG_RE_GOTREL | \
111*ba2be530Sab 	FLG_RE_GOTPC | FLG_RE_GOTOPINS)) != 0)
112*ba2be530Sab 
113*ba2be530Sab #define	RELTAB_IS_PC_RELATIVE(X, _reltab) \
114*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_PCREL) != 0)
115*ba2be530Sab 
116*ba2be530Sab #define	RELTAB_IS_ADD_RELATIVE(X, _reltab) \
117*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_ADDRELATIVE) != 0)
118*ba2be530Sab 
119*ba2be530Sab #define	RELTAB_IS_REGISTER(X, _reltab) \
120*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_REGISTER) != 0)
121*ba2be530Sab 
122*ba2be530Sab #define	RELTAB_IS_NOTSUP(X, _reltab) \
123*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_NOTSUP) != 0)
124*ba2be530Sab 
125*ba2be530Sab #define	RELTAB_IS_SEG_RELATIVE(X, _reltab) \
126*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_SEGREL) != 0)
127*ba2be530Sab 
128*ba2be530Sab #define	RELTAB_IS_EXTOFFSET(X, _reltab) \
129*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_EXTOFFSET) != 0)
130*ba2be530Sab 
131*ba2be530Sab #define	RELTAB_IS_SEC_RELATIVE(X, _reltab) \
132*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_SECREL) != 0)
133*ba2be530Sab 
134*ba2be530Sab #define	RELTAB_IS_TLS_INS(X, _reltab) \
135*ba2be530Sab 	((_reltab[(X)].re_flags & \
136*ba2be530Sab 	(FLG_RE_TLSGD | FLG_RE_TLSLD | FLG_RE_TLSIE | FLG_RE_TLSLE)) != 0)
137*ba2be530Sab 
138*ba2be530Sab #define	RELTAB_IS_TLS_GD(X, _reltab) \
139*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_TLSGD) != 0)
140*ba2be530Sab 
141*ba2be530Sab #define	RELTAB_IS_TLS_LD(X, _reltab) \
142*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_TLSLD) != 0)
143*ba2be530Sab 
144*ba2be530Sab #define	RELTAB_IS_TLS_IE(X, _reltab) \
145*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_TLSIE) != 0)
146*ba2be530Sab 
147*ba2be530Sab #define	RELTAB_IS_TLS_LE(X, _reltab) \
148*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_TLSLE) != 0)
149*ba2be530Sab 
150*ba2be530Sab #define	RELTAB_IS_LOCALBND(X, _reltab) \
151*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_LOCLBND) != 0)
152*ba2be530Sab 
153*ba2be530Sab #define	RELTAB_IS_SIZE(X, _reltab) \
154*ba2be530Sab 	((_reltab[(X)].re_flags & FLG_RE_SIZE) != 0)
155*ba2be530Sab 
156*ba2be530Sab #ifdef	__cplusplus
157*ba2be530Sab }
158*ba2be530Sab #endif
159*ba2be530Sab 
160*ba2be530Sab #endif /* _RELOC_DEFS_DOT_H */
161