xref: /illumos-gate/usr/src/uts/common/krtld/reloc_defs.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_RELOC_DEFS_DOT_H
28 #define	_RELOC_DEFS_DOT_H
29 
30 #include <sys/machelf.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Definitions used by the relocation common code.
38  */
39 
40 
41 /*
42  * Structure used to build the reloc_table[]
43  */
44 typedef struct {
45 	Xword	re_mask;	/* mask to apply to reloc (sparc only) */
46 	Word	re_flags;	/* relocation attributes */
47 	uchar_t	re_fsize;	/* field size (in bytes) */
48 	uchar_t	re_bshift;	/* number of bits to shift (sparc only) */
49 	uchar_t	re_sigbits;	/* number of significant bits */
50 } Rel_entry;
51 
52 /*
53  * Flags for reloc_entry->re_flags
54  */
55 #define	FLG_RE_NOTREL		0x00000000
56 #define	FLG_RE_GOTADD		0x00000001	/* create a GOT entry */
57 #define	FLG_RE_GOTREL		0x00000002	/* GOT based */
58 #define	FLG_RE_GOTPC		0x00000004	/* GOT - P */
59 #define	FLG_RE_GOTOPINS		0x00000008	/* GOTOP instruction */
60 #define	FLG_RE_PCREL		0x00000010
61 #define	FLG_RE_PLTREL		0x00000020
62 #define	FLG_RE_VERIFY		0x00000040	/* verify value fits */
63 #define	FLG_RE_UNALIGN		0x00000080	/* offset is not aligned */
64 #define	FLG_RE_WDISP16		0x00000100	/* funky sparc DISP16 rel */
65 #define	FLG_RE_SIGN		0x00000200	/* value is signed */
66 #define	FLG_RE_ADDRELATIVE	0x00000400	/* RELATIVE relocation */
67 						/*	required for non- */
68 						/*	fixed objects */
69 #define	FLG_RE_EXTOFFSET	0x00000800	/* extra offset required */
70 #define	FLG_RE_REGISTER		0x00001000	/* relocation initializes */
71 						/*    a REGISTER by OLO10 */
72 #define	FLG_RE_SIZE		0x00002000	/* symbol size required */
73 
74 #define	FLG_RE_NOTSUP		0x00010000	/* relocation not supported */
75 
76 #define	FLG_RE_SEGREL		0x00040000	/* segment relative */
77 #define	FLG_RE_SECREL		0x00080000	/* section relative */
78 
79 #define	FLG_RE_TLSGD		0x00200000	/* TLS GD relocation */
80 #define	FLG_RE_TLSLD		0x00400000	/* TLS LD relocation */
81 #define	FLG_RE_TLSIE		0x00800000	/* TLS IE relocation */
82 #define	FLG_RE_TLSLE		0x01000000	/* TLS LE relocation */
83 #define	FLG_RE_LOCLBND		0x02000000	/* relocation must bind */
84 						/*    locally */
85 
86 /*
87  * Relocation table and macros for testing relocation table flags.
88  */
89 
90 #define	RELTAB_IS_PLT(X, _reltab) \
91 	((_reltab[(X)].re_flags & FLG_RE_PLTREL) != 0)
92 
93 #define	RELTAB_IS_GOT_RELATIVE(X, _reltab) \
94 	((_reltab[(X)].re_flags & FLG_RE_GOTADD) != 0)
95 
96 #define	RELTAB_IS_GOT_PC(X, _reltab) \
97 	((_reltab[(X)].re_flags & FLG_RE_GOTPC) != 0)
98 
99 #define	RELTAB_IS_GOTPCREL(X, _reltab) \
100 	((_reltab[(X)].re_flags & (FLG_RE_GOTPC | FLG_RE_GOTADD)) == \
101 	(FLG_RE_GOTPC | FLG_RE_GOTADD))
102 
103 #define	RELTAB_IS_GOT_BASED(X, _reltab) \
104 	((_reltab[(X)].re_flags & FLG_RE_GOTREL) != 0)
105 
106 #define	RELTAB_IS_GOT_OPINS(X, _reltab) \
107 	((_reltab[(X)].re_flags & FLG_RE_GOTOPINS) != 0)
108 
109 #define	RELTAB_IS_GOT_REQUIRED(X, _reltab) \
110 	((_reltab[(X)].re_flags & (FLG_RE_GOTADD | FLG_RE_GOTREL | \
111 	FLG_RE_GOTPC | FLG_RE_GOTOPINS)) != 0)
112 
113 #define	RELTAB_IS_PC_RELATIVE(X, _reltab) \
114 	((_reltab[(X)].re_flags & FLG_RE_PCREL) != 0)
115 
116 #define	RELTAB_IS_ADD_RELATIVE(X, _reltab) \
117 	((_reltab[(X)].re_flags & FLG_RE_ADDRELATIVE) != 0)
118 
119 #define	RELTAB_IS_REGISTER(X, _reltab) \
120 	((_reltab[(X)].re_flags & FLG_RE_REGISTER) != 0)
121 
122 #define	RELTAB_IS_NOTSUP(X, _reltab) \
123 	((_reltab[(X)].re_flags & FLG_RE_NOTSUP) != 0)
124 
125 #define	RELTAB_IS_SEG_RELATIVE(X, _reltab) \
126 	((_reltab[(X)].re_flags & FLG_RE_SEGREL) != 0)
127 
128 #define	RELTAB_IS_EXTOFFSET(X, _reltab) \
129 	((_reltab[(X)].re_flags & FLG_RE_EXTOFFSET) != 0)
130 
131 #define	RELTAB_IS_SEC_RELATIVE(X, _reltab) \
132 	((_reltab[(X)].re_flags & FLG_RE_SECREL) != 0)
133 
134 #define	RELTAB_IS_TLS_INS(X, _reltab) \
135 	((_reltab[(X)].re_flags & \
136 	(FLG_RE_TLSGD | FLG_RE_TLSLD | FLG_RE_TLSIE | FLG_RE_TLSLE)) != 0)
137 
138 #define	RELTAB_IS_TLS_GD(X, _reltab) \
139 	((_reltab[(X)].re_flags & FLG_RE_TLSGD) != 0)
140 
141 #define	RELTAB_IS_TLS_LD(X, _reltab) \
142 	((_reltab[(X)].re_flags & FLG_RE_TLSLD) != 0)
143 
144 #define	RELTAB_IS_TLS_IE(X, _reltab) \
145 	((_reltab[(X)].re_flags & FLG_RE_TLSIE) != 0)
146 
147 #define	RELTAB_IS_TLS_LE(X, _reltab) \
148 	((_reltab[(X)].re_flags & FLG_RE_TLSLE) != 0)
149 
150 #define	RELTAB_IS_LOCALBND(X, _reltab) \
151 	((_reltab[(X)].re_flags & FLG_RE_LOCLBND) != 0)
152 
153 #define	RELTAB_IS_SIZE(X, _reltab) \
154 	((_reltab[(X)].re_flags & FLG_RE_SIZE) != 0)
155 
156 #ifdef	__cplusplus
157 }
158 #endif
159 
160 #endif /* _RELOC_DEFS_DOT_H */
161