xref: /openbsd-src/gnu/usr.bin/binutils/include/elf/mmix.h (revision cf2f2c5620d6d9a4fd01930983c4b9a1f76d7aa3)
1d2201f2fSdrahn /* MMIX support for BFD.
2*cf2f2c56Smiod    Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
3d2201f2fSdrahn 
4d2201f2fSdrahn This file is part of BFD, the Binary File Descriptor library.
5d2201f2fSdrahn 
6d2201f2fSdrahn This program is free software; you can redistribute it and/or modify
7d2201f2fSdrahn it under the terms of the GNU General Public License as published by
8d2201f2fSdrahn the Free Software Foundation; either version 2 of the License, or
9d2201f2fSdrahn (at your option) any later version.
10d2201f2fSdrahn 
11d2201f2fSdrahn This program is distributed in the hope that it will be useful,
12d2201f2fSdrahn but WITHOUT ANY WARRANTY; without even the implied warranty of
13d2201f2fSdrahn MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14d2201f2fSdrahn GNU General Public License for more details.
15d2201f2fSdrahn 
16d2201f2fSdrahn You should have received a copy of the GNU General Public License
17d2201f2fSdrahn along with this program; if not, write to the Free Software
18d2201f2fSdrahn Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19d2201f2fSdrahn 
20d2201f2fSdrahn /* This file holds definitions specific to the MMIX ELF ABI. */
21d2201f2fSdrahn #ifndef ELF_MMIX_H
22d2201f2fSdrahn #define ELF_MMIX_H
23d2201f2fSdrahn 
24d2201f2fSdrahn #include "elf/reloc-macros.h"
25d2201f2fSdrahn 
26*cf2f2c56Smiod /* Relocations.  See the reloc table in bfd/elf64-mmix.c for details.  */
27d2201f2fSdrahn START_RELOC_NUMBERS (elf_mmix_reloc_type)
28d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_NONE, 0)
29d2201f2fSdrahn 
30d2201f2fSdrahn   /* Standard absolute relocations.  */
31d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_8, 1)
32d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_16, 2)
33d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_24, 3)
34d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_32, 4)
35d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_64, 5)
36d2201f2fSdrahn 
37d2201f2fSdrahn   /* Standard relative relocations.  */
38d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PC_8, 6)
39d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PC_16, 7)
40d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PC_24, 8)
41d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PC_32, 9)
42d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PC_64, 10)
43d2201f2fSdrahn 
44d2201f2fSdrahn   /* GNU extensions for C++ vtables.  */
45d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_GNU_VTINHERIT, 11)
46d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_GNU_VTENTRY, 12)
47d2201f2fSdrahn 
48d2201f2fSdrahn   /* A GETA instruction.  */
49d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_GETA, 13)
50d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_GETA_1, 14)
51d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_GETA_2, 15)
52d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_GETA_3, 16)
53d2201f2fSdrahn 
54d2201f2fSdrahn   /* A conditional branch instruction.  */
55d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_CBRANCH, 17)
56d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_CBRANCH_J, 18)
57d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_CBRANCH_1, 19)
58d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_CBRANCH_2, 20)
59d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_CBRANCH_3, 21)
60d2201f2fSdrahn 
61d2201f2fSdrahn   /* A PUSHJ instruction.  */
62d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PUSHJ, 22)
63d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PUSHJ_1, 23)
64d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PUSHJ_2, 24)
65d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_PUSHJ_3, 25)
66d2201f2fSdrahn 
67d2201f2fSdrahn   /* A JMP instruction.  */
68d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_JMP, 26)
69d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_JMP_1, 27)
70d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_JMP_2, 28)
71d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_JMP_3, 29)
72d2201f2fSdrahn 
73d2201f2fSdrahn   /* A relative address such as in a GETA or a branch.  */
74d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_ADDR19, 30)
75d2201f2fSdrahn 
76d2201f2fSdrahn   /* A relative address such as in a JMP (only).  */
77d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_ADDR27, 31)
78d2201f2fSdrahn 
79d2201f2fSdrahn   /* A general register or a number 0..255.  */
80d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_REG_OR_BYTE, 32)
81d2201f2fSdrahn 
82d2201f2fSdrahn   /* A general register. */
83d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_REG, 33)
84d2201f2fSdrahn 
85d2201f2fSdrahn   /* A global register and an offset, the global register (allocated at
86d2201f2fSdrahn      link time) contents plus the offset made equivalent to the relocation
87d2201f2fSdrahn      expression at link time.  The relocation must point at the Y field of
88d2201f2fSdrahn      an instruction.  */
89d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_BASE_PLUS_OFFSET, 34)
90d2201f2fSdrahn 
91d2201f2fSdrahn   /* A LOCAL assertion.  */
92d2201f2fSdrahn   RELOC_NUMBER (R_MMIX_LOCAL, 35)
93*cf2f2c56Smiod 
94*cf2f2c56Smiod   /* A PUSHJ instruction, generating a stub if it does not reach.  */
95*cf2f2c56Smiod   RELOC_NUMBER (R_MMIX_PUSHJ_STUBBABLE, 36)
96d2201f2fSdrahn END_RELOC_NUMBERS (R_MMIX_max)
97d2201f2fSdrahn 
98d2201f2fSdrahn 
99d2201f2fSdrahn /* Section Attributes.  */
100d2201f2fSdrahn /* A section containing necessary information for relaxation.  */
101d2201f2fSdrahn #define SHF_MMIX_CANRELAX	0x80000000
102d2201f2fSdrahn 
103d2201f2fSdrahn /* Symbol attributes.  */
104d2201f2fSdrahn /* A symbol with this section-index is a register.  */
105d2201f2fSdrahn #define SHN_REGISTER	SHN_LOPROC
106d2201f2fSdrahn 
107d2201f2fSdrahn /* This section holds contents for each initialized register, at VMA
108d2201f2fSdrahn    regno*8.  A symbol relative to this section will be transformed to an
109d2201f2fSdrahn    absolute symbol with the value corresponding to the register number at
110d2201f2fSdrahn    final link time.  A symbol with a value outside the inclusive range
111d2201f2fSdrahn    32*8 .. 254*8 is an error.  It is highly recommended to only use an
112d2201f2fSdrahn    upper bound of 253*8 or lower as specified in the (currently
113d2201f2fSdrahn    unspecified) ABI.  */
114d2201f2fSdrahn #define MMIX_REG_CONTENTS_SECTION_NAME ".MMIX.reg_contents"
115d2201f2fSdrahn 
116d2201f2fSdrahn /* At link time, a section by this name is created, expected to be
117d2201f2fSdrahn    included in MMIX_REG_CONTENTS_SECTION_NAME in the output.  */
118d2201f2fSdrahn #define MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME \
119d2201f2fSdrahn  ".MMIX.reg_contents.linker_allocated"
120d2201f2fSdrahn 
121d2201f2fSdrahn /* This is a faked section holding symbols with SHN_REGISTER.  Don't
122d2201f2fSdrahn    confuse it with MMIX_REG_CONTENTS_SECTION_NAME; this one has no
123d2201f2fSdrahn    contents, just values.  It is an error for a value in this section to
124d2201f2fSdrahn    be outside the range 32..255 and it must never become an actual section
125d2201f2fSdrahn    in an object file.  */
126d2201f2fSdrahn #define MMIX_REG_SECTION_NAME "*REG*"
127d2201f2fSdrahn 
128d2201f2fSdrahn /* Appended with a number N=0..65535, this is a representation of the
129d2201f2fSdrahn    mmixal "BSPEC N" ... "ESPEC" directive pair; the contents go into an
130d2201f2fSdrahn    ELF section by name ".MMIX.spec_data.N".  */
131d2201f2fSdrahn #define MMIX_OTHER_SPEC_SECTION_PREFIX ".MMIX.spec_data."
132d2201f2fSdrahn 
133d2201f2fSdrahn /* A section SECNAME is noted to start at "__.MMIX.start.SECNAME" by the
134d2201f2fSdrahn    presence of this symbol.  Currently only implemented for ".text"
135d2201f2fSdrahn    through the symbol "__.MMIX.start..text".  */
136d2201f2fSdrahn #define MMIX_LOC_SECTION_START_SYMBOL_PREFIX "__.MMIX.start."
137d2201f2fSdrahn 
138d2201f2fSdrahn /* This symbol is always a function.  */
139d2201f2fSdrahn #define MMIX_START_SYMBOL_NAME "Main"
140d2201f2fSdrahn 
141d2201f2fSdrahn 
142d2201f2fSdrahn /* We smuggle in a few MMO specifics here.  We don't make a specific MMO
143d2201f2fSdrahn    file, since we can't reasonably support MMO without ELF; we have to
144d2201f2fSdrahn    include this file anyway.  */
145d2201f2fSdrahn 
146d2201f2fSdrahn #define MMO_TEXT_SECTION_NAME ".text"
147d2201f2fSdrahn #define MMO_DATA_SECTION_NAME ".data"
148d2201f2fSdrahn 
149d2201f2fSdrahn /* A definition for the flags we put in spec data in files.  A copy of our
150d2201f2fSdrahn    own of some flags to keep immune to BFD flag changes.  See section.c of
151d2201f2fSdrahn    2001-07-18 for flag documentation.  */
152d2201f2fSdrahn #define MMO_SEC_ALLOC      0x001
153d2201f2fSdrahn #define MMO_SEC_LOAD       0x002
154d2201f2fSdrahn #define MMO_SEC_RELOC      0x004
155d2201f2fSdrahn #define MMO_SEC_READONLY   0x010
156d2201f2fSdrahn #define MMO_SEC_CODE       0x020
157d2201f2fSdrahn #define MMO_SEC_DATA       0x040
158d2201f2fSdrahn #define MMO_SEC_NEVER_LOAD 0x400
159d2201f2fSdrahn #define MMO_SEC_IS_COMMON 0x8000
160d2201f2fSdrahn #define MMO_SEC_DEBUGGING 0x10000
161d2201f2fSdrahn 
162d2201f2fSdrahn #ifdef BFD_ARCH_SIZE
163*cf2f2c56Smiod extern bfd_boolean _bfd_mmix_before_linker_allocation
164*cf2f2c56Smiod   (bfd *, struct bfd_link_info *);
165*cf2f2c56Smiod extern bfd_boolean _bfd_mmix_after_linker_allocation
166*cf2f2c56Smiod   (bfd *, struct bfd_link_info *);
167d2201f2fSdrahn extern bfd_boolean _bfd_mmix_check_all_relocs
168*cf2f2c56Smiod   (bfd *, struct bfd_link_info *);
169d2201f2fSdrahn #endif
170d2201f2fSdrahn 
171d2201f2fSdrahn #endif /* ELF_MMIX_H */
172