Mercurial > illumos > illumos-gate
annotate usr/src/cmd/sgs/include/sparc/machdep.h @ 2647:e440e3da2a6f
6464235 executing the 64-bit ld(1) should be easy
author | rie |
---|---|
date | Wed, 30 Aug 2006 10:15:44 -0700 |
parents | 8c9a4f31d225 |
children | 897bcb036a29 |
rev | line source |
---|---|
0 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
4 * The contents of this file are subject to the terms of the | |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
0
diff
changeset
|
5 * Common Development and Distribution License (the "License"). |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
0
diff
changeset
|
6 * You may not use this file except in compliance with the License. |
0 | 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 */ | |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
0
diff
changeset
|
21 |
0 | 22 /* |
23 * Copyright (c) 1988 AT&T | |
24 * All Rights Reserved | |
25 * | |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
0
diff
changeset
|
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
0 | 27 * Use is subject to license terms. |
28 * | |
29 * Global include file for all sgs SPARC machine dependent macros, constants | |
30 * and declarations. | |
31 */ | |
32 | |
33 #ifndef _MACHDEP_H | |
34 #define _MACHDEP_H | |
35 | |
36 #pragma ident "%Z%%M% %I% %E% SMI" | |
37 | |
38 #include <link.h> | |
39 #include <sys/machelf.h> | |
40 | |
41 #ifdef __cplusplus | |
42 extern "C" { | |
43 #endif | |
44 | |
45 /* | |
46 * Elf header information. | |
47 */ | |
48 #ifdef _ELF64 | |
49 #define M_MACH EM_SPARCV9 | |
50 #define M_CLASS ELFCLASS64 | |
51 #else | |
52 #define M_MACH EM_SPARC | |
53 #define M_CLASS ELFCLASS32 | |
54 #endif | |
55 #define M_MACHPLUS EM_SPARC32PLUS | |
56 #define M_DATA ELFDATA2MSB | |
57 #define M_FLAGSPLUS EF_SPARC_32PLUS | |
58 | |
59 /* | |
60 * Page boundary Macros: truncate to previous page boundary and round to | |
61 * next page boundary (refer to generic macros in ../sgs.h also). | |
62 */ | |
63 #define M_PTRUNC(X) ((X) & ~(syspagsz - 1)) | |
64 #define M_PROUND(X) (((X) + syspagsz - 1) & ~(syspagsz - 1)) | |
65 | |
66 /* | |
67 * Segment boundary macros: truncate to previous segment boundary and round | |
68 * to next page boundary. | |
69 */ | |
70 #ifndef M_SEGSIZE | |
71 #define M_SEGSIZE ELF_SPARC_MAXPGSZ | |
72 #endif | |
73 #define M_STRUNC(X) ((X) & ~(M_SEGSIZE - 1)) | |
74 #define M_SROUND(X) (((X) + M_SEGSIZE - 1) & ~(M_SEGSIZE - 1)) | |
75 | |
76 | |
77 /* | |
78 * TLS static segments must be rounded to the following requirements, | |
79 * due to libthread stack allocation. | |
80 */ | |
81 #if defined(_ELF64) | |
82 #define M_TLSSTATALIGN 0x10 | |
83 #else | |
2647 | 84 #define M_TLSSTATALIGN 0x08 |
0 | 85 #endif |
86 | |
87 | |
88 /* | |
89 * Instruction encodings. | |
90 */ | |
91 #define M_SAVESP64 0x9de3bfc0 /* save %sp, -64, %sp */ | |
92 #define M_CALL 0x40000000 | |
93 #define M_JMPL 0x81c06000 /* jmpl %g1 + simm13, %g0 */ | |
94 #define M_SETHIG0 0x01000000 /* sethi %hi(val), %g0 */ | |
95 #define M_SETHIG1 0x03000000 /* sethi %hi(val), %g1 */ | |
96 #define M_STO7G1IM 0xde206000 /* st %o7,[%g1 + %lo(val)] */ | |
97 #define M_SUBFPSPG1 0x8227800e /* sub %fp,%sp,%g1 */ | |
98 #define M_NOP 0x01000000 /* sethi 0, %o0 (nop) */ | |
99 #define M_BA_A 0x30800000 /* ba,a */ | |
100 #define M_BA_A_PT 0x30480000 /* ba,a %icc, <dst> */ | |
101 #define M_MOVO7TOG1 0x8210000f /* mov %o7, %g1 */ | |
102 #define M_MOVO7TOG5 0x8a10000f /* mov %o7, %g5 */ | |
103 #define M_MOVI7TOG1 0x8210001f /* mov %i7, %g1 */ | |
104 #define M_BA_A_XCC 0x30680000 /* ba,a %xcc */ | |
105 #define M_JMPL_G5G0 0x81c16000 /* jmpl %g5 + 0, %g0 */ | |
106 #define M_XNOR_G5G1 0x82396000 /* xnor %g5, 0, %g1 */ | |
107 | |
108 | |
109 #define M_BIND_ADJ 4 /* adjustment for end of */ | |
110 /* elf_rtbndr() address */ | |
111 | |
112 | |
113 /* | |
114 * Plt and Got information; the first few .got and .plt entries are reserved | |
115 * PLT[0] jump to dynamic linker | |
116 * GOT[0] address of _DYNAMIC | |
117 */ | |
118 #define M_PLT_INSSIZE 4 /* single plt instruction size */ | |
119 #define M_GOT_XDYNAMIC 0 /* got index for _DYNAMIC */ | |
120 #define M_GOT_XNumber 1 /* reserved no. of got entries */ | |
121 | |
122 /* | |
123 * ELF32 bit PLT constants | |
124 */ | |
125 #define M32_PLT_ENTSIZE 12 /* 32bit plt entry size in bytes */ | |
126 | |
127 /* | |
128 * ELF64 bit PLT constants | |
129 */ | |
130 #define M64_PLT_NEARPLTS 0x8000 /* # of NEAR PLTS we can have */ | |
131 #define M64_PLT_ENTSIZE 32 /* plt entry size in bytes */ | |
132 #define M64_PLT_FENTSIZE 24 /* size of far plt is 6 instructions */ | |
133 /* x 4bytes */ | |
134 #define M64_PLT_PSIZE 8 /* size of PLTP pointer */ | |
135 #define M64_PLT_FBLKCNTS 160 /* # of plts in far PLT blocks */ | |
136 #define M64_PLT_FBLOCKSZ (M64_PLT_FBLKCNTS *\ | |
137 M64_PLT_ENTSIZE) /* size of far PLT block */ | |
138 | |
139 | |
140 #ifdef _ELF64 | |
141 #define M_PLT_ENTSIZE M64_PLT_ENTSIZE /* plt entry size in bytes */ | |
142 #define M_PLT_XNumber 4 /* reserved no. of plt entries */ | |
143 #define M_PLT_ALIGN 256 /* alignment of .plt section */ | |
144 #define M_PLT_RESERVSZ (M_PLT_XNumber * \ | |
145 M_PLT_ENTSIZE) /* first 4 plt's reserved */ | |
146 #define M_GOT_ENTSIZE 8 /* got entry size in bytes */ | |
147 #define M_GOT_MAXSMALL 1024 /* maximum no. of small gots */ | |
148 #else /* Elf32 */ | |
149 #define M_PLT_ENTSIZE M32_PLT_ENTSIZE /* plt entry size in bytes */ | |
150 #define M_PLT_XNumber 4 /* reserved no. of plt entries */ | |
151 #define M_PLT_ALIGN M_WORD_ALIGN /* alignment of .plt section */ | |
152 #define M_PLT_RESERVSZ (M_PLT_XNumber * \ | |
153 M_PLT_ENTSIZE) /* first 4 plt's reserved */ | |
154 #define M_GOT_ENTSIZE 4 /* got entry size in bytes */ | |
155 #define M_GOT_MAXSMALL 2048 /* maximum no. of small gots */ | |
156 #endif /* _ELF64 */ | |
157 /* transition flags for got sizing */ | |
158 #define M_GOT_LARGE (Sword)(-M_GOT_MAXSMALL - 1) | |
159 #define M_GOT_SMALL (Sword)(-M_GOT_MAXSMALL - 2) | |
160 | |
161 | |
162 /* | |
163 * Other machine dependent entities | |
164 */ | |
165 #ifdef _ELF64 | |
166 #define M_SEGM_ALIGN ELF_SPARCV9_MAXPGSZ | |
167 /* | |
168 * Put 64-bit programs above 4 gigabytes to help insure correctness, | |
169 * so any 64-bit programs that truncate pointers will fault now instead of | |
170 * corrupting itself and dying mysteriously. | |
171 */ | |
172 #define M_SEGM_ORIGIN (Addr)0x100000000ULL /* default first segment offset */ | |
173 #define M_WORD_ALIGN 8 | |
174 #else | |
175 #define M_SEGM_ALIGN ELF_SPARC_MAXPGSZ | |
176 #define M_SEGM_ORIGIN (Addr)0x10000 /* default first segment offset */ | |
177 #define M_WORD_ALIGN 4 | |
178 #endif | |
179 | |
180 /* | |
181 * Make machine class dependent functions transparent to the common code | |
182 */ | |
183 #ifdef _ELF64 | |
184 #define ELF_R_TYPE ELF64_R_TYPE_ID | |
185 #define ELF_R_INFO ELF64_R_INFO | |
186 #define ELF_R_SYM ELF64_R_SYM | |
187 #define ELF_R_TYPE_DATA ELF64_R_TYPE_DATA | |
188 #define ELF_R_TYPE_INFO ELF64_R_TYPE_INFO | |
189 #define ELF_ST_BIND ELF64_ST_BIND | |
190 #define ELF_ST_TYPE ELF64_ST_TYPE | |
191 #define ELF_ST_INFO ELF64_ST_INFO | |
192 #define ELF_ST_VISIBILITY ELF64_ST_VISIBILITY | |
193 #define ELF_M_SYM ELF64_M_SYM | |
194 #define ELF_M_SIZE ELF64_M_SIZE | |
195 #define ELF_M_INFO ELF64_M_INFO | |
196 #define elf_checksum elf64_checksum | |
197 #define elf_fsize elf64_fsize | |
198 #define elf_getehdr elf64_getehdr | |
199 #define elf_getphdr elf64_getphdr | |
200 #define elf_newehdr elf64_newehdr | |
201 #define elf_newphdr elf64_newphdr | |
202 #define elf_getshdr elf64_getshdr | |
203 #else /* Elf32 */ | |
204 #define ELF_R_TYPE ELF32_R_TYPE | |
205 #define ELF_R_INFO ELF32_R_INFO | |
206 #define ELF_R_SYM ELF32_R_SYM | |
207 #define ELF_M_SYM ELF32_M_SYM | |
208 #define ELF_M_SIZE ELF32_M_SIZE | |
209 #define ELF_M_INFO ELF32_M_INFO | |
210 /* Elf64 can hide extra offset in r_info */ | |
211 #define ELF_R_TYPE_DATA(x) (0) | |
212 #define ELF_R_TYPE_INFO(xoff, type) (type) | |
213 #define ELF_ST_BIND ELF32_ST_BIND | |
214 #define ELF_ST_TYPE ELF32_ST_TYPE | |
215 #define ELF_ST_INFO ELF32_ST_INFO | |
216 #define ELF_ST_VISIBILITY ELF32_ST_VISIBILITY | |
217 #define elf_checksum elf32_checksum | |
218 #define elf_fsize elf32_fsize | |
219 #define elf_getehdr elf32_getehdr | |
220 #define elf_getphdr elf32_getphdr | |
221 #define elf_newehdr elf32_newehdr | |
222 #define elf_newphdr elf32_newphdr | |
223 #define elf_getshdr elf32_getshdr | |
224 #endif /* Elf32 */ | |
225 | |
226 /* | |
227 * Make common relocation information transparent to the common code | |
228 */ | |
229 #define M_REL_DT_TYPE DT_RELA /* .dynamic entry */ | |
230 #define M_REL_DT_SIZE DT_RELASZ /* .dynamic entry */ | |
231 #define M_REL_DT_ENT DT_RELAENT /* .dynamic entry */ | |
232 #define M_REL_DT_COUNT DT_RELACOUNT /* .dynamic entry */ | |
233 #define M_REL_SHT_TYPE SHT_RELA /* section header type */ | |
234 #define M_REL_ELF_TYPE ELF_T_RELA /* data buffer type */ | |
235 | |
236 /* | |
237 * Make common relocation types transparent to the common code | |
238 */ | |
239 #define M_R_NONE R_SPARC_NONE | |
240 #define M_R_GLOB_DAT R_SPARC_GLOB_DAT | |
241 #define M_R_COPY R_SPARC_COPY | |
242 #define M_R_RELATIVE R_SPARC_RELATIVE | |
243 #define M_R_JMP_SLOT R_SPARC_JMP_SLOT | |
244 #define M_R_REGISTER R_SPARC_REGISTER | |
245 #define M_R_FPTR R_SPARC_NONE | |
246 #define M_R_NUM R_SPARC_NUM | |
247 | |
248 /* | |
249 * Length of R_SPARC_ | |
250 */ | |
251 #define M_R_STR_LEN 8 | |
252 | |
253 #ifdef _ELF64 | |
254 #define M_R_ARRAYADDR R_SPARC_64 | |
255 #define M_R_DTPMOD R_SPARC_TLS_DTPMOD64 | |
256 #define M_R_DTPOFF R_SPARC_TLS_DTPOFF64 | |
257 #define M_R_TPOFF R_SPARC_TLS_TPOFF64 | |
258 #else /* _ELF32 */ | |
259 #define M_R_ARRAYADDR R_SPARC_32 | |
260 #define M_R_DTPMOD R_SPARC_TLS_DTPMOD32 | |
261 #define M_R_DTPOFF R_SPARC_TLS_DTPOFF32 | |
262 #define M_R_TPOFF R_SPARC_TLS_TPOFF32 | |
263 #endif /* _ELF64 */ | |
264 | |
265 | |
266 /* | |
267 * Make register symbols transparent to common code | |
268 */ | |
269 #define M_DT_REGISTER DT_SPARC_REGISTER | |
270 | |
271 /* | |
272 * PLTRESERVE is not relevant on sparc | |
273 */ | |
274 #define M_DT_PLTRESERVE 0xffffffff | |
275 | |
276 | |
277 /* | |
278 * Make plt section information transparent to the common code. | |
279 */ | |
280 #define M_PLT_SHF_FLAGS (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR) | |
281 | |
282 /* | |
283 * Make data segment information transparent to the common code. | |
284 */ | |
285 #define M_DATASEG_PERM (PF_R | PF_W | PF_X) | |
286 | |
287 /* | |
288 * Define a set of identifies for special sections. These allow the sections | |
289 * to be ordered within the output file image. These values should be | |
290 * maintained consistently, where appropriate, in each platform specific header | |
291 * file. | |
292 * | |
293 * o null identifies that this section does not need to be added to the | |
294 * output image (ie. shared object sections or sections we're going to | |
295 * recreate (sym tables, string tables, relocations, etc.)). | |
296 * | |
297 * o any user defined section will be first in the associated segment. | |
298 * | |
299 * o interp and capabilities sections are next, as these are accessed | |
300 * immediately the first page of the image is mapped. | |
301 * | |
302 * o the syminfo, hash, dynsym, dynstr and rel's are grouped together as | |
303 * these will all be accessed first by ld.so.1 to perform relocations. | |
304 * | |
305 * o the got, dynamic, and plt are grouped together as these may also be | |
306 * accessed first by ld.so.1 to perform relocations, fill in DT_DEBUG | |
307 * (executables only), and .plt[0]. | |
308 * | |
309 * o unknown sections (stabs, comments etc.) go at the end. | |
310 * | |
311 * Note that .tlsbss/.bss are given the largest identifiers. This insures that | |
312 * if any unknown sections become associated to the same segment as the .bss, | |
313 * the .bss sections are always the last section in the segment. | |
314 */ | |
315 #define M_ID_NULL 0x00 | |
316 #define M_ID_USER 0x01 | |
317 | |
318 #define M_ID_INTERP 0x02 /* SHF_ALLOC */ | |
319 #define M_ID_CAP 0x03 | |
320 #define M_ID_SYMINFO 0x04 | |
321 #define M_ID_HASH 0x05 | |
322 #define M_ID_DYNSYM 0x06 | |
323 #define M_ID_DYNSTR 0x07 | |
324 #define M_ID_VERSION 0x08 | |
325 #define M_ID_REL 0x09 | |
326 #define M_ID_TEXT 0x0b /* SHF_ALLOC + SHF_EXECINSTR */ | |
327 #define M_ID_DATA 0x0c | |
328 | |
329 /* M_ID_USER 0x01 dual entry - listed above */ | |
330 #define M_ID_GOTDATA 0x02 /* SHF_ALLOC + SHF_WRITE */ | |
331 #define M_ID_GOT 0x03 | |
332 #define M_ID_PLT 0x04 | |
333 #define M_ID_DYNAMIC 0x05 | |
334 #define M_ID_ARRAY 0x06 | |
335 | |
336 #define M_ID_UNKNOWN 0xfc /* just before TLS */ | |
337 | |
338 #define M_ID_TLS 0xfd /* just before bss */ | |
339 #define M_ID_TLSBSS 0xfe | |
340 #define M_ID_BSS 0xff | |
341 | |
342 #define M_ID_SYMTAB_NDX 0x02 /* ! SHF_ALLOC */ | |
343 #define M_ID_SYMTAB 0x03 | |
344 #define M_ID_STRTAB 0x04 | |
345 #define M_ID_DYNSYM_NDX 0x05 | |
346 #define M_ID_NOTE 0x06 | |
347 | |
348 #ifdef __cplusplus | |
349 } | |
350 #endif | |
351 | |
352 #endif /* _MACHDEP_H */ |