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 * 2611734SAli.Bahrami@Sun.COM * Copyright 2010 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 778598SRod.Evans@Sun.COM /* 788598SRod.Evans@Sun.COM * Relocation type macro. 798598SRod.Evans@Sun.COM */ 808598SRod.Evans@Sun.COM #define M_RELOC Rela 816206Sab196087 826206Sab196087 /* 836206Sab196087 * TLS static segments must be rounded to the following requirements, 846206Sab196087 * due to libthread stack allocation. 856206Sab196087 */ 866206Sab196087 #if defined(_ELF64) 876206Sab196087 #define M_TLSSTATALIGN 0x10 886206Sab196087 #else 896206Sab196087 #define M_TLSSTATALIGN 0x08 906206Sab196087 #endif 916206Sab196087 926206Sab196087 /* 936206Sab196087 * Instruction encodings. 946206Sab196087 */ 956206Sab196087 #define M_SAVESP64 0x9de3bfc0 /* save %sp, -64, %sp */ 966206Sab196087 #define M_CALL 0x40000000 976206Sab196087 #define M_JMPL 0x81c06000 /* jmpl %g1 + simm13, %g0 */ 986206Sab196087 #define M_SETHIG0 0x01000000 /* sethi %hi(val), %g0 */ 996206Sab196087 #define M_SETHIG1 0x03000000 /* sethi %hi(val), %g1 */ 1006206Sab196087 #define M_STO7G1IM 0xde206000 /* st %o7,[%g1 + %lo(val)] */ 1016206Sab196087 #define M_SUBFPSPG1 0x8227800e /* sub %fp,%sp,%g1 */ 1026206Sab196087 #define M_NOP 0x01000000 /* sethi 0, %o0 (nop) */ 1036206Sab196087 #define M_BA_A 0x30800000 /* ba,a */ 1046206Sab196087 #define M_BA_A_PT 0x30480000 /* ba,a %icc, <dst> */ 1056206Sab196087 #define M_MOVO7TOG1 0x8210000f /* mov %o7, %g1 */ 1066206Sab196087 #define M_MOVO7TOG5 0x8a10000f /* mov %o7, %g5 */ 1076206Sab196087 #define M_MOVI7TOG1 0x8210001f /* mov %i7, %g1 */ 1086206Sab196087 #define M_BA_A_XCC 0x30680000 /* ba,a %xcc */ 1096206Sab196087 #define M_JMPL_G5G0 0x81c16000 /* jmpl %g5 + 0, %g0 */ 1106206Sab196087 #define M_XNOR_G5G1 0x82396000 /* xnor %g5, 0, %g1 */ 1116206Sab196087 1126206Sab196087 1136206Sab196087 #define M_BIND_ADJ 4 /* adjustment for end of */ 1146206Sab196087 /* elf_rtbndr() address */ 1156206Sab196087 11610201SEdward.Pilatowicz@Sun.COM /* transition flags for got sizing */ 1176206Sab196087 #define M_GOT_LARGE (Sword)(-M_GOT_MAXSMALL - 1) 1186206Sab196087 #define M_GOT_SMALL (Sword)(-M_GOT_MAXSMALL - 2) 1196206Sab196087 #define M_GOT_MIXED (Sword)(-M_GOT_MAXSMALL - 3) 1206206Sab196087 1216206Sab196087 /* 1226206Sab196087 * Other machine dependent entities 1236206Sab196087 */ 1246206Sab196087 #ifdef _ELF64 1256206Sab196087 #define M_SEGM_ALIGN ELF_SPARCV9_MAXPGSZ 1266206Sab196087 /* 1278501SRod.Evans@Sun.COM * Put default 64-bit programs above 4 gigabytes to help insure correctness, so 1288501SRod.Evans@Sun.COM * that any 64-bit programs that truncate pointers will fault now instead of 1298501SRod.Evans@Sun.COM * corrupting itself and dying mysteriously. 64-bit programs can also be 1308501SRod.Evans@Sun.COM * restricted to a 32-bit address space (SF1_SUNW_ADDR32), and these programs 1318501SRod.Evans@Sun.COM * provide an alternative origin. 1326206Sab196087 */ 1338501SRod.Evans@Sun.COM #define M_SEGM_ORIGIN (Addr)0x100000000ULL /* default 1st segment origin */ 1348501SRod.Evans@Sun.COM #define M_SEGM_AORIGIN (Addr)0x100000ULL /* alternative 1st segment */ 1358501SRod.Evans@Sun.COM /* origin */ 1366206Sab196087 #else 1376206Sab196087 #define M_SEGM_ALIGN ELF_SPARC_MAXPGSZ 1388501SRod.Evans@Sun.COM #define M_SEGM_ORIGIN (Addr)0x10000 /* default 1st segment origin */ 1398501SRod.Evans@Sun.COM #define M_SEGM_AORIGIN M_SEGM_ORIGIN /* alternative 1st segment */ 1408501SRod.Evans@Sun.COM /* origin */ 1416206Sab196087 #endif 1426206Sab196087 1436206Sab196087 /* 1446206Sab196087 * Make common relocation information transparent to the common code 1456206Sab196087 */ 1466206Sab196087 #define M_REL_DT_TYPE DT_RELA /* .dynamic entry */ 1476206Sab196087 #define M_REL_DT_SIZE DT_RELASZ /* .dynamic entry */ 1486206Sab196087 #define M_REL_DT_ENT DT_RELAENT /* .dynamic entry */ 1496206Sab196087 #define M_REL_DT_COUNT DT_RELACOUNT /* .dynamic entry */ 1506206Sab196087 #define M_REL_SHT_TYPE SHT_RELA /* section header type */ 1516206Sab196087 #define M_REL_ELF_TYPE ELF_T_RELA /* data buffer type */ 1526206Sab196087 1536206Sab196087 /* 1546206Sab196087 * Make common relocation types transparent to the common code 1556206Sab196087 */ 1566206Sab196087 #define M_R_NONE R_SPARC_NONE 1576206Sab196087 #define M_R_GLOB_DAT R_SPARC_GLOB_DAT 1586206Sab196087 #define M_R_COPY R_SPARC_COPY 1596206Sab196087 #define M_R_RELATIVE R_SPARC_RELATIVE 1606206Sab196087 #define M_R_JMP_SLOT R_SPARC_JMP_SLOT 1616206Sab196087 #define M_R_REGISTER R_SPARC_REGISTER 1626206Sab196087 #define M_R_FPTR R_SPARC_NONE 1636206Sab196087 #define M_R_NUM R_SPARC_NUM 1646206Sab196087 1656206Sab196087 #ifdef _ELF64 1666206Sab196087 #define M_R_ARRAYADDR R_SPARC_64 1676206Sab196087 #define M_R_DTPMOD R_SPARC_TLS_DTPMOD64 1686206Sab196087 #define M_R_DTPOFF R_SPARC_TLS_DTPOFF64 1696206Sab196087 #define M_R_TPOFF R_SPARC_TLS_TPOFF64 1706206Sab196087 #else /* _ELF32 */ 1716206Sab196087 #define M_R_ARRAYADDR R_SPARC_32 1726206Sab196087 #define M_R_DTPMOD R_SPARC_TLS_DTPMOD32 1736206Sab196087 #define M_R_DTPOFF R_SPARC_TLS_DTPOFF32 1746206Sab196087 #define M_R_TPOFF R_SPARC_TLS_TPOFF32 1756206Sab196087 #endif /* _ELF64 */ 1766206Sab196087 1776206Sab196087 1786206Sab196087 /* 1796206Sab196087 * Make register symbols transparent to common code 1806206Sab196087 */ 1816206Sab196087 #define M_DT_REGISTER DT_SPARC_REGISTER 1826206Sab196087 1836206Sab196087 /* 1846206Sab196087 * Make plt section information transparent to the common code. 1856206Sab196087 */ 1866206Sab196087 #define M_PLT_SHF_FLAGS (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR) 1876206Sab196087 1886206Sab196087 /* 18911734SAli.Bahrami@Sun.COM * Make default data segment and stack flags transparent to the common code. 1906206Sab196087 */ 1916206Sab196087 #define M_DATASEG_PERM (PF_R | PF_W | PF_X) 19211734SAli.Bahrami@Sun.COM #ifdef _ELF64 19311734SAli.Bahrami@Sun.COM #define M_STACK_PERM (PF_R | PF_W) 19411734SAli.Bahrami@Sun.COM #else 19511734SAli.Bahrami@Sun.COM #define M_STACK_PERM (PF_R | PF_W | PF_X) 19611734SAli.Bahrami@Sun.COM #endif 19711734SAli.Bahrami@Sun.COM 1986206Sab196087 1996206Sab196087 /* 2006206Sab196087 * Define a set of identifies for special sections. These allow the sections 2016206Sab196087 * to be ordered within the output file image. These values should be 2026206Sab196087 * maintained consistently, where appropriate, in each platform specific header 2036206Sab196087 * file. 2046206Sab196087 * 2056206Sab196087 * o null identifies that this section does not need to be added to the 2066206Sab196087 * output image (ie. shared object sections or sections we're going to 2076206Sab196087 * recreate (sym tables, string tables, relocations, etc.)). 2086206Sab196087 * 2096206Sab196087 * o any user defined section will be first in the associated segment. 2106206Sab196087 * 2116206Sab196087 * o interp and capabilities sections are next, as these are accessed 2126206Sab196087 * immediately the first page of the image is mapped. 2136206Sab196087 * 2146206Sab196087 * o the syminfo, hash, dynsym, dynstr and rel's are grouped together as 2156206Sab196087 * these will all be accessed first by ld.so.1 to perform relocations. 2166206Sab196087 * 2176206Sab196087 * o the got, dynamic, and plt are grouped together as these may also be 2186206Sab196087 * accessed first by ld.so.1 to perform relocations, fill in DT_DEBUG 2196206Sab196087 * (executables only), and .plt[0]. 2206206Sab196087 * 2216206Sab196087 * o unknown sections (stabs, comments etc.) go at the end. 2226206Sab196087 * 2236206Sab196087 * Note that .tlsbss/.bss are given the largest identifiers. This insures that 2246206Sab196087 * if any unknown sections become associated to the same segment as the .bss, 2256206Sab196087 * the .bss sections are always the last section in the segment. 2266206Sab196087 */ 2276206Sab196087 #define M_ID_NULL 0x00 2286206Sab196087 #define M_ID_USER 0x01 2296206Sab196087 2306206Sab196087 #define M_ID_INTERP 0x02 /* SHF_ALLOC */ 2316206Sab196087 #define M_ID_CAP 0x03 232*11827SRod.Evans@Sun.COM 2339085SAli.Bahrami@Sun.COM #define M_ID_UNWINDHDR 0x06 2349085SAli.Bahrami@Sun.COM #define M_ID_UNWIND 0x07 235*11827SRod.Evans@Sun.COM #define M_ID_CAPINFO 0x08 236*11827SRod.Evans@Sun.COM #define M_ID_CAPCHAIN 0x09 237*11827SRod.Evans@Sun.COM #define M_ID_SYMINFO 0x0a 238*11827SRod.Evans@Sun.COM #define M_ID_HASH 0x0b 239*11827SRod.Evans@Sun.COM #define M_ID_LDYNSYM 0x0c /* always right before DYNSYM */ 240*11827SRod.Evans@Sun.COM #define M_ID_DYNSYM 0x0d 241*11827SRod.Evans@Sun.COM #define M_ID_DYNSTR 0x0e 242*11827SRod.Evans@Sun.COM #define M_ID_VERSION 0x0f 243*11827SRod.Evans@Sun.COM #define M_ID_DYNSORT 0x10 244*11827SRod.Evans@Sun.COM #define M_ID_REL 0x11 245*11827SRod.Evans@Sun.COM #define M_ID_TEXT 0x12 /* SHF_ALLOC + SHF_EXECINSTR */ 2469085SAli.Bahrami@Sun.COM #define M_ID_DATA 0x20 2476206Sab196087 2486206Sab196087 /* M_ID_USER 0x01 dual entry - listed above */ 2496206Sab196087 #define M_ID_GOTDATA 0x02 /* SHF_ALLOC + SHF_WRITE */ 2506206Sab196087 #define M_ID_GOT 0x03 2516206Sab196087 #define M_ID_PLT 0x04 2526206Sab196087 #define M_ID_DYNAMIC 0x05 2536206Sab196087 #define M_ID_ARRAY 0x06 2549085SAli.Bahrami@Sun.COM /* M_ID_UNWIND 0x07 dual entry - listed above */ 2556206Sab196087 2566206Sab196087 #define M_ID_UNKNOWN 0xfc /* just before TLS */ 2576206Sab196087 2586206Sab196087 #define M_ID_TLS 0xfd /* just before bss */ 2596206Sab196087 #define M_ID_TLSBSS 0xfe 2606206Sab196087 #define M_ID_BSS 0xff 2616206Sab196087 2626206Sab196087 #define M_ID_SYMTAB_NDX 0x02 /* ! SHF_ALLOC */ 2636206Sab196087 #define M_ID_SYMTAB 0x03 2646206Sab196087 #define M_ID_STRTAB 0x04 2656206Sab196087 #define M_ID_DYNSYM_NDX 0x05 2666206Sab196087 #define M_ID_NOTE 0x06 2676206Sab196087 2686206Sab196087 2696206Sab196087 #ifdef __cplusplus 2706206Sab196087 } 2716206Sab196087 #endif 2726206Sab196087 2736206Sab196087 #endif /* _MACHDEP_SPARC_H */ 274