xref: /netbsd-src/external/gpl3/gdb/dist/include/elf/sh.h (revision 02f41505626a9ceb584d30d0789203495760ac88)
198b9484cSchristos /* SH ELF support for BFD.
2*02f41505Schristos    Copyright (C) 1998-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 Foundation,
1898b9484cSchristos    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
1998b9484cSchristos 
2098b9484cSchristos #ifndef _ELF_SH_H
2198b9484cSchristos #define _ELF_SH_H
2298b9484cSchristos 
23ba340e45Schristos #ifdef __cplusplus
24ba340e45Schristos extern "C" {
25ba340e45Schristos #endif
26ba340e45Schristos 
2798b9484cSchristos /* Processor specific flags for the ELF header e_flags field.  */
2898b9484cSchristos 
2998b9484cSchristos #define EF_SH_MACH_MASK	0x1f
3098b9484cSchristos #define EF_SH_UNKNOWN	   0 /* For backwards compatibility.  */
3198b9484cSchristos #define EF_SH1		   1
3298b9484cSchristos #define EF_SH2		   2
3398b9484cSchristos #define EF_SH3		   3
3498b9484cSchristos #define EF_SH_DSP	   4
3598b9484cSchristos #define EF_SH3_DSP	   5
3698b9484cSchristos #define EF_SH4AL_DSP	   6
3798b9484cSchristos #define EF_SH3E		   8
3898b9484cSchristos #define EF_SH4		   9
3998b9484cSchristos #define EF_SH2E            11
4098b9484cSchristos #define EF_SH4A		   12
4198b9484cSchristos #define EF_SH2A            13
4298b9484cSchristos 
4398b9484cSchristos #define EF_SH4_NOFPU	   16
4498b9484cSchristos #define EF_SH4A_NOFPU	   17
4598b9484cSchristos #define EF_SH4_NOMMU_NOFPU 18
4698b9484cSchristos #define EF_SH2A_NOFPU      19
4798b9484cSchristos #define EF_SH3_NOMMU       20
4898b9484cSchristos 
4998b9484cSchristos #define EF_SH2A_SH4_NOFPU  21
5098b9484cSchristos #define EF_SH2A_SH3_NOFPU  22
5198b9484cSchristos #define EF_SH2A_SH4        23
5298b9484cSchristos #define EF_SH2A_SH3E       24
5398b9484cSchristos 
5498b9484cSchristos /* This one can only mix in objects from other EF_SH5 objects.  */
5598b9484cSchristos #define EF_SH5		  10
5698b9484cSchristos 
5798b9484cSchristos /* Define the mapping from ELF to bfd mach numbers.
5898b9484cSchristos    bfd_mach_* are defined in bfd_in2.h (generated from
5998b9484cSchristos    archures.c).  */
6098b9484cSchristos #define EF_SH_BFD_TABLE \
6198b9484cSchristos /* EF_SH_UNKNOWN	*/ bfd_mach_sh		, \
6298b9484cSchristos /* EF_SH1		*/ bfd_mach_sh		, \
6398b9484cSchristos /* EF_SH2		*/ bfd_mach_sh2		, \
6498b9484cSchristos /* EF_SH3		*/ bfd_mach_sh3		, \
6598b9484cSchristos /* EF_SH_DSP		*/ bfd_mach_sh_dsp	, \
6698b9484cSchristos /* EF_SH3_DSP		*/ bfd_mach_sh3_dsp	, \
6798b9484cSchristos /* EF_SHAL_DSP		*/ bfd_mach_sh4al_dsp	, \
6898b9484cSchristos /* 7			*/ 0, \
6998b9484cSchristos /* EF_SH3E		*/ bfd_mach_sh3e	, \
7098b9484cSchristos /* EF_SH4		*/ bfd_mach_sh4		, \
7198b9484cSchristos /* EF_SH5		*/ 0, \
7298b9484cSchristos /* EF_SH2E		*/ bfd_mach_sh2e	, \
7398b9484cSchristos /* EF_SH4A		*/ bfd_mach_sh4a	, \
7498b9484cSchristos /* EF_SH2A		*/ bfd_mach_sh2a        , \
7598b9484cSchristos /* 14, 15		*/ 0, 0, \
7698b9484cSchristos /* EF_SH4_NOFPU		*/ bfd_mach_sh4_nofpu	, \
7798b9484cSchristos /* EF_SH4A_NOFPU	*/ bfd_mach_sh4a_nofpu	, \
7898b9484cSchristos /* EF_SH4_NOMMU_NOFPU	*/ bfd_mach_sh4_nommu_nofpu, \
7998b9484cSchristos /* EF_SH2A_NOFPU	*/ bfd_mach_sh2a_nofpu  , \
8098b9484cSchristos /* EF_SH3_NOMMU		*/ bfd_mach_sh3_nommu   , \
8198b9484cSchristos /* EF_SH2A_SH4_NOFPU    */ bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu, \
8298b9484cSchristos /* EF_SH2A_SH3_NOFPU    */ bfd_mach_sh2a_nofpu_or_sh3_nommu, \
8398b9484cSchristos /* EF_SH2A_SH4          */ bfd_mach_sh2a_or_sh4 , \
8498b9484cSchristos /* EF_SH2A_SH3E         */ bfd_mach_sh2a_or_sh3e
8598b9484cSchristos 
8698b9484cSchristos /* Convert arch_sh* into EF_SH*.  */
8798b9484cSchristos int sh_find_elf_flags (unsigned int arch_set);
8898b9484cSchristos 
8998b9484cSchristos /* Convert bfd_mach_* into EF_SH*.  */
9098b9484cSchristos int sh_elf_get_flags_from_mach (unsigned long mach);
9198b9484cSchristos 
9298b9484cSchristos /* Other e_flags bits.  */
9398b9484cSchristos 
9498b9484cSchristos #define EF_SH_PIC		0x100	/* Segments of an FDPIC binary may
9598b9484cSchristos 					   be relocated independently.  */
9698b9484cSchristos #define EF_SH_FDPIC		0x8000	/* Uses the FDPIC ABI.  */
9798b9484cSchristos 
9898b9484cSchristos #include "elf/reloc-macros.h"
9998b9484cSchristos 
10098b9484cSchristos /* Relocations.  */
10198b9484cSchristos /* Relocations 10-32 and 128-255 are GNU extensions.
10298b9484cSchristos    25..32 and 10 are used for relaxation.  */
10398b9484cSchristos START_RELOC_NUMBERS (elf_sh_reloc_type)
10498b9484cSchristos   RELOC_NUMBER (R_SH_NONE, 0)
10598b9484cSchristos   RELOC_NUMBER (R_SH_DIR32, 1)
10698b9484cSchristos   RELOC_NUMBER (R_SH_REL32, 2)
10798b9484cSchristos   RELOC_NUMBER (R_SH_DIR8WPN, 3)
10898b9484cSchristos   RELOC_NUMBER (R_SH_IND12W, 4)
10998b9484cSchristos   RELOC_NUMBER (R_SH_DIR8WPL, 5)
11098b9484cSchristos   RELOC_NUMBER (R_SH_DIR8WPZ, 6)
11198b9484cSchristos   RELOC_NUMBER (R_SH_DIR8BP, 7)
11298b9484cSchristos   RELOC_NUMBER (R_SH_DIR8W, 8)
11398b9484cSchristos   RELOC_NUMBER (R_SH_DIR8L, 9)
11498b9484cSchristos 
11598b9484cSchristos   RELOC_NUMBER (R_SH_LOOP_START, 10)
11698b9484cSchristos   RELOC_NUMBER (R_SH_LOOP_END, 11)
11798b9484cSchristos 
11898b9484cSchristos   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC, 12)
11998b9484cSchristos   FAKE_RELOC (R_SH_LAST_INVALID_RELOC, 21)
12098b9484cSchristos 
12198b9484cSchristos   RELOC_NUMBER (R_SH_GNU_VTINHERIT, 22)
12298b9484cSchristos   RELOC_NUMBER (R_SH_GNU_VTENTRY, 23)
12398b9484cSchristos   RELOC_NUMBER (R_SH_SWITCH8, 24)
12498b9484cSchristos   RELOC_NUMBER (R_SH_SWITCH16, 25)
12598b9484cSchristos   RELOC_NUMBER (R_SH_SWITCH32, 26)
12698b9484cSchristos   RELOC_NUMBER (R_SH_USES, 27)
12798b9484cSchristos   RELOC_NUMBER (R_SH_COUNT, 28)
12898b9484cSchristos   RELOC_NUMBER (R_SH_ALIGN, 29)
12998b9484cSchristos   RELOC_NUMBER (R_SH_CODE, 30)
13098b9484cSchristos   RELOC_NUMBER (R_SH_DATA, 31)
13198b9484cSchristos   RELOC_NUMBER (R_SH_LABEL, 32)
13298b9484cSchristos 
13398b9484cSchristos   RELOC_NUMBER (R_SH_DIR16, 33)
13498b9484cSchristos   RELOC_NUMBER (R_SH_DIR8, 34)
13598b9484cSchristos   RELOC_NUMBER (R_SH_DIR8UL, 35)
13698b9484cSchristos   RELOC_NUMBER (R_SH_DIR8UW, 36)
13798b9484cSchristos   RELOC_NUMBER (R_SH_DIR8U, 37)
13898b9484cSchristos   RELOC_NUMBER (R_SH_DIR8SW, 38)
13998b9484cSchristos   RELOC_NUMBER (R_SH_DIR8S, 39)
14098b9484cSchristos   RELOC_NUMBER (R_SH_DIR4UL, 40)
14198b9484cSchristos   RELOC_NUMBER (R_SH_DIR4UW, 41)
14298b9484cSchristos   RELOC_NUMBER (R_SH_DIR4U, 42)
14398b9484cSchristos   RELOC_NUMBER (R_SH_PSHA, 43)
14498b9484cSchristos   RELOC_NUMBER (R_SH_PSHL, 44)
14598b9484cSchristos   RELOC_NUMBER (R_SH_DIR5U, 45)
14698b9484cSchristos   RELOC_NUMBER (R_SH_DIR6U, 46)
14798b9484cSchristos   RELOC_NUMBER (R_SH_DIR6S, 47)
14898b9484cSchristos   RELOC_NUMBER (R_SH_DIR10S, 48)
14998b9484cSchristos   RELOC_NUMBER (R_SH_DIR10SW, 49)
15098b9484cSchristos   RELOC_NUMBER (R_SH_DIR10SL, 50)
15198b9484cSchristos   RELOC_NUMBER (R_SH_DIR10SQ, 51)
15298b9484cSchristos   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_2, 52)
15398b9484cSchristos   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_2, 52)
15498b9484cSchristos   RELOC_NUMBER (R_SH_DIR16S, 53)
15598b9484cSchristos   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_3, 54)
15698b9484cSchristos   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_3, 143)
15798b9484cSchristos   RELOC_NUMBER (R_SH_TLS_GD_32, 144)
15898b9484cSchristos   RELOC_NUMBER (R_SH_TLS_LD_32, 145)
15998b9484cSchristos   RELOC_NUMBER (R_SH_TLS_LDO_32, 146)
16098b9484cSchristos   RELOC_NUMBER (R_SH_TLS_IE_32, 147)
16198b9484cSchristos   RELOC_NUMBER (R_SH_TLS_LE_32, 148)
16298b9484cSchristos   RELOC_NUMBER (R_SH_TLS_DTPMOD32, 149)
16398b9484cSchristos   RELOC_NUMBER (R_SH_TLS_DTPOFF32, 150)
16498b9484cSchristos   RELOC_NUMBER (R_SH_TLS_TPOFF32, 151)
16598b9484cSchristos   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_4, 152)
16698b9484cSchristos   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_4, 159)
16798b9484cSchristos   RELOC_NUMBER (R_SH_GOT32, 160)
16898b9484cSchristos   RELOC_NUMBER (R_SH_PLT32, 161)
16998b9484cSchristos   RELOC_NUMBER (R_SH_COPY, 162)
17098b9484cSchristos   RELOC_NUMBER (R_SH_GLOB_DAT, 163)
17198b9484cSchristos   RELOC_NUMBER (R_SH_JMP_SLOT, 164)
17298b9484cSchristos   RELOC_NUMBER (R_SH_RELATIVE, 165)
17398b9484cSchristos   RELOC_NUMBER (R_SH_GOTOFF, 166)
17498b9484cSchristos   RELOC_NUMBER (R_SH_GOTPC, 167)
17598b9484cSchristos   RELOC_NUMBER (R_SH_GOTPLT32, 168)
17698b9484cSchristos   RELOC_NUMBER (R_SH_GOT_LOW16, 169)
17798b9484cSchristos   RELOC_NUMBER (R_SH_GOT_MEDLOW16, 170)
17898b9484cSchristos   RELOC_NUMBER (R_SH_GOT_MEDHI16, 171)
17998b9484cSchristos   RELOC_NUMBER (R_SH_GOT_HI16, 172)
18098b9484cSchristos   RELOC_NUMBER (R_SH_GOTPLT_LOW16, 173)
18198b9484cSchristos   RELOC_NUMBER (R_SH_GOTPLT_MEDLOW16, 174)
18298b9484cSchristos   RELOC_NUMBER (R_SH_GOTPLT_MEDHI16, 175)
18398b9484cSchristos   RELOC_NUMBER (R_SH_GOTPLT_HI16, 176)
18498b9484cSchristos   RELOC_NUMBER (R_SH_PLT_LOW16, 177)
18598b9484cSchristos   RELOC_NUMBER (R_SH_PLT_MEDLOW16, 178)
18698b9484cSchristos   RELOC_NUMBER (R_SH_PLT_MEDHI16, 179)
18798b9484cSchristos   RELOC_NUMBER (R_SH_PLT_HI16, 180)
18898b9484cSchristos   RELOC_NUMBER (R_SH_GOTOFF_LOW16, 181)
18998b9484cSchristos   RELOC_NUMBER (R_SH_GOTOFF_MEDLOW16, 182)
19098b9484cSchristos   RELOC_NUMBER (R_SH_GOTOFF_MEDHI16, 183)
19198b9484cSchristos   RELOC_NUMBER (R_SH_GOTOFF_HI16, 184)
19298b9484cSchristos   RELOC_NUMBER (R_SH_GOTPC_LOW16, 185)
19398b9484cSchristos   RELOC_NUMBER (R_SH_GOTPC_MEDLOW16, 186)
19498b9484cSchristos   RELOC_NUMBER (R_SH_GOTPC_MEDHI16, 187)
19598b9484cSchristos   RELOC_NUMBER (R_SH_GOTPC_HI16, 188)
19698b9484cSchristos   RELOC_NUMBER (R_SH_GOT10BY4, 189)
19798b9484cSchristos   RELOC_NUMBER (R_SH_GOTPLT10BY4, 190)
19898b9484cSchristos   RELOC_NUMBER (R_SH_GOT10BY8, 191)
19998b9484cSchristos   RELOC_NUMBER (R_SH_GOTPLT10BY8, 192)
20098b9484cSchristos   RELOC_NUMBER (R_SH_COPY64, 193)
20198b9484cSchristos   RELOC_NUMBER (R_SH_GLOB_DAT64, 194)
20298b9484cSchristos   RELOC_NUMBER (R_SH_JMP_SLOT64, 195)
20398b9484cSchristos   RELOC_NUMBER (R_SH_RELATIVE64, 196)
20498b9484cSchristos   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_5, 197)
20598b9484cSchristos   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_5, 200)
20698b9484cSchristos   RELOC_NUMBER (R_SH_GOT20, 201)
20798b9484cSchristos   RELOC_NUMBER (R_SH_GOTOFF20, 202)
20898b9484cSchristos   RELOC_NUMBER (R_SH_GOTFUNCDESC, 203)
20998b9484cSchristos   RELOC_NUMBER (R_SH_GOTFUNCDESC20, 204)
21098b9484cSchristos   RELOC_NUMBER (R_SH_GOTOFFFUNCDESC, 205)
21198b9484cSchristos   RELOC_NUMBER (R_SH_GOTOFFFUNCDESC20, 206)
21298b9484cSchristos   RELOC_NUMBER (R_SH_FUNCDESC, 207)
21398b9484cSchristos   RELOC_NUMBER (R_SH_FUNCDESC_VALUE, 208)
21498b9484cSchristos   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_6, 209)
21598b9484cSchristos   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_6, 241)
21698b9484cSchristos   RELOC_NUMBER (R_SH_SHMEDIA_CODE, 242)
21798b9484cSchristos   RELOC_NUMBER (R_SH_PT_16, 243)
21898b9484cSchristos   RELOC_NUMBER (R_SH_IMMS16, 244)
21998b9484cSchristos   RELOC_NUMBER (R_SH_IMMU16, 245)
22098b9484cSchristos   RELOC_NUMBER (R_SH_IMM_LOW16, 246)
22198b9484cSchristos   RELOC_NUMBER (R_SH_IMM_LOW16_PCREL, 247)
22298b9484cSchristos   RELOC_NUMBER (R_SH_IMM_MEDLOW16, 248)
22398b9484cSchristos   RELOC_NUMBER (R_SH_IMM_MEDLOW16_PCREL, 249)
22498b9484cSchristos   RELOC_NUMBER (R_SH_IMM_MEDHI16, 250)
22598b9484cSchristos   RELOC_NUMBER (R_SH_IMM_MEDHI16_PCREL, 251)
22698b9484cSchristos   RELOC_NUMBER (R_SH_IMM_HI16, 252)
22798b9484cSchristos   RELOC_NUMBER (R_SH_IMM_HI16_PCREL, 253)
22898b9484cSchristos   RELOC_NUMBER (R_SH_64, 254)
22998b9484cSchristos   RELOC_NUMBER (R_SH_64_PCREL, 255)
23098b9484cSchristos END_RELOC_NUMBERS (R_SH_max)
23198b9484cSchristos 
232ba340e45Schristos #ifdef __cplusplus
233ba340e45Schristos }
234ba340e45Schristos #endif
235ba340e45Schristos 
23698b9484cSchristos #endif
237