xref: /illumos-gate/usr/src/uts/common/sys/elf_amd64.h (revision 1e56f352c1c208679012bca47d552e127f5b1072)
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_GOTPC32_TLSDESC	34
71 #define	R_AMD64_TLSDESC_CALL	35
72 #define	R_AMD64_TLSDESC		36
73 #define	R_AMD64_IRELATIVE	37
74 #define	R_AMD64_RELATIVE64	38
75 #define	R_AMD64_UNKNOWN39	39	/* deprecated */
76 #define	R_AMD64_UNKNOWN40	40	/* deprecated */
77 #define	R_AMD64_GOTPCRELX	41
78 #define	R_AMD64_REX_GOTPCRELX	42
79 #define	R_AMD64_NUM		43
80 
81 /*
82  * The "System V Application Binary Interface, AMD64 Architecture Processor
83  * Supplement", defines relocations in terms of R_X86_64_ rather than R_AMD64_.
84  * Maintain both relocation naming conventions for compatibility.
85  */
86 #define	R_X86_64_NONE			R_AMD64_NONE
87 #define	R_X86_64_64			R_AMD64_64
88 #define	R_X86_64_PC32			R_AMD64_PC32
89 #define	R_X86_64_GOT32			R_AMD64_GOT32
90 #define	R_X86_64_PLT32			R_AMD64_PLT32
91 #define	R_X86_64_COPY			R_AMD64_COPY
92 #define	R_X86_64_GLOB_DAT		R_AMD64_GLOB_DAT
93 #define	R_X86_64_JUMP_SLOT		R_AMD64_JUMP_SLOT
94 #define	R_X86_64_RELATIVE		R_AMD64_RELATIVE
95 #define	R_X86_64_GOTPCREL		R_AMD64_GOTPCREL
96 #define	R_X86_64_32			R_AMD64_32
97 #define	R_X86_64_32S			R_AMD64_32S
98 #define	R_X86_64_16			R_AMD64_16
99 #define	R_X86_64_PC16			R_AMD64_PC16
100 #define	R_X86_64_8			R_AMD64_8
101 #define	R_X86_64_PC8			R_AMD64_PC8
102 #define	R_X86_64_DTPMOD64		R_AMD64_DTPMOD64
103 #define	R_X86_64_DTPOFF64		R_AMD64_DTPOFF64
104 #define	R_X86_64_TPOFF64		R_AMD64_TPOFF64
105 #define	R_X86_64_TLSGD			R_AMD64_TLSGD
106 #define	R_X86_64_TLSLD			R_AMD64_TLSLD
107 #define	R_X86_64_DTPOFF32		R_AMD64_DTPOFF32
108 #define	R_X86_64_GOTTPOFF		R_AMD64_GOTTPOFF
109 #define	R_X86_64_TPOFF32		R_AMD64_TPOFF32
110 #define	R_X86_64_PC64			R_AMD64_PC64
111 #define	R_X86_64_GOTPC32		R_AMD64_GOTPC32
112 #define	R_X86_64_GOTOFF64		R_AMD64_GOTOFF64
113 #define	R_X86_64_GOT64			R_AMD64_GOT64
114 #define	R_X86_64_GOTPCREL64		R_AMD64_GOTPCREL64
115 #define	R_X86_64_GOTPC64		R_AMD64_GOTPC64
116 #define	R_X86_64_GOTPLT64		R_AMD64_GOTPLT64
117 #define	R_X86_64_PLTOFF64		R_AMD64_PLTOFF64
118 #define	R_X86_64_SIZE32			R_AMD64_SIZE32
119 #define	R_X86_64_SIZE64			R_AMD64_SIZE64
120 #define	R_X86_64_GOTPC32_TLSDESC	R_AMD64_GOTPC32_TLSDESC
121 #define	R_X86_64_TLSDESC_CALL		R_AMD64_TLSDESC_CALL
122 #define	R_X86_64_TLSDESC		R_AMD64_TLSDESC
123 #define	R_X86_64_IRELATIVE		R_AMD64_IRELATIVE
124 #define	R_X86_64_RELATIVE64		R_AMD64_RELATIVE64
125 #define	R_X86_64_GOTPCRELX		R_AMD64_GOTPCRELX
126 #define	R_X86_64_REX_GOTPCRELX		R_AMD64_REX_GOTPCRELX
127 #define	R_X86_64_NUM			R_AMD64_NUM
128 
129 #define	ELF_AMD64_MAXPGSZ	0x100000	/* maximum page size */
130 
131 /*
132  * processor specific section types
133  */
134 #define	SHT_AMD64_UNWIND	0x70000001	/* unwind information */
135 #define	SHT_X86_64_UNWIND	SHT_AMD64_UNWIND
136 
137 /*
138  * NOTE: PT_SUNW_UNWIND is defined in the OS specific range
139  *	 to conform with the amd64 psABI.
140  */
141 
142 #define	SHF_AMD64_LARGE		0x10000000
143 #define	SHF_X86_64_LARGE	SHF_AMD64_LARGE
144 
145 #define	SHN_AMD64_LCOMMON	0xff02
146 #define	SHN_X86_64_LCOMMON	SHN_AMD64_LCOMMON
147 
148 /*
149  * There are consumers of this file that want to include elf defines for
150  * all architectures.  This is a problem for the defines below, because
151  * while they are architecture specific they have common names.  Hence to
152  * prevent attempts to redefine these variables we'll check if any of
153  * the other elf architecture header files have been included.  If
154  * they have then we'll just stick with the existing definitions.
155  */
156 #if defined(_SYS_ELF_MACH_386)
157 
158 /*
159  * Plt and Got information; the first few .got and .plt entries are reserved
160  *	PLT[0]	jump to dynamic linker
161  *	GOT[0]	address of _DYNAMIC
162  */
163 #define	M64_WORD_ALIGN		8
164 #define	M64_PLT_ENTSIZE		M32_PLT_ENTSIZE
165 #define	M64_PLT_ALIGN		M64_WORD_ALIGN	/* alignment of .plt section */
166 #define	M64_GOT_ENTSIZE		8	/* got entry size in bytes */
167 #define	M64_PLT_RESERVSZ	M32_PLT_RESERVSZ
168 
169 /*
170  * Make common alias for the 32/64 bit specific defines based on _ELF64
171  */
172 #if defined(_ELF64)
173 /* architecture common defines */
174 #define	M_WORD_ALIGN		M64_WORD_ALIGN
175 #define	M_PLT_ENTSIZE		M64_PLT_ENTSIZE
176 #define	M_PLT_ALIGN		M64_PLT_ALIGN
177 #define	M_PLT_RESERVSZ		M64_PLT_RESERVSZ
178 #define	M_GOT_ENTSIZE		M64_GOT_ENTSIZE
179 #endif /* _ELF64 */
180 
181 #endif /* _SYS_ELF_MACH_386 */
182 
183 #ifdef	__cplusplus
184 }
185 #endif
186 
187 #endif	/* _SYS_ELF_AMD64_H */
188