198b9484cSchristos /* MMIX support for BFD. 2*02f41505Schristos Copyright (C) 2001-2024 Free Software Foundation, Inc. 398b9484cSchristos 498b9484cSchristos This file is part of BFD, the Binary File Descriptor library. 598b9484cSchristos 698b9484cSchristos This program is free software; you can redistribute it and/or modify 798b9484cSchristos it under the terms of the GNU General Public License as published by 898b9484cSchristos the Free Software Foundation; either version 3 of the License, or 998b9484cSchristos (at your option) any later version. 1098b9484cSchristos 1198b9484cSchristos This program is distributed in the hope that it will be useful, 1298b9484cSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1398b9484cSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1498b9484cSchristos GNU General Public License for more details. 1598b9484cSchristos 1698b9484cSchristos You should have received a copy of the GNU General Public License 1798b9484cSchristos along with this program; if not, write to the Free Software 1898b9484cSchristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 1998b9484cSchristos MA 02110-1301, USA. */ 2098b9484cSchristos 2198b9484cSchristos /* This file holds definitions specific to the MMIX ELF ABI. */ 2298b9484cSchristos 2398b9484cSchristos #ifndef ELF_MMIX_H 2498b9484cSchristos #define ELF_MMIX_H 2598b9484cSchristos 2698b9484cSchristos #include "elf/reloc-macros.h" 2798b9484cSchristos 2898b9484cSchristos /* Relocations. See the reloc table in bfd/elf64-mmix.c for details. */ 2998b9484cSchristos START_RELOC_NUMBERS (elf_mmix_reloc_type) 3098b9484cSchristos RELOC_NUMBER (R_MMIX_NONE, 0) 3198b9484cSchristos 3298b9484cSchristos /* Standard absolute relocations. */ 3398b9484cSchristos RELOC_NUMBER (R_MMIX_8, 1) 3498b9484cSchristos RELOC_NUMBER (R_MMIX_16, 2) 3598b9484cSchristos RELOC_NUMBER (R_MMIX_24, 3) 3698b9484cSchristos RELOC_NUMBER (R_MMIX_32, 4) 3798b9484cSchristos RELOC_NUMBER (R_MMIX_64, 5) 3898b9484cSchristos 3998b9484cSchristos /* Standard relative relocations. */ 4098b9484cSchristos RELOC_NUMBER (R_MMIX_PC_8, 6) 4198b9484cSchristos RELOC_NUMBER (R_MMIX_PC_16, 7) 4298b9484cSchristos RELOC_NUMBER (R_MMIX_PC_24, 8) 4398b9484cSchristos RELOC_NUMBER (R_MMIX_PC_32, 9) 4498b9484cSchristos RELOC_NUMBER (R_MMIX_PC_64, 10) 4598b9484cSchristos 4698b9484cSchristos /* GNU extensions for C++ vtables. */ 4798b9484cSchristos RELOC_NUMBER (R_MMIX_GNU_VTINHERIT, 11) 4898b9484cSchristos RELOC_NUMBER (R_MMIX_GNU_VTENTRY, 12) 4998b9484cSchristos 5098b9484cSchristos /* A GETA instruction. */ 5198b9484cSchristos RELOC_NUMBER (R_MMIX_GETA, 13) 5298b9484cSchristos RELOC_NUMBER (R_MMIX_GETA_1, 14) 5398b9484cSchristos RELOC_NUMBER (R_MMIX_GETA_2, 15) 5498b9484cSchristos RELOC_NUMBER (R_MMIX_GETA_3, 16) 5598b9484cSchristos 5698b9484cSchristos /* A conditional branch instruction. */ 5798b9484cSchristos RELOC_NUMBER (R_MMIX_CBRANCH, 17) 5898b9484cSchristos RELOC_NUMBER (R_MMIX_CBRANCH_J, 18) 5998b9484cSchristos RELOC_NUMBER (R_MMIX_CBRANCH_1, 19) 6098b9484cSchristos RELOC_NUMBER (R_MMIX_CBRANCH_2, 20) 6198b9484cSchristos RELOC_NUMBER (R_MMIX_CBRANCH_3, 21) 6298b9484cSchristos 6398b9484cSchristos /* A PUSHJ instruction. */ 6498b9484cSchristos RELOC_NUMBER (R_MMIX_PUSHJ, 22) 6598b9484cSchristos RELOC_NUMBER (R_MMIX_PUSHJ_1, 23) 6698b9484cSchristos RELOC_NUMBER (R_MMIX_PUSHJ_2, 24) 6798b9484cSchristos RELOC_NUMBER (R_MMIX_PUSHJ_3, 25) 6898b9484cSchristos 6998b9484cSchristos /* A JMP instruction. */ 7098b9484cSchristos RELOC_NUMBER (R_MMIX_JMP, 26) 7198b9484cSchristos RELOC_NUMBER (R_MMIX_JMP_1, 27) 7298b9484cSchristos RELOC_NUMBER (R_MMIX_JMP_2, 28) 7398b9484cSchristos RELOC_NUMBER (R_MMIX_JMP_3, 29) 7498b9484cSchristos 7598b9484cSchristos /* A relative address such as in a GETA or a branch. */ 7698b9484cSchristos RELOC_NUMBER (R_MMIX_ADDR19, 30) 7798b9484cSchristos 7898b9484cSchristos /* A relative address such as in a JMP (only). */ 7998b9484cSchristos RELOC_NUMBER (R_MMIX_ADDR27, 31) 8098b9484cSchristos 8198b9484cSchristos /* A general register or a number 0..255. */ 8298b9484cSchristos RELOC_NUMBER (R_MMIX_REG_OR_BYTE, 32) 8398b9484cSchristos 8498b9484cSchristos /* A general register. */ 8598b9484cSchristos RELOC_NUMBER (R_MMIX_REG, 33) 8698b9484cSchristos 8798b9484cSchristos /* A global register and an offset, the global register (allocated at 8898b9484cSchristos link time) contents plus the offset made equivalent to the relocation 8998b9484cSchristos expression at link time. The relocation must point at the Y field of 9098b9484cSchristos an instruction. */ 9198b9484cSchristos RELOC_NUMBER (R_MMIX_BASE_PLUS_OFFSET, 34) 9298b9484cSchristos 9398b9484cSchristos /* A LOCAL assertion. */ 9498b9484cSchristos RELOC_NUMBER (R_MMIX_LOCAL, 35) 9598b9484cSchristos 9698b9484cSchristos /* A PUSHJ instruction, generating a stub if it does not reach. */ 9798b9484cSchristos RELOC_NUMBER (R_MMIX_PUSHJ_STUBBABLE, 36) 9898b9484cSchristos END_RELOC_NUMBERS (R_MMIX_max) 9998b9484cSchristos 10098b9484cSchristos 10198b9484cSchristos /* Section Attributes. */ 10298b9484cSchristos /* A section containing necessary information for relaxation. */ 10398b9484cSchristos #define SHF_MMIX_CANRELAX 0x80000000 10498b9484cSchristos 10598b9484cSchristos /* Symbol attributes. */ 10698b9484cSchristos /* A symbol with this section-index is a register. */ 10798b9484cSchristos #define SHN_REGISTER SHN_LOPROC 10898b9484cSchristos 10998b9484cSchristos /* This section holds contents for each initialized register, at VMA 11098b9484cSchristos regno*8. A symbol relative to this section will be transformed to an 11198b9484cSchristos absolute symbol with the value corresponding to the register number at 11298b9484cSchristos final link time. A symbol with a value outside the inclusive range 11398b9484cSchristos 32*8 .. 254*8 is an error. It is highly recommended to only use an 11498b9484cSchristos upper bound of 253*8 or lower as specified in the (currently 11598b9484cSchristos unspecified) ABI. */ 11698b9484cSchristos #define MMIX_REG_CONTENTS_SECTION_NAME ".MMIX.reg_contents" 11798b9484cSchristos 11898b9484cSchristos /* At link time, a section by this name is created, expected to be 11998b9484cSchristos included in MMIX_REG_CONTENTS_SECTION_NAME in the output. */ 12098b9484cSchristos #define MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME \ 12198b9484cSchristos ".MMIX.reg_contents.linker_allocated" 12298b9484cSchristos 12398b9484cSchristos /* This is a faked section holding symbols with SHN_REGISTER. Don't 12498b9484cSchristos confuse it with MMIX_REG_CONTENTS_SECTION_NAME; this one has no 12598b9484cSchristos contents, just values. It is an error for a value in this section to 12698b9484cSchristos be outside the range 32..255 and it must never become an actual section 12798b9484cSchristos in an object file. */ 12898b9484cSchristos #define MMIX_REG_SECTION_NAME "*REG*" 12998b9484cSchristos 13098b9484cSchristos /* Appended with a number N=0..65535, this is a representation of the 13198b9484cSchristos mmixal "BSPEC N" ... "ESPEC" directive pair; the contents go into an 13298b9484cSchristos ELF section by name ".MMIX.spec_data.N". */ 13398b9484cSchristos #define MMIX_OTHER_SPEC_SECTION_PREFIX ".MMIX.spec_data." 13498b9484cSchristos 13598b9484cSchristos /* A section SECNAME is noted to start at "__.MMIX.start.SECNAME" by the 13698b9484cSchristos presence of this symbol. Currently only implemented for ".text" 13798b9484cSchristos through the symbol "__.MMIX.start..text". */ 13898b9484cSchristos #define MMIX_LOC_SECTION_START_SYMBOL_PREFIX "__.MMIX.start." 13998b9484cSchristos 14098b9484cSchristos /* This symbol is always a function. */ 14198b9484cSchristos #define MMIX_START_SYMBOL_NAME "Main" 14298b9484cSchristos 14398b9484cSchristos 14498b9484cSchristos /* We smuggle in a few MMO specifics here. We don't make a specific MMO 14598b9484cSchristos file, since we can't reasonably support MMO without ELF; we have to 14698b9484cSchristos include this file anyway. */ 14798b9484cSchristos 14898b9484cSchristos #define MMO_TEXT_SECTION_NAME ".text" 14998b9484cSchristos #define MMO_DATA_SECTION_NAME ".data" 15098b9484cSchristos 15198b9484cSchristos /* A definition for the flags we put in spec data in files. A copy of our 15298b9484cSchristos own of some flags to keep immune to BFD flag changes. See section.c of 15398b9484cSchristos 2001-07-18 for flag documentation. */ 15498b9484cSchristos #define MMO_SEC_ALLOC 0x001 15598b9484cSchristos #define MMO_SEC_LOAD 0x002 15698b9484cSchristos #define MMO_SEC_RELOC 0x004 15798b9484cSchristos #define MMO_SEC_READONLY 0x010 15898b9484cSchristos #define MMO_SEC_CODE 0x020 15998b9484cSchristos #define MMO_SEC_DATA 0x040 16098b9484cSchristos #define MMO_SEC_NEVER_LOAD 0x400 16198b9484cSchristos #define MMO_SEC_IS_COMMON 0x8000 16298b9484cSchristos #define MMO_SEC_DEBUGGING 0x10000 16398b9484cSchristos 16498b9484cSchristos #ifdef BFD_ARCH_SIZE 1654b169a6bSchristos extern bool _bfd_mmix_before_linker_allocation 16698b9484cSchristos (bfd *, struct bfd_link_info *); 1674b169a6bSchristos extern bool _bfd_mmix_after_linker_allocation 16898b9484cSchristos (bfd *, struct bfd_link_info *); 1694b169a6bSchristos extern bool _bfd_mmix_check_all_relocs 17098b9484cSchristos (bfd *, struct bfd_link_info *); 17198b9484cSchristos #endif 17298b9484cSchristos 17398b9484cSchristos #endif /* ELF_MMIX_H */ 174