xref: /illumos-gate/usr/src/uts/common/sys/elf_386.h (revision a530dbfeb9a5dac77444604360c346085f7c7a04)
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 (c) 1984, 1986, 1987, 1988, 1989 AT&T
24  *	  All Rights Reserved
25  *
26  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 #ifndef _SYS_ELF_386_H
31 #define	_SYS_ELF_386_H
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #define	R_386_NONE		0	/* relocation type */
38 #define	R_386_32		1
39 #define	R_386_PC32		2
40 #define	R_386_GOT32		3
41 #define	R_386_PLT32		4
42 #define	R_386_COPY		5
43 #define	R_386_GLOB_DAT		6
44 #define	R_386_JMP_SLOT		7
45 #define	R_386_RELATIVE		8
46 #define	R_386_GOTOFF		9
47 #define	R_386_GOTPC		10
48 #define	R_386_32PLT		11
49 #define	R_386_TLS_GD_PLT	12
50 #define	R_386_TLS_LDM_PLT	13
51 #define	R_386_TLS_TPOFF		14
52 #define	R_386_TLS_IE		15
53 #define	R_386_TLS_GOTIE		16
54 #define	R_386_TLS_LE		17
55 #define	R_386_TLS_GD		18
56 #define	R_386_TLS_LDM		19
57 #define	R_386_16		20
58 #define	R_386_PC16		21
59 #define	R_386_8			22
60 #define	R_386_PC8		23
61 #define	R_386_TLS_GD_32		24
62 #define	R_386_TLS_GD_PUSH	25
63 #define	R_386_TLS_GD_CALL	26
64 #define	R_386_TLS_GD_POP	27
65 #define	R_386_TLS_LDM_32	28
66 #define	R_386_TLS_LDM_PUSH	29
67 #define	R_386_TLS_LDM_CALL	30
68 #define	R_386_TLS_LDM_POP	31
69 #define	R_386_TLS_LDO_32	32
70 #define	R_386_TLS_IE_32		33
71 #define	R_386_TLS_LE_32		34
72 #define	R_386_TLS_DTPMOD32	35
73 #define	R_386_TLS_DTPOFF32	36
74 #define	R_386_TLS_TPOFF32	37
75 #define	R_386_SIZE32		38
76 #define	R_386_TLS_GOTDESC	39
77 #define	R_386_TLS_DESC_CALL	40
78 #define	R_386_TLS_DESC		41
79 #define	R_386_IRELATIVE		42
80 #define	R_386_GOT32X		43
81 #define	R_386_NUM		44
82 
83 #define	ELF_386_MAXPGSZ		0x10000	/* maximum page size */
84 
85 #define	SHF_ORDERED	0x40000000
86 #define	SHF_EXCLUDE	0x80000000
87 
88 #define	SHN_BEFORE	0xff00
89 #define	SHN_AFTER	0xff01
90 
91 /*
92  * There are consumers of this file that want to include elf defines for
93  * all architectures.  This is a problem for the defines below, because
94  * while they are architecture specific they have common names.  Hence to
95  * prevent attempts to redefine these variables we'll check if any of
96  * the other elf architecture header files have been included.  If
97  * they have then we'll just stick with the existing definitions.
98  */
99 #if !defined(_SYS_ELF_MACH_COMMON)
100 #define	_SYS_ELF_MACH_COMMON
101 #define	_SYS_ELF_MACH_386
102 
103 /*
104  * Plt and Got information; the first few .got and .plt entries are reserved
105  *	PLT[0]	jump to dynamic linker
106  *	GOT[0]	address of _DYNAMIC
107  */
108 #define	M_PLT_INSSIZE		6	/* single plt instruction size */
109 #define	M_PLT_XNumber		1	/* PLT[0] reserved */
110 #define	M_GOT_XDYNAMIC		0	/* got index for _DYNAMIC */
111 #define	M_GOT_XLINKMAP		1	/* got index for link map */
112 #define	M_GOT_XRTLD		2	/* got index for rtbinder */
113 #define	M_GOT_XNumber		3	/* reserved no. of got entries */
114 
115 #define	M32_WORD_ALIGN		4
116 #define	M32_PLT_ENTSIZE		16	/* plt entry size in bytes */
117 #define	M32_PLT_ALIGN		M32_WORD_ALIGN	/* alignment of .plt section */
118 #define	M32_GOT_ENTSIZE		4	/* got entry size in bytes */
119 #define	M32_PLT_RESERVSZ	(M_PLT_XNumber * \
120 				M32_PLT_ENTSIZE) /* first plt reserved */
121 
122 
123 /*
124  * Make common alias for the 32/64 bit specific defines based on _ELF64
125  */
126 #if !defined(_ELF64)
127 /* architecture common defines */
128 #define	M_WORD_ALIGN		M32_WORD_ALIGN
129 #define	M_PLT_ENTSIZE		M32_PLT_ENTSIZE
130 #define	M_PLT_ALIGN		M32_PLT_ALIGN
131 #define	M_PLT_RESERVSZ		M32_PLT_RESERVSZ
132 #define	M_GOT_ENTSIZE		M32_GOT_ENTSIZE
133 #endif /* !_ELF64 */
134 
135 #endif /* !_SYS_ELF_MACH_COMMON */
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _SYS_ELF_386_H */
142