16206Sab196087 /* 26206Sab196087 * CDDL HEADER START 36206Sab196087 * 46206Sab196087 * The contents of this file are subject to the terms of the 56206Sab196087 * Common Development and Distribution License (the "License"). 66206Sab196087 * You may not use this file except in compliance with the License. 76206Sab196087 * 86206Sab196087 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96206Sab196087 * or http://www.opensolaris.org/os/licensing. 106206Sab196087 * See the License for the specific language governing permissions 116206Sab196087 * and limitations under the License. 126206Sab196087 * 136206Sab196087 * When distributing Covered Code, include this CDDL HEADER in each 146206Sab196087 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156206Sab196087 * If applicable, add the following below this CDDL HEADER, with the 166206Sab196087 * fields enclosed by brackets "[]" replaced with your own identifying 176206Sab196087 * information: Portions Copyright [yyyy] [name of copyright owner] 186206Sab196087 * 196206Sab196087 * CDDL HEADER END 206206Sab196087 */ 216206Sab196087 226206Sab196087 /* 236206Sab196087 * Copyright (c) 1988 AT&T 246206Sab196087 * All Rights Reserved 256206Sab196087 * 26*8501SRod.Evans@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 276206Sab196087 * Use is subject to license terms. 286206Sab196087 * 296206Sab196087 * Global include file for all sgs SPARC machine dependent macros, constants 306206Sab196087 * and declarations. 316206Sab196087 */ 326206Sab196087 336206Sab196087 #ifndef _MACHDEP_SPARC_H 346206Sab196087 #define _MACHDEP_SPARC_H 356206Sab196087 366206Sab196087 #include <link.h> 376206Sab196087 #include <sys/machelf.h> 386206Sab196087 396206Sab196087 #ifdef __cplusplus 406206Sab196087 extern "C" { 416206Sab196087 #endif 426206Sab196087 436206Sab196087 /* 446206Sab196087 * Elf header information. 456206Sab196087 */ 466206Sab196087 #define M_MACH_32 EM_SPARC 476206Sab196087 #define M_MACH_64 EM_SPARCV9 486206Sab196087 496206Sab196087 #ifdef _ELF64 506206Sab196087 #define M_MACH EM_SPARCV9 516206Sab196087 #define M_CLASS ELFCLASS64 526206Sab196087 #else 536206Sab196087 #define M_MACH EM_SPARC 546206Sab196087 #define M_CLASS ELFCLASS32 556206Sab196087 #endif 566206Sab196087 #define M_MACHPLUS EM_SPARC32PLUS 576206Sab196087 #define M_DATA ELFDATA2MSB 586206Sab196087 #define M_FLAGSPLUS EF_SPARC_32PLUS 596206Sab196087 606206Sab196087 /* 616206Sab196087 * Page boundary Macros: truncate to previous page boundary and round to 626206Sab196087 * next page boundary (refer to generic macros in ../sgs.h also). 636206Sab196087 */ 646206Sab196087 #define M_PTRUNC(X) ((X) & ~(syspagsz - 1)) 656206Sab196087 #define M_PROUND(X) (((X) + syspagsz - 1) & ~(syspagsz - 1)) 666206Sab196087 676206Sab196087 /* 686206Sab196087 * Segment boundary macros: truncate to previous segment boundary and round 696206Sab196087 * to next page boundary. 706206Sab196087 */ 716206Sab196087 #ifndef M_SEGSIZE 726206Sab196087 #define M_SEGSIZE ELF_SPARC_MAXPGSZ 736206Sab196087 #endif 746206Sab196087 #define M_STRUNC(X) ((X) & ~(M_SEGSIZE - 1)) 756206Sab196087 #define M_SROUND(X) (((X) + M_SEGSIZE - 1) & ~(M_SEGSIZE - 1)) 766206Sab196087 776206Sab196087 786206Sab196087 /* 796206Sab196087 * TLS static segments must be rounded to the following requirements, 806206Sab196087 * due to libthread stack allocation. 816206Sab196087 */ 826206Sab196087 #if defined(_ELF64) 836206Sab196087 #define M_TLSSTATALIGN 0x10 846206Sab196087 #else 856206Sab196087 #define M_TLSSTATALIGN 0x08 866206Sab196087 #endif 876206Sab196087 886206Sab196087 896206Sab196087 /* 906206Sab196087 * Instruction encodings. 916206Sab196087 */ 926206Sab196087 #define M_SAVESP64 0x9de3bfc0 /* save %sp, -64, %sp */ 936206Sab196087 #define M_CALL 0x40000000 946206Sab196087 #define M_JMPL 0x81c06000 /* jmpl %g1 + simm13, %g0 */ 956206Sab196087 #define M_SETHIG0 0x01000000 /* sethi %hi(val), %g0 */ 966206Sab196087 #define M_SETHIG1 0x03000000 /* sethi %hi(val), %g1 */ 976206Sab196087 #define M_STO7G1IM 0xde206000 /* st %o7,[%g1 + %lo(val)] */ 986206Sab196087 #define M_SUBFPSPG1 0x8227800e /* sub %fp,%sp,%g1 */ 996206Sab196087 #define M_NOP 0x01000000 /* sethi 0, %o0 (nop) */ 1006206Sab196087 #define M_BA_A 0x30800000 /* ba,a */ 1016206Sab196087 #define M_BA_A_PT 0x30480000 /* ba,a %icc, <dst> */ 1026206Sab196087 #define M_MOVO7TOG1 0x8210000f /* mov %o7, %g1 */ 1036206Sab196087 #define M_MOVO7TOG5 0x8a10000f /* mov %o7, %g5 */ 1046206Sab196087 #define M_MOVI7TOG1 0x8210001f /* mov %i7, %g1 */ 1056206Sab196087 #define M_BA_A_XCC 0x30680000 /* ba,a %xcc */ 1066206Sab196087 #define M_JMPL_G5G0 0x81c16000 /* jmpl %g5 + 0, %g0 */ 1076206Sab196087 #define M_XNOR_G5G1 0x82396000 /* xnor %g5, 0, %g1 */ 1086206Sab196087 1096206Sab196087 1106206Sab196087 #define M_BIND_ADJ 4 /* adjustment for end of */ 1116206Sab196087 /* elf_rtbndr() address */ 1126206Sab196087 1136206Sab196087 1146206Sab196087 /* 1156206Sab196087 * Plt and Got information; the first few .got and .plt entries are reserved 1166206Sab196087 * PLT[0] jump to dynamic linker 1176206Sab196087 * GOT[0] address of _DYNAMIC 1186206Sab196087 */ 1196206Sab196087 #define M_PLT_INSSIZE 4 /* single plt instruction size */ 1206206Sab196087 #define M_GOT_XDYNAMIC 0 /* got index for _DYNAMIC */ 1216206Sab196087 #define M_GOT_XNumber 1 /* reserved no. of got entries */ 1226206Sab196087 1236206Sab196087 /* 1246206Sab196087 * ELF32 bit PLT constants 1256206Sab196087 */ 1266206Sab196087 #define M32_PLT_ENTSIZE 12 /* 32bit plt entry size in bytes */ 1276206Sab196087 1286206Sab196087 /* 1296206Sab196087 * ELF64 bit PLT constants 1306206Sab196087 */ 1316206Sab196087 #define M64_PLT_NEARPLTS 0x8000 /* # of NEAR PLTS we can have */ 1326206Sab196087 #define M64_PLT_ENTSIZE 32 /* plt entry size in bytes */ 1336206Sab196087 #define M64_PLT_FENTSIZE 24 /* size of far plt is 6 instructions */ 1346206Sab196087 /* x 4bytes */ 1356206Sab196087 #define M64_PLT_PSIZE 8 /* size of PLTP pointer */ 1366206Sab196087 #define M64_PLT_FBLKCNTS 160 /* # of plts in far PLT blocks */ 1376206Sab196087 #define M64_PLT_FBLOCKSZ (M64_PLT_FBLKCNTS *\ 1386206Sab196087 M64_PLT_ENTSIZE) /* size of far PLT block */ 1396206Sab196087 1406206Sab196087 1416206Sab196087 #ifdef _ELF64 1426206Sab196087 #define M_PLT_ENTSIZE M64_PLT_ENTSIZE /* plt entry size in bytes */ 1436206Sab196087 #define M_PLT_XNumber 4 /* reserved no. of plt entries */ 1446206Sab196087 #define M_PLT_ALIGN 256 /* alignment of .plt section */ 1456206Sab196087 #define M_PLT_RESERVSZ (M_PLT_XNumber * \ 1466206Sab196087 M_PLT_ENTSIZE) /* first 4 plt's reserved */ 1476206Sab196087 #define M_GOT_ENTSIZE 8 /* got entry size in bytes */ 1486206Sab196087 #define M_GOT_MAXSMALL 1024 /* maximum no. of small gots */ 1496206Sab196087 #else /* Elf32 */ 1506206Sab196087 #define M_PLT_ENTSIZE M32_PLT_ENTSIZE /* plt entry size in bytes */ 1516206Sab196087 #define M_PLT_XNumber 4 /* reserved no. of plt entries */ 1526206Sab196087 #define M_PLT_ALIGN M_WORD_ALIGN /* alignment of .plt section */ 1536206Sab196087 #define M_PLT_RESERVSZ (M_PLT_XNumber * \ 1546206Sab196087 M_PLT_ENTSIZE) /* first 4 plt's reserved */ 1556206Sab196087 #define M_GOT_ENTSIZE 4 /* got entry size in bytes */ 1566206Sab196087 #define M_GOT_MAXSMALL 2048 /* maximum no. of small gots */ 1576206Sab196087 #endif /* _ELF64 */ 1586206Sab196087 /* transition flags for got sizing */ 1596206Sab196087 #define M_GOT_LARGE (Sword)(-M_GOT_MAXSMALL - 1) 1606206Sab196087 #define M_GOT_SMALL (Sword)(-M_GOT_MAXSMALL - 2) 1616206Sab196087 #define M_GOT_MIXED (Sword)(-M_GOT_MAXSMALL - 3) 1626206Sab196087 1636206Sab196087 1646206Sab196087 /* 1656206Sab196087 * Other machine dependent entities 1666206Sab196087 */ 1676206Sab196087 #ifdef _ELF64 1686206Sab196087 #define M_SEGM_ALIGN ELF_SPARCV9_MAXPGSZ 1696206Sab196087 /* 170*8501SRod.Evans@Sun.COM * Put default 64-bit programs above 4 gigabytes to help insure correctness, so 171*8501SRod.Evans@Sun.COM * that any 64-bit programs that truncate pointers will fault now instead of 172*8501SRod.Evans@Sun.COM * corrupting itself and dying mysteriously. 64-bit programs can also be 173*8501SRod.Evans@Sun.COM * restricted to a 32-bit address space (SF1_SUNW_ADDR32), and these programs 174*8501SRod.Evans@Sun.COM * provide an alternative origin. 1756206Sab196087 */ 176*8501SRod.Evans@Sun.COM #define M_SEGM_ORIGIN (Addr)0x100000000ULL /* default 1st segment origin */ 177*8501SRod.Evans@Sun.COM #define M_SEGM_AORIGIN (Addr)0x100000ULL /* alternative 1st segment */ 178*8501SRod.Evans@Sun.COM /* origin */ 1796206Sab196087 #define M_WORD_ALIGN 8 1806206Sab196087 #else 1816206Sab196087 #define M_SEGM_ALIGN ELF_SPARC_MAXPGSZ 182*8501SRod.Evans@Sun.COM #define M_SEGM_ORIGIN (Addr)0x10000 /* default 1st segment origin */ 183*8501SRod.Evans@Sun.COM #define M_SEGM_AORIGIN M_SEGM_ORIGIN /* alternative 1st segment */ 184*8501SRod.Evans@Sun.COM /* origin */ 1856206Sab196087 #define M_WORD_ALIGN 4 1866206Sab196087 #endif 1876206Sab196087 1886206Sab196087 /* 1896206Sab196087 * Make common relocation information transparent to the common code 1906206Sab196087 */ 1916206Sab196087 #define M_REL_DT_TYPE DT_RELA /* .dynamic entry */ 1926206Sab196087 #define M_REL_DT_SIZE DT_RELASZ /* .dynamic entry */ 1936206Sab196087 #define M_REL_DT_ENT DT_RELAENT /* .dynamic entry */ 1946206Sab196087 #define M_REL_DT_COUNT DT_RELACOUNT /* .dynamic entry */ 1956206Sab196087 #define M_REL_SHT_TYPE SHT_RELA /* section header type */ 1966206Sab196087 #define M_REL_ELF_TYPE ELF_T_RELA /* data buffer type */ 1976206Sab196087 1986206Sab196087 /* 1996206Sab196087 * Make common relocation types transparent to the common code 2006206Sab196087 */ 2016206Sab196087 #define M_R_NONE R_SPARC_NONE 2026206Sab196087 #define M_R_GLOB_DAT R_SPARC_GLOB_DAT 2036206Sab196087 #define M_R_COPY R_SPARC_COPY 2046206Sab196087 #define M_R_RELATIVE R_SPARC_RELATIVE 2056206Sab196087 #define M_R_JMP_SLOT R_SPARC_JMP_SLOT 2066206Sab196087 #define M_R_REGISTER R_SPARC_REGISTER 2076206Sab196087 #define M_R_FPTR R_SPARC_NONE 2086206Sab196087 #define M_R_NUM R_SPARC_NUM 2096206Sab196087 2106206Sab196087 #ifdef _ELF64 2116206Sab196087 #define M_R_ARRAYADDR R_SPARC_64 2126206Sab196087 #define M_R_DTPMOD R_SPARC_TLS_DTPMOD64 2136206Sab196087 #define M_R_DTPOFF R_SPARC_TLS_DTPOFF64 2146206Sab196087 #define M_R_TPOFF R_SPARC_TLS_TPOFF64 2156206Sab196087 #else /* _ELF32 */ 2166206Sab196087 #define M_R_ARRAYADDR R_SPARC_32 2176206Sab196087 #define M_R_DTPMOD R_SPARC_TLS_DTPMOD32 2186206Sab196087 #define M_R_DTPOFF R_SPARC_TLS_DTPOFF32 2196206Sab196087 #define M_R_TPOFF R_SPARC_TLS_TPOFF32 2206206Sab196087 #endif /* _ELF64 */ 2216206Sab196087 2226206Sab196087 2236206Sab196087 /* 2246206Sab196087 * Make register symbols transparent to common code 2256206Sab196087 */ 2266206Sab196087 #define M_DT_REGISTER DT_SPARC_REGISTER 2276206Sab196087 2286206Sab196087 /* 2296206Sab196087 * Make plt section information transparent to the common code. 2306206Sab196087 */ 2316206Sab196087 #define M_PLT_SHF_FLAGS (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR) 2326206Sab196087 2336206Sab196087 /* 2346206Sab196087 * Make data segment information transparent to the common code. 2356206Sab196087 */ 2366206Sab196087 #define M_DATASEG_PERM (PF_R | PF_W | PF_X) 2376206Sab196087 2386206Sab196087 /* 2396206Sab196087 * Define a set of identifies for special sections. These allow the sections 2406206Sab196087 * to be ordered within the output file image. These values should be 2416206Sab196087 * maintained consistently, where appropriate, in each platform specific header 2426206Sab196087 * file. 2436206Sab196087 * 2446206Sab196087 * o null identifies that this section does not need to be added to the 2456206Sab196087 * output image (ie. shared object sections or sections we're going to 2466206Sab196087 * recreate (sym tables, string tables, relocations, etc.)). 2476206Sab196087 * 2486206Sab196087 * o any user defined section will be first in the associated segment. 2496206Sab196087 * 2506206Sab196087 * o interp and capabilities sections are next, as these are accessed 2516206Sab196087 * immediately the first page of the image is mapped. 2526206Sab196087 * 2536206Sab196087 * o the syminfo, hash, dynsym, dynstr and rel's are grouped together as 2546206Sab196087 * these will all be accessed first by ld.so.1 to perform relocations. 2556206Sab196087 * 2566206Sab196087 * o the got, dynamic, and plt are grouped together as these may also be 2576206Sab196087 * accessed first by ld.so.1 to perform relocations, fill in DT_DEBUG 2586206Sab196087 * (executables only), and .plt[0]. 2596206Sab196087 * 2606206Sab196087 * o unknown sections (stabs, comments etc.) go at the end. 2616206Sab196087 * 2626206Sab196087 * Note that .tlsbss/.bss are given the largest identifiers. This insures that 2636206Sab196087 * if any unknown sections become associated to the same segment as the .bss, 2646206Sab196087 * the .bss sections are always the last section in the segment. 2656206Sab196087 */ 2666206Sab196087 #define M_ID_NULL 0x00 2676206Sab196087 #define M_ID_USER 0x01 2686206Sab196087 2696206Sab196087 #define M_ID_INTERP 0x02 /* SHF_ALLOC */ 2706206Sab196087 #define M_ID_CAP 0x03 2716206Sab196087 #define M_ID_SYMINFO 0x04 2726206Sab196087 #define M_ID_HASH 0x05 2736206Sab196087 #define M_ID_LDYNSYM 0x06 /* always right before DYNSYM */ 2746206Sab196087 #define M_ID_DYNSYM 0x07 2756206Sab196087 #define M_ID_DYNSTR 0x08 2766206Sab196087 #define M_ID_VERSION 0x09 2776206Sab196087 #define M_ID_DYNSORT 0x0a 2786206Sab196087 #define M_ID_REL 0x0b 2796206Sab196087 #define M_ID_TEXT 0x0c /* SHF_ALLOC + SHF_EXECINSTR */ 2806206Sab196087 #define M_ID_DATA 0x0d 2816206Sab196087 2826206Sab196087 /* M_ID_USER 0x01 dual entry - listed above */ 2836206Sab196087 #define M_ID_GOTDATA 0x02 /* SHF_ALLOC + SHF_WRITE */ 2846206Sab196087 #define M_ID_GOT 0x03 2856206Sab196087 #define M_ID_PLT 0x04 2866206Sab196087 #define M_ID_DYNAMIC 0x05 2876206Sab196087 #define M_ID_ARRAY 0x06 2886206Sab196087 2896206Sab196087 #define M_ID_UNKNOWN 0xfc /* just before TLS */ 2906206Sab196087 2916206Sab196087 #define M_ID_TLS 0xfd /* just before bss */ 2926206Sab196087 #define M_ID_TLSBSS 0xfe 2936206Sab196087 #define M_ID_BSS 0xff 2946206Sab196087 2956206Sab196087 #define M_ID_SYMTAB_NDX 0x02 /* ! SHF_ALLOC */ 2966206Sab196087 #define M_ID_SYMTAB 0x03 2976206Sab196087 #define M_ID_STRTAB 0x04 2986206Sab196087 #define M_ID_DYNSYM_NDX 0x05 2996206Sab196087 #define M_ID_NOTE 0x06 3006206Sab196087 3016206Sab196087 3026206Sab196087 #ifdef __cplusplus 3036206Sab196087 } 3046206Sab196087 #endif 3056206Sab196087 3066206Sab196087 #endif /* _MACHDEP_SPARC_H */ 307