xref: /netbsd-src/external/gpl3/gdb/dist/include/elf/cris.h (revision e663ba6e3a60083e70de702e9d54bf486a57b6a7)
198b9484cSchristos /* CRIS ELF support for BFD.
2*e663ba6eSchristos    Copyright (C) 2000-2024 Free Software Foundation, Inc.
398b9484cSchristos    Contributed by Axis Communications AB, Lund, Sweden.
498b9484cSchristos    Written by Hans-Peter Nilsson.
598b9484cSchristos 
698b9484cSchristos    This file is part of BFD, the Binary File Descriptor library.
798b9484cSchristos 
898b9484cSchristos    This program is free software; you can redistribute it and/or modify
998b9484cSchristos    it under the terms of the GNU General Public License as published by
1098b9484cSchristos    the Free Software Foundation; either version 3 of the License, or
1198b9484cSchristos    (at your option) any later version.
1298b9484cSchristos 
1398b9484cSchristos    This program is distributed in the hope that it will be useful,
1498b9484cSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1598b9484cSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1698b9484cSchristos    GNU General Public License for more details.
1798b9484cSchristos 
1898b9484cSchristos    You should have received a copy of the GNU General Public License
1998b9484cSchristos    along with this program; if not, write to the Free Software Foundation,
2098b9484cSchristos    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
2198b9484cSchristos 
2298b9484cSchristos #ifndef _ELF_CRIS_H
2398b9484cSchristos #define _ELF_CRIS_H
2498b9484cSchristos 
2598b9484cSchristos #include "elf/reloc-macros.h"
2698b9484cSchristos 
2798b9484cSchristos /* Relocations.  */
2898b9484cSchristos START_RELOC_NUMBERS (elf_cris_reloc_type)
2998b9484cSchristos   RELOC_NUMBER (R_CRIS_NONE,		0)
3098b9484cSchristos   RELOC_NUMBER (R_CRIS_8,		1)
3198b9484cSchristos   RELOC_NUMBER (R_CRIS_16,		2)
3298b9484cSchristos   RELOC_NUMBER (R_CRIS_32,		3)
3398b9484cSchristos 
3498b9484cSchristos   /* The "PC" position is the location right after the relocation.  */
3598b9484cSchristos   RELOC_NUMBER (R_CRIS_8_PCREL,		4)
3698b9484cSchristos   RELOC_NUMBER (R_CRIS_16_PCREL,	5)
3798b9484cSchristos   RELOC_NUMBER (R_CRIS_32_PCREL,	6)
3898b9484cSchristos 
3998b9484cSchristos   RELOC_NUMBER (R_CRIS_GNU_VTINHERIT,	7)
4098b9484cSchristos   RELOC_NUMBER (R_CRIS_GNU_VTENTRY,	8)
4198b9484cSchristos 
4298b9484cSchristos   /* Copy contents at dynlinking.  Generated by the linker.
4398b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_COPY.  */
4498b9484cSchristos   RELOC_NUMBER (R_CRIS_COPY, 9)
4598b9484cSchristos 
4698b9484cSchristos   /* Create GOT entry.  Generated by the linker.
4798b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_GLOB_DAT.  */
4898b9484cSchristos   RELOC_NUMBER (R_CRIS_GLOB_DAT, 10)
4998b9484cSchristos 
5098b9484cSchristos   /* Create PLT entry.  Generated by the linker.
5198b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_JUMP_SLOT.  */
5298b9484cSchristos   RELOC_NUMBER (R_CRIS_JUMP_SLOT, 11)
5398b9484cSchristos 
5498b9484cSchristos   /* Adjust by program base.  Generated by the linker.
5598b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_RELATIVE.  */
5698b9484cSchristos   RELOC_NUMBER (R_CRIS_RELATIVE, 12)
5798b9484cSchristos 
5898b9484cSchristos   /* A 16-bit offset to entry in GOT and request to create GOT entry for
5998b9484cSchristos      that symbol.
6098b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_16_GOT.  */
6198b9484cSchristos   RELOC_NUMBER (R_CRIS_16_GOT, 13)
6298b9484cSchristos 
6398b9484cSchristos   /* A 32-bit offset to entry in GOT and request to create GOT entry for
6498b9484cSchristos      that symbol.
6598b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_32_GOT.  */
6698b9484cSchristos   RELOC_NUMBER (R_CRIS_32_GOT, 14)
6798b9484cSchristos 
6898b9484cSchristos   /* A 16-bit offset to entry in PLT part of GOT and request to create PLT
6998b9484cSchristos      entry for that symbol.
7098b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_16_GOTPLT.  */
7198b9484cSchristos   RELOC_NUMBER (R_CRIS_16_GOTPLT, 15)
7298b9484cSchristos 
7398b9484cSchristos   /* A 32-bit offset to entry in PLT part of GOT and request to create PLT
7498b9484cSchristos      entry for that symbol.
7598b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_32_GOTPLT.  */
7698b9484cSchristos   RELOC_NUMBER (R_CRIS_32_GOTPLT, 16)
7798b9484cSchristos 
7898b9484cSchristos   /* A 32-bit offset from GOT to (local) symbol: no GOT entry should be
7998b9484cSchristos      necessary.
8098b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_32_GOTREL.  */
8198b9484cSchristos   RELOC_NUMBER (R_CRIS_32_GOTREL, 17)
8298b9484cSchristos 
8398b9484cSchristos   /* A 32-bit offset from GOT to entry for this symbol in PLT and request
8498b9484cSchristos      to create PLT entry for symbol.
8598b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_32_GOTREL.  */
8698b9484cSchristos   RELOC_NUMBER (R_CRIS_32_PLT_GOTREL, 18)
8798b9484cSchristos 
8898b9484cSchristos   /* A 32-bit offset from location after this relocation (addend specifies
8998b9484cSchristos      offset) to entry for this symbol in PLT and request to create PLT
9098b9484cSchristos      entry for symbol.
9198b9484cSchristos      The BFD equivalent is BFD_RELOC_CRIS_32_PLT_PCREL.  */
9298b9484cSchristos   RELOC_NUMBER (R_CRIS_32_PLT_PCREL, 19)
9398b9484cSchristos 
9498b9484cSchristos   /* An assembler-generated-only relocation, instructing the linker to
9598b9484cSchristos      reserve two GOT slots, carrying the R_CRIS_DTP relocation for the
9698b9484cSchristos      symbol (pointing to the first slot, the relocation fills in
9798b9484cSchristos      both).  The value is a 32-bit-value, relative to the start of the
9898b9484cSchristos      GOT.  Assembly syntax: "sym:GDGOTREL".  */
9998b9484cSchristos   RELOC_NUMBER (R_CRIS_32_GOT_GD, 20)
10098b9484cSchristos 
10198b9484cSchristos   /* Similar to R_CRIS_32_GOT_GD, but the value is a 16-bit unsigned
10298b9484cSchristos      number, limiting access to 65536/4 global symbols per module (or
10398b9484cSchristos      65536/8 thread variables; loosely speaking G*4+T*8 < 65536, where
10498b9484cSchristos      T is the number of thread variables and G is the number of other
10598b9484cSchristos      external global variables and functions).  Assembly syntax:
10698b9484cSchristos      "sym:GDGOTREL16".  */
10798b9484cSchristos   RELOC_NUMBER (R_CRIS_16_GOT_GD, 21)
10898b9484cSchristos 
10998b9484cSchristos   /* Similar to R_CRIS_32_GOT_GD, but the value is the absolute
11098b9484cSchristos      address of the GOT entry.  Disallowed in DSOs created with
11198b9484cSchristos      -shared.  Assembly syntax: "sym:GD".  */
11298b9484cSchristos   RELOC_NUMBER (R_CRIS_32_GD, 22)
11398b9484cSchristos 
11498b9484cSchristos   /* A linker-generated-only relocation, instructing the dynamic
11598b9484cSchristos      linker to fill in the module ID and module-relative-TLS-block
11698b9484cSchristos      offset of the symbol in question, used for GOT entries.  Note
11798b9484cSchristos      that this relocation instructs to fill in two 32-bit values.  */
11898b9484cSchristos   RELOC_NUMBER (R_CRIS_DTP, 23)
11998b9484cSchristos 
12098b9484cSchristos   /* An assembler-generated-only relocation, instructing the linker to
12198b9484cSchristos      reserve the first two GOT slots, and attach the R_CRIS_DTPMOD
12298b9484cSchristos      relocation(*) for the module to the first slot, the second
12398b9484cSchristos      containing zero.  The value is 32 bits, the offset from the start
12498b9484cSchristos      of the TLS block of the module to the thread-local symbol
12598b9484cSchristos      mentioned in the relocation.  This relocation must only be applied
12698b9484cSchristos      to module-local symbols.  Assembly syntax: "expr:DTPREL".  */
12798b9484cSchristos   RELOC_NUMBER (R_CRIS_32_DTPREL, 24)
12898b9484cSchristos 
12998b9484cSchristos   /* Similar to R_CRIS_32_DTPREL, but the value is a 16-bit signed
13098b9484cSchristos      number, limiting the size of thread-variables of the DSO to 32768
13198b9484cSchristos      bytes.  (Note: matches both model 1 and 2 and allows use of addo.w
13298b9484cSchristos      as the instruction where this relocation is used.)  Assembly
13398b9484cSchristos      syntax: "expr:DTPREL16".  */
13498b9484cSchristos   RELOC_NUMBER (R_CRIS_16_DTPREL, 25)
13598b9484cSchristos 
13698b9484cSchristos   /* An assembler-generated-only relocation, instructing the linker to
13798b9484cSchristos      reserve a GOT slot and attach the R_CRIS_32_TPREL relocation for
13898b9484cSchristos      the symbol in question.  The value is 32 bits, which is the
13998b9484cSchristos      GOT-relative offset of the slot.  Assembly syntax:
14098b9484cSchristos      "sym:TPOFFGOT".  */
14198b9484cSchristos   RELOC_NUMBER (R_CRIS_32_GOT_TPREL, 26)
14298b9484cSchristos 
14398b9484cSchristos   /* Similar to R_CRIS_32_TPREL, but the value is a 16-bit positive
14498b9484cSchristos      number, limiting the number of thread- and global variables of
14598b9484cSchristos      the DSO to 32768/4.  Assembly syntax: "sym:TPOFFGOT16".  */
14698b9484cSchristos   RELOC_NUMBER (R_CRIS_16_GOT_TPREL, 27)
14798b9484cSchristos 
14898b9484cSchristos   /* An assembler- and linker-generated relocation, instructing to
14998b9484cSchristos      resolve the symbol in question yielding the TLS offset of the
15098b9484cSchristos      thread variable, relative to the global TLS block.  Not allowed
15198b9484cSchristos      as input when generating a DSO.  Assembly syntax:
15298b9484cSchristos      "expr:TPOFF".  */
15398b9484cSchristos   RELOC_NUMBER (R_CRIS_32_TPREL, 28)
15498b9484cSchristos 
15598b9484cSchristos   /* Similar to R_CRIS_32_TPREL, but only applicable to executables
15698b9484cSchristos      compiled with -msmall-tls. Not allowed in a DSO. The value is a
15798b9484cSchristos      16-bit signed number, limiting the size of thread-variables of
15898b9484cSchristos      the executable to 32768 bytes. (Note: being signed makes it match
15998b9484cSchristos      both model 1 and 2 and allows use of addo.w as the instruction
16098b9484cSchristos      where this relocation is applied.)  Assembly syntax:
16198b9484cSchristos      "expr:TPOFF16".  */
16298b9484cSchristos   RELOC_NUMBER (R_CRIS_16_TPREL, 29)
16398b9484cSchristos 
16498b9484cSchristos   /* A linker-generated-only relocation, instructing the dynamic
16598b9484cSchristos      linker to fill in the current module ID, used for GOT entries
16698b9484cSchristos      (usually the fourth one).  */
16798b9484cSchristos   RELOC_NUMBER (R_CRIS_DTPMOD, 30)
16898b9484cSchristos 
16998b9484cSchristos   /* Similar to R_CRIS_32_GOT_TPREL, but the value is the absolute
17098b9484cSchristos      address of the GOT entry.  Disallowed in DSOs created with
17198b9484cSchristos      -shared.  Assembly syntax: "sym:IE".  */
17298b9484cSchristos   RELOC_NUMBER (R_CRIS_32_IE, 31)
17398b9484cSchristos 
17498b9484cSchristos   /* No other relocs must be visible outside the assembler.  */
17598b9484cSchristos 
17698b9484cSchristos END_RELOC_NUMBERS (R_CRIS_max)
17798b9484cSchristos 
17898b9484cSchristos /* User symbols in this file have a leading underscore.  */
17998b9484cSchristos #define EF_CRIS_UNDERSCORE		0x00000001
18098b9484cSchristos 
18198b9484cSchristos /* This is a mask for different incompatible machine variants.  */
18298b9484cSchristos #define EF_CRIS_VARIANT_MASK		0x0000000e
18398b9484cSchristos 
18498b9484cSchristos /* Variant 0; may contain v0..10 object.  */
18598b9484cSchristos #define EF_CRIS_VARIANT_ANY_V0_V10	0x00000000
18698b9484cSchristos 
18798b9484cSchristos /* Variant 1; contains v32 object.  */
18898b9484cSchristos #define EF_CRIS_VARIANT_V32		0x00000002
18998b9484cSchristos 
19098b9484cSchristos /* Variant 2; contains object compatible with v32 and v10.  */
19198b9484cSchristos #define EF_CRIS_VARIANT_COMMON_V10_V32	0x00000004
19298b9484cSchristos 
19398b9484cSchristos #endif /* _ELF_CRIS_H */
194