xref: /netbsd-src/external/gpl3/gdb/dist/include/elf/msp430.h (revision e663ba6e3a60083e70de702e9d54bf486a57b6a7)
198b9484cSchristos /* MSP430 ELF support for BFD.
2*e663ba6eSchristos    Copyright (C) 2002-2024 Free Software Foundation, Inc.
398b9484cSchristos    Contributed by Dmitry Diky <diwil@mail.ru>
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 Foundation,
1998b9484cSchristos    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
2098b9484cSchristos 
2198b9484cSchristos #ifndef _ELF_MSP430_H
2298b9484cSchristos #define _ELF_MSP430_H
2398b9484cSchristos 
2498b9484cSchristos #include "elf/reloc-macros.h"
2598b9484cSchristos 
2698b9484cSchristos /* Processor specific flags for the ELF header e_flags field.  */
2798b9484cSchristos #define EF_MSP430_MACH 		0xff
2898b9484cSchristos 
2998b9484cSchristos #define E_MSP430_MACH_MSP430x11  11
3098b9484cSchristos #define E_MSP430_MACH_MSP430x11x1  110
3198b9484cSchristos #define E_MSP430_MACH_MSP430x12  12
3298b9484cSchristos #define E_MSP430_MACH_MSP430x13  13
3398b9484cSchristos #define E_MSP430_MACH_MSP430x14  14
3498b9484cSchristos #define E_MSP430_MACH_MSP430x15  15
3598b9484cSchristos #define E_MSP430_MACH_MSP430x16  16
3603467a24Schristos #define E_MSP430_MACH_MSP430x20  20
3703467a24Schristos #define E_MSP430_MACH_MSP430x22  22
3803467a24Schristos #define E_MSP430_MACH_MSP430x23  23
3903467a24Schristos #define E_MSP430_MACH_MSP430x24  24
4003467a24Schristos #define E_MSP430_MACH_MSP430x26  26
4198b9484cSchristos #define E_MSP430_MACH_MSP430x31  31
4298b9484cSchristos #define E_MSP430_MACH_MSP430x32  32
4398b9484cSchristos #define E_MSP430_MACH_MSP430x33  33
4498b9484cSchristos #define E_MSP430_MACH_MSP430x41  41
4598b9484cSchristos #define E_MSP430_MACH_MSP430x42  42
4698b9484cSchristos #define E_MSP430_MACH_MSP430x43  43
4798b9484cSchristos #define E_MSP430_MACH_MSP430x44  44
4803467a24Schristos #define E_MSP430_MACH_MSP430X    45
4903467a24Schristos #define E_MSP430_MACH_MSP430x46  46
5003467a24Schristos #define E_MSP430_MACH_MSP430x47  47
5103467a24Schristos #define E_MSP430_MACH_MSP430x54  54
5203467a24Schristos 
5303467a24Schristos #define SHT_MSP430_ATTRIBUTES	0x70000003	/* Section holds ABI attributes.  */
5403467a24Schristos #define SHT_MSP430_SEC_FLAGS	0x7f000005	/* Holds TI compiler's section flags.  */
5503467a24Schristos #define SHT_MSP430_SYM_ALIASES	0x7f000006	/* Holds TI compiler's symbol aliases.  */
5603467a24Schristos 
5703467a24Schristos /* Tag values for an attribute section.  */
5803467a24Schristos #define OFBA_MSPABI_Tag_ISA		4
5903467a24Schristos #define OFBA_MSPABI_Tag_Code_Model	6
6003467a24Schristos #define OFBA_MSPABI_Tag_Data_Model	8
618dffb485Schristos #define OFBA_MSPABI_Tag_enum_size	10	/* Unused by GNU.  */
628dffb485Schristos 
638dffb485Schristos /* GNU Object attribute tags.  */
648dffb485Schristos enum
658dffb485Schristos {
668dffb485Schristos   /* 0-3 are generic.  */
678dffb485Schristos 
688dffb485Schristos   /* Define a GNU attribute for keeping track of whether the compiler has
698dffb485Schristos      generated code assuming that the upper region could be in use.
708dffb485Schristos      Added by the assembler based on the -mdata-region option.
718dffb485Schristos      This tag is ignored unless the large memory model is in use.  */
728dffb485Schristos   Tag_GNU_MSP430_Data_Region = 4,
738dffb485Schristos };
748dffb485Schristos 
758dffb485Schristos /* Object attribute values.  */
768dffb485Schristos enum
778dffb485Schristos {
788dffb485Schristos   /* Values defined for OFBA_MSPABI_Tag_ISA.  */
798dffb485Schristos   OFBA_MSPABI_Val_ISA_NONE = 0,
808dffb485Schristos   OFBA_MSPABI_Val_ISA_MSP430 = 1,
818dffb485Schristos   OFBA_MSPABI_Val_ISA_MSP430X = 2,
828dffb485Schristos 
838dffb485Schristos   /* Values defined for OFBA_MSPABI_Tag_Code_Model.  */
848dffb485Schristos   OFBA_MSPABI_Val_Code_Model_NONE = 0,
858dffb485Schristos   OFBA_MSPABI_Val_Code_Model_SMALL = 1,
868dffb485Schristos   OFBA_MSPABI_Val_Code_Model_LARGE = 2,
878dffb485Schristos 
888dffb485Schristos   /* Values defined for OFBA_MSPABI_Tag_Data_Model.  */
898dffb485Schristos   OFBA_MSPABI_Val_Data_Model_NONE = 0,
908dffb485Schristos   OFBA_MSPABI_Val_Data_Model_SMALL = 1,
918dffb485Schristos   OFBA_MSPABI_Val_Data_Model_LARGE = 2,
928dffb485Schristos   OFBA_MSPABI_Val_Data_Model_RESTRICTED = 3,	/* Unused by GNU.  */
938dffb485Schristos 
948dffb485Schristos   /* Values defined for Tag_GNU_MSP430_Data_Region.  */
958dffb485Schristos   Val_GNU_MSP430_Data_Region_NONE = 0,
968dffb485Schristos   /* The default data region.  Assumes all data is below address 0x10000.  */
978dffb485Schristos   Val_GNU_MSP430_Data_Region_Lower = 1,
988dffb485Schristos   /* Set if -mdata-region={none,upper,either}.  Assumes
998dffb485Schristos      data could be placed at or above address 0x10000.  */
1008dffb485Schristos   Val_GNU_MSP430_Data_Region_Any = 2,
1018dffb485Schristos };
10298b9484cSchristos 
10398b9484cSchristos /* Relocations.  */
10498b9484cSchristos START_RELOC_NUMBERS (elf_msp430_reloc_type)
10598b9484cSchristos      RELOC_NUMBER (R_MSP430_NONE,		0)
10698b9484cSchristos      RELOC_NUMBER (R_MSP430_32,			1)
10798b9484cSchristos      RELOC_NUMBER (R_MSP430_10_PCREL,		2)
10898b9484cSchristos      RELOC_NUMBER (R_MSP430_16, 		3)
10998b9484cSchristos      RELOC_NUMBER (R_MSP430_16_PCREL, 		4)
11098b9484cSchristos      RELOC_NUMBER (R_MSP430_16_BYTE, 		5)
11198b9484cSchristos      RELOC_NUMBER (R_MSP430_16_PCREL_BYTE, 	6)
11298b9484cSchristos      RELOC_NUMBER (R_MSP430_2X_PCREL,		7)
11398b9484cSchristos      RELOC_NUMBER (R_MSP430_RL_PCREL,		8)
11403467a24Schristos      RELOC_NUMBER (R_MSP430_8,			9)
11503467a24Schristos      RELOC_NUMBER (R_MSP430_SYM_DIFF,		10)
1168dffb485Schristos      RELOC_NUMBER (R_MSP430_GNU_SET_ULEB128, 11) /* GNU only.  */
1178dffb485Schristos      RELOC_NUMBER (R_MSP430_GNU_SUB_ULEB128, 12) /* GNU only.  */
11898b9484cSchristos END_RELOC_NUMBERS (R_MSP430_max)
11998b9484cSchristos 
12003467a24Schristos START_RELOC_NUMBERS (elf_msp430x_reloc_type)
12103467a24Schristos      RELOC_NUMBER (R_MSP430_ABS32, 1)		/* aka R_MSP430_32 */
12203467a24Schristos      RELOC_NUMBER (R_MSP430_ABS16, 2)		/* aka R_MSP430_16 */
12303467a24Schristos      RELOC_NUMBER (R_MSP430_ABS8, 3)
12403467a24Schristos      RELOC_NUMBER (R_MSP430_PCR16, 4)		/* aka R_MSP430_16_PCREL */
12503467a24Schristos      RELOC_NUMBER (R_MSP430X_PCR20_EXT_SRC, 5)
12603467a24Schristos      RELOC_NUMBER (R_MSP430X_PCR20_EXT_DST, 6)
12703467a24Schristos      RELOC_NUMBER (R_MSP430X_PCR20_EXT_ODST, 7)
12803467a24Schristos      RELOC_NUMBER (R_MSP430X_ABS20_EXT_SRC, 8)
12903467a24Schristos      RELOC_NUMBER (R_MSP430X_ABS20_EXT_DST, 9)
13003467a24Schristos      RELOC_NUMBER (R_MSP430X_ABS20_EXT_ODST, 10)
13103467a24Schristos      RELOC_NUMBER (R_MSP430X_ABS20_ADR_SRC, 11)
13203467a24Schristos      RELOC_NUMBER (R_MSP430X_ABS20_ADR_DST, 12)
13303467a24Schristos      RELOC_NUMBER (R_MSP430X_PCR16, 13)		/* Like R_MSP430_PCR16 but with overflow checking.  */
13403467a24Schristos      RELOC_NUMBER (R_MSP430X_PCR20_CALL, 14)
13503467a24Schristos      RELOC_NUMBER (R_MSP430X_ABS16, 15)		/* Like R_MSP430_ABS16 but with overflow checking.  */
13603467a24Schristos      RELOC_NUMBER (R_MSP430_ABS_HI16, 16)
13703467a24Schristos      RELOC_NUMBER (R_MSP430_PREL31, 17)
13803467a24Schristos      RELOC_NUMBER (R_MSP430_EHTYPE, 18)		/* Mentioned in ABI.  */
13903467a24Schristos      RELOC_NUMBER (R_MSP430X_10_PCREL, 19)	/* Red Hat invention.  Used for Jump instructions.  */
14003467a24Schristos      RELOC_NUMBER (R_MSP430X_2X_PCREL, 20)	/* Red Hat invention.  Used for relaxing jumps.  */
14103467a24Schristos      RELOC_NUMBER (R_MSP430X_SYM_DIFF, 21)	/* Red Hat invention.  Used for relaxing debug info.  */
1428dffb485Schristos      RELOC_NUMBER (R_MSP430X_GNU_SET_ULEB128, 22) /* GNU only.  */
1438dffb485Schristos      RELOC_NUMBER (R_MSP430X_GNU_SUB_ULEB128, 23) /* GNU only.  */
14403467a24Schristos END_RELOC_NUMBERS (R_MSP430x_max)
14503467a24Schristos 
14698b9484cSchristos #endif /* _ELF_MSP430_H */
147