xref: /titanic_41/usr/src/uts/common/sys/elf_amd64.h (revision 3fc1e28905f8d0b151f1f359d523492bed5a20f2)
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 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_ELF_AMD64_H
28 #define	_SYS_ELF_AMD64_H
29 
30 #include <sys/elf_386.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	R_AMD64_NONE		0	/* relocation types */
37 #define	R_AMD64_64		1
38 #define	R_AMD64_PC32		2
39 #define	R_AMD64_GOT32		3
40 #define	R_AMD64_PLT32		4
41 #define	R_AMD64_COPY		5
42 #define	R_AMD64_GLOB_DAT	6
43 #define	R_AMD64_JUMP_SLOT	7
44 #define	R_AMD64_RELATIVE	8
45 #define	R_AMD64_GOTPCREL	9
46 #define	R_AMD64_32		10
47 #define	R_AMD64_32S		11
48 #define	R_AMD64_16		12
49 #define	R_AMD64_PC16		13
50 #define	R_AMD64_8		14
51 #define	R_AMD64_PC8		15
52 #define	R_AMD64_DTPMOD64	16
53 #define	R_AMD64_DTPOFF64	17
54 #define	R_AMD64_TPOFF64		18
55 #define	R_AMD64_TLSGD		19
56 #define	R_AMD64_TLSLD		20
57 #define	R_AMD64_DTPOFF32	21
58 #define	R_AMD64_GOTTPOFF	22
59 #define	R_AMD64_TPOFF32		23
60 #define	R_AMD64_PC64		24
61 #define	R_AMD64_GOTOFF64	25
62 #define	R_AMD64_GOTPC32		26
63 #define	R_AMD64_GOT64		27	/* reserved for future expansion */
64 #define	R_AMD64_GOTPCREL64	28	/* reserved for future expansion */
65 #define	R_AMD64_GOTPC64		29	/* reserved for future expansion */
66 #define	R_AMD64_GOTPLT64	30	/* reserved for future expansion */
67 #define	R_AMD64_PLTOFF64	31	/* reserved for future expansion */
68 #define	R_AMD64_SIZE32		32
69 #define	R_AMD64_SIZE64		33
70 #define	R_AMD64_NUM		34
71 
72 
73 /*
74  * The "System V Application Binary Interface, AMD64 Architecture Processor
75  * Supplement", defines relocations in terms of R_X86_64_ rather than R_AMD64_.
76  * Maintain both relocation naming conventions for compatibility.
77  */
78 #define	R_X86_64_NONE		R_AMD64_NONE
79 #define	R_X86_64_64		R_AMD64_64
80 #define	R_X86_64_PC32		R_AMD64_PC32
81 #define	R_X86_64_GOT32		R_AMD64_GOT32
82 #define	R_X86_64_PLT32		R_AMD64_PLT32
83 #define	R_X86_64_COPY		R_AMD64_COPY
84 #define	R_X86_64_GLOB_DAT	R_AMD64_GLOB_DAT
85 #define	R_X86_64_JUMP_SLOT	R_AMD64_JUMP_SLOT
86 #define	R_X86_64_RELATIVE	R_AMD64_RELATIVE
87 #define	R_X86_64_GOTPCREL	R_AMD64_GOTPCREL
88 #define	R_X86_64_32		R_AMD64_32
89 #define	R_X86_64_32S		R_AMD64_32S
90 #define	R_X86_64_16		R_AMD64_16
91 #define	R_X86_64_PC16		R_AMD64_PC16
92 #define	R_X86_64_8		R_AMD64_8
93 #define	R_X86_64_PC8		R_AMD64_PC8
94 #define	R_X86_64_DTPMOD64	R_AMD64_DTPMOD64
95 #define	R_X86_64_DTPOFF64	R_AMD64_DTPOFF64
96 #define	R_X86_64_TPOFF64	R_AMD64_TPOFF64
97 #define	R_X86_64_TLSGD		R_AMD64_TLSGD
98 #define	R_X86_64_TLSLD		R_AMD64_TLSLD
99 #define	R_X86_64_DTPOFF32	R_AMD64_DTPOFF32
100 #define	R_X86_64_GOTTPOFF	R_AMD64_GOTTPOFF
101 #define	R_X86_64_TPOFF32	R_AMD64_TPOFF32
102 #define	R_X86_64_PC64		R_AMD64_PC64
103 #define	R_X86_64_GOTPC32	R_AMD64_GOTPC32
104 #define	R_X86_64_GOTOFF64	R_AMD64_GOTOFF64
105 #define	R_X86_64_GOT64		R_AMD64_GOT64
106 #define	R_X86_64_GOTPCREL64	R_AMD64_GOTPCREL64
107 #define	R_X86_64_GOTPC64	R_AMD64_GOTPC64
108 #define	R_X86_64_GOTPLT64	R_AMD64_GOTPLT64
109 #define	R_X86_64_PLTOFF64	R_AMD64_PLTOFF64
110 #define	R_X86_64_SIZE32		R_AMD64_SIZE32
111 #define	R_X86_64_SIZE64		R_AMD64_SIZE64
112 #define	R_X86_64_NUM		R_AMD64_NUM
113 
114 
115 #define	ELF_AMD64_MAXPGSZ	0x100000	/* maximum page size */
116 
117 /*
118  * processor specific section types
119  */
120 #define	SHT_AMD64_UNWIND	0x70000001	/* unwind information */
121 #define	SHT_X86_64_UNWIND	SHT_AMD64_UNWIND
122 
123 /*
124  * NOTE: PT_SUNW_UNWIND is defined in the OS specific range
125  *	 to conform with the amd64 psABI.
126  */
127 
128 #define	SHF_AMD64_LARGE		0x10000000
129 #define	SHF_X86_64_LARGE	SHF_AMD64_LARGE
130 
131 #define	SHN_AMD64_LCOMMON	0xff02
132 #define	SHN_X86_64_LCOMMON	SHN_AMD64_LCOMMON
133 
134 /*
135  * There are consumers of this file that want to include elf defines for
136  * all architectures.  This is a problem for the defines below, because
137  * while they are architecture specific they have common names.  Hence to
138  * prevent attempts to redefine these variables we'll check if any of
139  * the other elf architecture header files have been included.  If
140  * they have then we'll just stick with the existing definitions.
141  */
142 #if defined(_SYS_ELF_MACH_386)
143 
144 /*
145  * Plt and Got information; the first few .got and .plt entries are reserved
146  *	PLT[0]	jump to dynamic linker
147  *	GOT[0]	address of _DYNAMIC
148  */
149 #define	M64_WORD_ALIGN		8
150 #define	M64_PLT_ENTSIZE		M32_PLT_ENTSIZE
151 #define	M64_PLT_ALIGN		M64_WORD_ALIGN	/* alignment of .plt section */
152 #define	M64_GOT_ENTSIZE		8	/* got entry size in bytes */
153 #define	M64_PLT_RESERVSZ	M32_PLT_RESERVSZ
154 
155 /*
156  * Make common alias for the 32/64 bit specific defines based on _ELF64
157  */
158 #if defined(_ELF64)
159 /* architecture common defines */
160 #define	M_WORD_ALIGN		M64_WORD_ALIGN
161 #define	M_PLT_ENTSIZE		M64_PLT_ENTSIZE
162 #define	M_PLT_ALIGN		M64_PLT_ALIGN
163 #define	M_PLT_RESERVSZ		M64_PLT_RESERVSZ
164 #define	M_GOT_ENTSIZE		M64_GOT_ENTSIZE
165 #endif /* _ELF64 */
166 
167 #endif /* _SYS_ELF_MACH_386 */
168 
169 #ifdef	__cplusplus
170 }
171 #endif
172 
173 #endif	/* _SYS_ELF_AMD64_H */
174