rl78.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* RL78 ELF support for BFD.
  2. Copyright (C) 2008-2022 Free Software Foundation, Inc.
  3. This file is part of BFD, the Binary File Descriptor library.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
  15. #ifndef _ELF_RL78_H
  16. #define _ELF_RL78_H
  17. #include "elf/reloc-macros.h"
  18. /* Note that there are a few internal relocation types used by the
  19. linker to do link-time relaxation. If you update this file, please
  20. check elf32-rl78.c to see if any of the internal relocations need to
  21. be, er, relocated. */
  22. /* Preliminary relocations. */
  23. START_RELOC_NUMBERS (elf_rl78_reloc_type)
  24. RELOC_NUMBER (R_RL78_NONE, 0x00)
  25. /* These are for data, and are bi-endian. */
  26. RELOC_NUMBER (R_RL78_DIR32, 0x01) /* Was: R_RL78_32. */
  27. RELOC_NUMBER (R_RL78_DIR24S, 0x02) /* Was: R_RL78_24. */
  28. RELOC_NUMBER (R_RL78_DIR16, 0x03)
  29. RELOC_NUMBER (R_RL78_DIR16U, 0x04) /* Was: R_RL78_16_UNS. */
  30. RELOC_NUMBER (R_RL78_DIR16S, 0x05) /* Was: R_RL78_16. */
  31. RELOC_NUMBER (R_RL78_DIR8, 0x06)
  32. RELOC_NUMBER (R_RL78_DIR8U, 0x07) /* Was: R_RL78_8_UNS. */
  33. RELOC_NUMBER (R_RL78_DIR8S, 0x08) /* Was: R_RL78_8. */
  34. /* Signed pc-relative values. */
  35. RELOC_NUMBER (R_RL78_DIR24S_PCREL, 0x09) /* Was: R_RL78_24_PCREL. */
  36. RELOC_NUMBER (R_RL78_DIR16S_PCREL, 0x0a) /* Was: R_RL78_16_PCREL. */
  37. RELOC_NUMBER (R_RL78_DIR8S_PCREL, 0x0b) /* Was: R_RL78_8_PCREL. */
  38. /* These are for fields in the instructions. */
  39. RELOC_NUMBER (R_RL78_DIR16UL, 0x0c)
  40. RELOC_NUMBER (R_RL78_DIR16UW, 0x0d)
  41. RELOC_NUMBER (R_RL78_DIR8UL, 0x0e)
  42. RELOC_NUMBER (R_RL78_DIR8UW, 0x0f)
  43. RELOC_NUMBER (R_RL78_DIR32_REV, 0x10)
  44. RELOC_NUMBER (R_RL78_DIR16_REV, 0x11)
  45. RELOC_NUMBER (R_RL78_DIR3U_PCREL, 0x12)
  46. /* These are extensions added by Red Hat. */
  47. RELOC_NUMBER (R_RL78_RH_RELAX, 0x2d) /* Marks opcodes suitable for linker relaxation. */
  48. RELOC_NUMBER (R_RL78_RH_SFR, 0x2e) /* SFR addresses - internal use only. */
  49. RELOC_NUMBER (R_RL78_RH_SADDR, 0x2f) /* SADDR addresses - internal use only.. */
  50. /* These are for complex relocs. */
  51. RELOC_NUMBER (R_RL78_ABS32, 0x41)
  52. RELOC_NUMBER (R_RL78_ABS24S, 0x42)
  53. RELOC_NUMBER (R_RL78_ABS16, 0x43)
  54. RELOC_NUMBER (R_RL78_ABS16U, 0x44)
  55. RELOC_NUMBER (R_RL78_ABS16S, 0x45)
  56. RELOC_NUMBER (R_RL78_ABS8, 0x46)
  57. RELOC_NUMBER (R_RL78_ABS8U, 0x47)
  58. RELOC_NUMBER (R_RL78_ABS8S, 0x48)
  59. RELOC_NUMBER (R_RL78_ABS24S_PCREL, 0x49)
  60. RELOC_NUMBER (R_RL78_ABS16S_PCREL, 0x4a)
  61. RELOC_NUMBER (R_RL78_ABS8S_PCREL, 0x4b)
  62. RELOC_NUMBER (R_RL78_ABS16UL, 0x4c)
  63. RELOC_NUMBER (R_RL78_ABS16UW, 0x4d)
  64. RELOC_NUMBER (R_RL78_ABS8UL, 0x4e)
  65. RELOC_NUMBER (R_RL78_ABS8UW, 0x4f)
  66. RELOC_NUMBER (R_RL78_ABS32_REV, 0x50)
  67. RELOC_NUMBER (R_RL78_ABS16_REV, 0x51)
  68. RELOC_NUMBER (R_RL78_SYM, 0x80)
  69. RELOC_NUMBER (R_RL78_OPneg, 0x81)
  70. RELOC_NUMBER (R_RL78_OPadd, 0x82)
  71. RELOC_NUMBER (R_RL78_OPsub, 0x83)
  72. RELOC_NUMBER (R_RL78_OPmul, 0x84)
  73. RELOC_NUMBER (R_RL78_OPdiv, 0x85)
  74. RELOC_NUMBER (R_RL78_OPshla, 0x86)
  75. RELOC_NUMBER (R_RL78_OPshra, 0x87)
  76. RELOC_NUMBER (R_RL78_OPsctsize, 0x88)
  77. RELOC_NUMBER (R_RL78_OPscttop, 0x8d)
  78. RELOC_NUMBER (R_RL78_OPand, 0x90)
  79. RELOC_NUMBER (R_RL78_OPor, 0x91)
  80. RELOC_NUMBER (R_RL78_OPxor, 0x92)
  81. RELOC_NUMBER (R_RL78_OPnot, 0x93)
  82. RELOC_NUMBER (R_RL78_OPmod, 0x94)
  83. RELOC_NUMBER (R_RL78_OPromtop, 0x95)
  84. RELOC_NUMBER (R_RL78_OPramtop, 0x96)
  85. END_RELOC_NUMBERS (R_RL78_max)
  86. #define EF_RL78_CPU_RL78 0x00000079 /* FIXME: correct value? */
  87. #define EF_RL78_CPU_MASK 0x0000007F /* specific cpu bits. */
  88. #define EF_RL78_ALL_FLAGS (EF_RL78_CPU_MASK)
  89. /* Values for the e_flags field in the ELF header. */
  90. #define E_FLAG_RL78_64BIT_DOUBLES (1 << 0)
  91. #define E_FLAG_RL78_DSP (1 << 1) /* Defined in the RL78 CPU Object file specification, but not explained. */
  92. #define E_FLAG_RL78_CPU_MASK 0x0c
  93. #define E_FLAG_RL78_ANY_CPU 0x00 /* CPU not specified. Assume no CPU specific code usage. */
  94. #define E_FLAG_RL78_G10 0x04 /* CPU is missing register banks 1-3, so uses different ABI. */
  95. #define E_FLAG_RL78_G13 0x08 /* CPU uses a peripheral for multiply/divide. */
  96. #define E_FLAG_RL78_G14 0x0c /* CPU has multiply/divide instructions. */
  97. /* These define the addend field of R_RL78_RH_RELAX relocations. */
  98. #define RL78_RELAXA_MASK 0x000000f0 /* Mask for relax types */
  99. #define RL78_RELAXA_BRA 0x00000010 /* Any type of branch (must be decoded). */
  100. #define RL78_RELAXA_ADDR16 0x00000020 /* addr16->sfr/saddr opportunity */
  101. #define RL78_RELAXA_RNUM 0x0000000f /* Number of associated relocations. */
  102. /* These mark the place where alignment is requested, and the place where the filler bytes end. */
  103. #define RL78_RELAXA_ALIGN 0x10000000 /* Start alignment; the remaining bits are the alignment value. */
  104. #define RL78_RELAXA_ELIGN 0x20000000 /* End alignment; the remaining bits are the alignment value. */
  105. #define RL78_RELAXA_ANUM 0x00ffffff /* Alignment amount, in bytes (i.e. .balign). */
  106. #endif /* _ELF_RL78_H */