198b9484cSchristos /* SPARC ELF support for BFD. 2*02f41505Schristos Copyright (C) 1996-2024 Free Software Foundation, Inc. 398b9484cSchristos By Doug Evans, Cygnus Support, <dje@cygnus.com>. 498b9484cSchristos 598b9484cSchristos This file is part of BFD, the Binary File Descriptor library. 698b9484cSchristos 798b9484cSchristos This program is free software; you can redistribute it and/or modify 898b9484cSchristos it under the terms of the GNU General Public License as published by 998b9484cSchristos the Free Software Foundation; either version 3 of the License, or 1098b9484cSchristos (at your option) any later version. 1198b9484cSchristos 1298b9484cSchristos This program is distributed in the hope that it will be useful, 1398b9484cSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1498b9484cSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1598b9484cSchristos GNU General Public License for more details. 1698b9484cSchristos 1798b9484cSchristos You should have received a copy of the GNU General Public License 1898b9484cSchristos along with this program; if not, write to the Free Software 1998b9484cSchristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 2098b9484cSchristos MA 02110-1301, USA. */ 2198b9484cSchristos 2298b9484cSchristos #ifndef _ELF_SPARC_H 2398b9484cSchristos #define _ELF_SPARC_H 2498b9484cSchristos 2598b9484cSchristos /* Processor specific flags for the ELF header e_flags field. */ 2698b9484cSchristos 2798b9484cSchristos /* These are defined by Sun. */ 2898b9484cSchristos 2998b9484cSchristos #define EF_SPARC_32PLUS_MASK 0xffff00 /* bits indicating V8+ type */ 3098b9484cSchristos #define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ 3198b9484cSchristos #define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ 3298b9484cSchristos #define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ 3398b9484cSchristos #define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ 3498b9484cSchristos 3598b9484cSchristos #define EF_SPARC_LEDATA 0x800000 /* little endian data */ 3698b9484cSchristos 3798b9484cSchristos /* This name is used in the V9 ABI. */ 3898b9484cSchristos #define EF_SPARC_EXT_MASK 0xffff00 /* reserved for vendor extensions */ 3998b9484cSchristos 4098b9484cSchristos /* V9 memory models */ 4198b9484cSchristos #define EF_SPARCV9_MM 0x3 /* memory model mask */ 4298b9484cSchristos #define EF_SPARCV9_TSO 0x0 /* total store ordering */ 4398b9484cSchristos #define EF_SPARCV9_PSO 0x1 /* partial store ordering */ 4498b9484cSchristos #define EF_SPARCV9_RMO 0x2 /* relaxed store ordering */ 4598b9484cSchristos 4698b9484cSchristos /* Section indices. */ 4798b9484cSchristos 4898b9484cSchristos #define SHN_BEFORE SHN_LORESERVE /* Used with SHF_ORDERED and... */ 4998b9484cSchristos #define SHN_AFTER (SHN_LORESERVE + 1) /* SHF_LINK_ORDER section flags. */ 5098b9484cSchristos 5198b9484cSchristos /* Section flags. */ 5298b9484cSchristos 5398b9484cSchristos #define SHF_ORDERED 0x40000000 /* treat sh_link,sh_info specially */ 5498b9484cSchristos 5598b9484cSchristos /* Symbol types. */ 5698b9484cSchristos 5798b9484cSchristos #define STT_REGISTER 13 /* global reg reserved to app. */ 5898b9484cSchristos 5998b9484cSchristos #include "elf/reloc-macros.h" 6098b9484cSchristos 6198b9484cSchristos /* Relocation types. */ 6298b9484cSchristos START_RELOC_NUMBERS (elf_sparc_reloc_type) 6398b9484cSchristos RELOC_NUMBER (R_SPARC_NONE, 0) 6498b9484cSchristos RELOC_NUMBER (R_SPARC_8, 1) 6598b9484cSchristos RELOC_NUMBER (R_SPARC_16, 2) 6698b9484cSchristos RELOC_NUMBER (R_SPARC_32, 3) 6798b9484cSchristos RELOC_NUMBER (R_SPARC_DISP8, 4) 6898b9484cSchristos RELOC_NUMBER (R_SPARC_DISP16, 5) 6998b9484cSchristos RELOC_NUMBER (R_SPARC_DISP32, 6) 7098b9484cSchristos RELOC_NUMBER (R_SPARC_WDISP30, 7) 7198b9484cSchristos RELOC_NUMBER (R_SPARC_WDISP22, 8) 7298b9484cSchristos RELOC_NUMBER (R_SPARC_HI22, 9) 7398b9484cSchristos RELOC_NUMBER (R_SPARC_22, 10) 7498b9484cSchristos RELOC_NUMBER (R_SPARC_13, 11) 7598b9484cSchristos RELOC_NUMBER (R_SPARC_LO10, 12) 7698b9484cSchristos RELOC_NUMBER (R_SPARC_GOT10, 13) 7798b9484cSchristos RELOC_NUMBER (R_SPARC_GOT13, 14) 7898b9484cSchristos RELOC_NUMBER (R_SPARC_GOT22, 15) 7998b9484cSchristos RELOC_NUMBER (R_SPARC_PC10, 16) 8098b9484cSchristos RELOC_NUMBER (R_SPARC_PC22, 17) 8198b9484cSchristos RELOC_NUMBER (R_SPARC_WPLT30, 18) 8298b9484cSchristos RELOC_NUMBER (R_SPARC_COPY, 19) 8398b9484cSchristos RELOC_NUMBER (R_SPARC_GLOB_DAT, 20) 8498b9484cSchristos RELOC_NUMBER (R_SPARC_JMP_SLOT, 21) 8598b9484cSchristos RELOC_NUMBER (R_SPARC_RELATIVE, 22) 8698b9484cSchristos RELOC_NUMBER (R_SPARC_UA32, 23) 8798b9484cSchristos 8898b9484cSchristos /* ??? These 6 relocs are new but not currently used. For binary 8998b9484cSchristos compatibility in the sparc64-elf toolchain, we leave them out. 9098b9484cSchristos A non-binary upward compatible change is expected for sparc64-elf. */ 9198b9484cSchristos #ifndef SPARC64_OLD_RELOCS 9298b9484cSchristos /* ??? New relocs on the UltraSPARC. Not sure what they're for yet. */ 9398b9484cSchristos RELOC_NUMBER (R_SPARC_PLT32, 24) 9498b9484cSchristos RELOC_NUMBER (R_SPARC_HIPLT22, 25) 9598b9484cSchristos RELOC_NUMBER (R_SPARC_LOPLT10, 26) 9698b9484cSchristos RELOC_NUMBER (R_SPARC_PCPLT32, 27) 9798b9484cSchristos RELOC_NUMBER (R_SPARC_PCPLT22, 28) 9898b9484cSchristos RELOC_NUMBER (R_SPARC_PCPLT10, 29) 9998b9484cSchristos #endif 10098b9484cSchristos 10198b9484cSchristos /* v9 relocs */ 10298b9484cSchristos RELOC_NUMBER (R_SPARC_10, 30) 10398b9484cSchristos RELOC_NUMBER (R_SPARC_11, 31) 10498b9484cSchristos RELOC_NUMBER (R_SPARC_64, 32) 10598b9484cSchristos RELOC_NUMBER (R_SPARC_OLO10, 33) 10698b9484cSchristos RELOC_NUMBER (R_SPARC_HH22, 34) 10798b9484cSchristos RELOC_NUMBER (R_SPARC_HM10, 35) 10898b9484cSchristos RELOC_NUMBER (R_SPARC_LM22, 36) 10998b9484cSchristos RELOC_NUMBER (R_SPARC_PC_HH22, 37) 11098b9484cSchristos RELOC_NUMBER (R_SPARC_PC_HM10, 38) 11198b9484cSchristos RELOC_NUMBER (R_SPARC_PC_LM22, 39) 11298b9484cSchristos RELOC_NUMBER (R_SPARC_WDISP16, 40) 11398b9484cSchristos RELOC_NUMBER (R_SPARC_WDISP19, 41) 11498b9484cSchristos RELOC_NUMBER (R_SPARC_UNUSED_42, 42) 11598b9484cSchristos RELOC_NUMBER (R_SPARC_7, 43) 11698b9484cSchristos RELOC_NUMBER (R_SPARC_5, 44) 11798b9484cSchristos RELOC_NUMBER (R_SPARC_6, 45) 11898b9484cSchristos RELOC_NUMBER (R_SPARC_DISP64, 46) 11998b9484cSchristos RELOC_NUMBER (R_SPARC_PLT64, 47) 12098b9484cSchristos RELOC_NUMBER (R_SPARC_HIX22, 48) 12198b9484cSchristos RELOC_NUMBER (R_SPARC_LOX10, 49) 12298b9484cSchristos RELOC_NUMBER (R_SPARC_H44, 50) 12398b9484cSchristos RELOC_NUMBER (R_SPARC_M44, 51) 12498b9484cSchristos RELOC_NUMBER (R_SPARC_L44, 52) 12598b9484cSchristos RELOC_NUMBER (R_SPARC_REGISTER, 53) 12698b9484cSchristos RELOC_NUMBER (R_SPARC_UA64, 54) 12798b9484cSchristos RELOC_NUMBER (R_SPARC_UA16, 55) 12898b9484cSchristos 12998b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_GD_HI22, 56) 13098b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_GD_LO10, 57) 13198b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_GD_ADD, 58) 13298b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_GD_CALL, 59) 13398b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LDM_HI22, 60) 13498b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LDM_LO10, 61) 13598b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LDM_ADD, 62) 13698b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LDM_CALL, 63) 13798b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LDO_HIX22, 64) 13898b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LDO_LOX10, 65) 13998b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LDO_ADD, 66) 14098b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_IE_HI22, 67) 14198b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_IE_LO10, 68) 14298b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_IE_LD, 69) 14398b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_IE_LDX, 70) 14498b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_IE_ADD, 71) 14598b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LE_HIX22, 72) 14698b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_LE_LOX10, 73) 14798b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_DTPMOD32, 74) 14898b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_DTPMOD64, 75) 14998b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_DTPOFF32, 76) 15098b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_DTPOFF64, 77) 15198b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_TPOFF32, 78) 15298b9484cSchristos RELOC_NUMBER (R_SPARC_TLS_TPOFF64, 79) 15398b9484cSchristos 15498b9484cSchristos RELOC_NUMBER (R_SPARC_GOTDATA_HIX22, 80) 15598b9484cSchristos RELOC_NUMBER (R_SPARC_GOTDATA_LOX10, 81) 15698b9484cSchristos RELOC_NUMBER (R_SPARC_GOTDATA_OP_HIX22, 82) 15798b9484cSchristos RELOC_NUMBER (R_SPARC_GOTDATA_OP_LOX10, 83) 15898b9484cSchristos RELOC_NUMBER (R_SPARC_GOTDATA_OP, 84) 15998b9484cSchristos 16098b9484cSchristos RELOC_NUMBER (R_SPARC_H34, 85) 16198b9484cSchristos RELOC_NUMBER (R_SPARC_SIZE32, 86) 16298b9484cSchristos RELOC_NUMBER (R_SPARC_SIZE64, 87) 163a2e2270fSchristos RELOC_NUMBER (R_SPARC_WDISP10, 88) 16498b9484cSchristos 16598b9484cSchristos EMPTY_RELOC (R_SPARC_max_std) 16698b9484cSchristos 16798b9484cSchristos RELOC_NUMBER (R_SPARC_JMP_IREL, 248) 16898b9484cSchristos RELOC_NUMBER (R_SPARC_IRELATIVE, 249) 16998b9484cSchristos RELOC_NUMBER (R_SPARC_GNU_VTINHERIT, 250) 17098b9484cSchristos RELOC_NUMBER (R_SPARC_GNU_VTENTRY, 251) 17198b9484cSchristos RELOC_NUMBER (R_SPARC_REV32, 252) 17298b9484cSchristos 17398b9484cSchristos END_RELOC_NUMBERS (R_SPARC_max) 17498b9484cSchristos 17598b9484cSchristos /* Relocation macros. */ 17698b9484cSchristos 17798b9484cSchristos #define ELF64_R_TYPE_DATA(info) \ 17898b9484cSchristos (((bfd_signed_vma)(ELF64_R_TYPE(info) >> 8) ^ 0x800000) - 0x800000) 17998b9484cSchristos #define ELF64_R_TYPE_ID(info) \ 18098b9484cSchristos ((info) & 0xff) 18198b9484cSchristos #define ELF64_R_TYPE_INFO(data, type) \ 18298b9484cSchristos (((bfd_vma) ((data) & 0xffffff) << 8) | (bfd_vma) (type)) 18398b9484cSchristos 18498b9484cSchristos /* Values for Elf64_Dyn.d_tag. */ 18598b9484cSchristos 18698b9484cSchristos #define DT_SPARC_REGISTER 0x70000001 18798b9484cSchristos 188a2e2270fSchristos /* Object attribute tags. */ 189a2e2270fSchristos enum 190a2e2270fSchristos { 191a2e2270fSchristos /* 0-3 are generic. */ 192a2e2270fSchristos Tag_GNU_Sparc_HWCAPS = 4, 193968cf8f2Schristos Tag_GNU_Sparc_HWCAPS2 = 8 194a2e2270fSchristos }; 195a2e2270fSchristos 196968cf8f2Schristos /* Generally speaking the ELF_SPARC_HWCAP_* and ELF_SPARC_HWCAP2_* 197968cf8f2Schristos values match the AV_SPARC_* and AV2_SPARC_* bits respectively. 198968cf8f2Schristos 199968cf8f2Schristos However Solaris 11 introduced a backwards-incompatible change 200968cf8f2Schristos deprecating the RANDOM, TRANS and ASI_CACHE_SPARING bits in the 201968cf8f2Schristos AT_SUNW_CAP_HW1 flags, reusing the bits for the unrelated hwcaps 202968cf8f2Schristos FJATHHPC, FJDES and FJAES respectively. In GNU/Linux we opted to 203968cf8f2Schristos keep the old hwcaps in Tag_GNU_Sparc_HWCAPS and allocate bits for 204968cf8f2Schristos FJATHHPC, FJDES and JFAES in Tag_GNU_Sparc_HWCAPS2. */ 205968cf8f2Schristos 206a2e2270fSchristos #define ELF_SPARC_HWCAP_MUL32 0x00000001 /* umul/umulcc/smul/smulcc insns */ 207a2e2270fSchristos #define ELF_SPARC_HWCAP_DIV32 0x00000002 /* udiv/udivcc/sdiv/sdivcc insns */ 208a2e2270fSchristos #define ELF_SPARC_HWCAP_FSMULD 0x00000004 /* 'fsmuld' insn */ 209a2e2270fSchristos #define ELF_SPARC_HWCAP_V8PLUS 0x00000008 /* v9 insns available to 32bit */ 210a2e2270fSchristos #define ELF_SPARC_HWCAP_POPC 0x00000010 /* 'popc' insn */ 211a2e2270fSchristos #define ELF_SPARC_HWCAP_VIS 0x00000020 /* VIS insns */ 212a2e2270fSchristos #define ELF_SPARC_HWCAP_VIS2 0x00000040 /* VIS2 insns */ 213a2e2270fSchristos #define ELF_SPARC_HWCAP_ASI_BLK_INIT \ 214a2e2270fSchristos 0x00000080 /* block init ASIs */ 215a2e2270fSchristos #define ELF_SPARC_HWCAP_FMAF 0x00000100 /* fused multiply-add */ 216a2e2270fSchristos #define ELF_SPARC_HWCAP_VIS3 0x00000400 /* VIS3 insns */ 217a2e2270fSchristos #define ELF_SPARC_HWCAP_HPC 0x00000800 /* HPC insns */ 218a2e2270fSchristos #define ELF_SPARC_HWCAP_RANDOM 0x00001000 /* 'random' insn */ 219a2e2270fSchristos #define ELF_SPARC_HWCAP_TRANS 0x00002000 /* transaction insns */ 220a2e2270fSchristos #define ELF_SPARC_HWCAP_FJFMAU 0x00004000 /* unfused multiply-add */ 221a2e2270fSchristos #define ELF_SPARC_HWCAP_IMA 0x00008000 /* integer multiply-add */ 222a2e2270fSchristos #define ELF_SPARC_HWCAP_ASI_CACHE_SPARING \ 223a2e2270fSchristos 0x00010000 /* cache sparing ASIs */ 224a2e2270fSchristos #define ELF_SPARC_HWCAP_AES 0x00020000 /* AES crypto insns */ 225a2e2270fSchristos #define ELF_SPARC_HWCAP_DES 0x00040000 /* DES crypto insns */ 226a2e2270fSchristos #define ELF_SPARC_HWCAP_KASUMI 0x00080000 /* KASUMI crypto insns */ 227a2e2270fSchristos #define ELF_SPARC_HWCAP_CAMELLIA \ 228a2e2270fSchristos 0x00100000 /* CAMELLIA crypto insns */ 229a2e2270fSchristos #define ELF_SPARC_HWCAP_MD5 0x00200000 /* MD5 hashing insns */ 230a2e2270fSchristos #define ELF_SPARC_HWCAP_SHA1 0x00400000 /* SHA1 hashing insns */ 231a2e2270fSchristos #define ELF_SPARC_HWCAP_SHA256 0x00800000 /* SHA256 hashing insns */ 232a2e2270fSchristos #define ELF_SPARC_HWCAP_SHA512 0x01000000 /* SHA512 hashing insns */ 233a2e2270fSchristos #define ELF_SPARC_HWCAP_MPMUL 0x02000000 /* Multiple Precision Multiply */ 234a2e2270fSchristos #define ELF_SPARC_HWCAP_MONT 0x04000000 /* Montgomery Mult/Sqrt */ 235a2e2270fSchristos #define ELF_SPARC_HWCAP_PAUSE 0x08000000 /* Pause insn */ 236a2e2270fSchristos #define ELF_SPARC_HWCAP_CBCOND 0x10000000 /* Compare and Branch insns */ 237a2e2270fSchristos #define ELF_SPARC_HWCAP_CRC32C 0x20000000 /* CRC32C insn */ 238a2e2270fSchristos 239968cf8f2Schristos #define ELF_SPARC_HWCAP2_FJATHPLUS 0x00000001 /* Fujitsu Athena+ */ 240968cf8f2Schristos #define ELF_SPARC_HWCAP2_VIS3B 0x00000002 /* Subset of VIS3 present on sparc64 X+ */ 241968cf8f2Schristos #define ELF_SPARC_HWCAP2_ADP 0x00000004 /* Application Data Protection */ 242968cf8f2Schristos #define ELF_SPARC_HWCAP2_SPARC5 0x00000008 /* The 29 new fp and sub instructions */ 243968cf8f2Schristos #define ELF_SPARC_HWCAP2_MWAIT 0x00000010 /* mwait instruction and load/monitor ASIs */ 244968cf8f2Schristos #define ELF_SPARC_HWCAP2_XMPMUL 0x00000020 /* XOR multiple precision multiply */ 245968cf8f2Schristos #define ELF_SPARC_HWCAP2_XMONT 0x00000040 /* XOR Montgomery mult/sqr instructions */ 246968cf8f2Schristos #define ELF_SPARC_HWCAP2_NSEC \ 247968cf8f2Schristos 0x00000080 /* pause insn with support for nsec timings */ 248968cf8f2Schristos #define ELF_SPARC_HWCAP2_FJATHHPC 0x00001000 /* Fujitsu HPC instrs */ 249968cf8f2Schristos #define ELF_SPARC_HWCAP2_FJDES 0x00002000 /* Fujitsu DES instrs */ 250968cf8f2Schristos #define ELF_SPARC_HWCAP2_FJAES 0x00010000 /* Fujitsu AES instrs */ 251968cf8f2Schristos 2524559860eSchristos #define ELF_SPARC_HWCAP2_SPARC6 0x00020000 /* OSA2017 new instructions */ 2534559860eSchristos #define ELF_SPARC_HWCAP2_ONADDSUB 0x00040000 /* Oracle Number add/subtract */ 2544559860eSchristos #define ELF_SPARC_HWCAP2_ONMUL 0x00080000 /* Oracle Number multiply */ 2554559860eSchristos #define ELF_SPARC_HWCAP2_ONDIV 0x00100000 /* Oracle Number divide */ 2564559860eSchristos #define ELF_SPARC_HWCAP2_DICTUNP 0x00200000 /* Dictionary unpack instruction */ 2574559860eSchristos #define ELF_SPARC_HWCAP2_FPCMPSHL 0x00400000 /* Partition compare with shifted result */ 2584559860eSchristos #define ELF_SPARC_HWCAP2_RLE 0x00800000 /* Run-length encoded burst and length */ 2594559860eSchristos #define ELF_SPARC_HWCAP2_SHA3 0x01000000 /* SHA3 instruction */ 2604559860eSchristos 26198b9484cSchristos #endif /* _ELF_SPARC_H */ 262