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