sh.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* coff information for Renesas SH
  2. Copyright (C) 2000-2015 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  14. MA 02110-1301, USA. */
  15. #ifdef COFF_WITH_PE
  16. #define L_LNNO_SIZE 2
  17. #else
  18. #define L_LNNO_SIZE 4
  19. #endif
  20. #define INCLUDE_COMDAT_FIELDS_IN_AUXENT
  21. #include "coff/external.h"
  22. #define SH_ARCH_MAGIC_BIG 0x0500
  23. #define SH_ARCH_MAGIC_LITTLE 0x0550 /* Little endian SH */
  24. #define SH_ARCH_MAGIC_WINCE 0x01a2 /* Windows CE - little endian */
  25. #define SH_PE_MAGIC 0x010b
  26. #define SHBADMAG(x) \
  27. (((x).f_magic != SH_ARCH_MAGIC_BIG) && \
  28. ((x).f_magic != SH_ARCH_MAGIC_WINCE) && \
  29. ((x).f_magic != SH_ARCH_MAGIC_LITTLE))
  30. /* Define some NT default values. */
  31. /* #define NT_IMAGE_BASE 0x400000 moved to internal.h */
  32. #define NT_SECTION_ALIGNMENT 0x1000
  33. #define NT_FILE_ALIGNMENT 0x200
  34. #define NT_DEF_RESERVE 0x100000
  35. #define NT_DEF_COMMIT 0x1000
  36. /********************** RELOCATION DIRECTIVES **********************/
  37. /* The external reloc has an offset field, because some of the reloc
  38. types on the h8 don't have room in the instruction for the entire
  39. offset - eg the strange jump and high page addressing modes. */
  40. #ifndef COFF_WITH_PE
  41. struct external_reloc
  42. {
  43. char r_vaddr[4];
  44. char r_symndx[4];
  45. char r_offset[4];
  46. char r_type[2];
  47. char r_stuff[2];
  48. };
  49. #else
  50. struct external_reloc
  51. {
  52. char r_vaddr[4];
  53. char r_symndx[4];
  54. char r_type[2];
  55. };
  56. #endif
  57. #define RELOC struct external_reloc
  58. #ifdef COFF_WITH_PE
  59. #define RELSZ 10
  60. #else
  61. #define RELSZ 16
  62. #endif
  63. /* SH relocation types. Not all of these are actually used. */
  64. #define R_SH_UNUSED 0 /* only used internally */
  65. #define R_SH_IMM32CE 2 /* 32 bit immediate for WinCE */
  66. #define R_SH_PCREL8 3 /* 8 bit pcrel */
  67. #define R_SH_PCREL16 4 /* 16 bit pcrel */
  68. #define R_SH_HIGH8 5 /* high 8 bits of 24 bit address */
  69. #define R_SH_LOW16 7 /* low 16 bits of 24 bit immediate */
  70. #define R_SH_IMM24 6 /* 24 bit immediate */
  71. #define R_SH_PCDISP8BY4 9 /* PC rel 8 bits *4 +ve */
  72. #define R_SH_PCDISP8BY2 10 /* PC rel 8 bits *2 +ve */
  73. #define R_SH_PCDISP8 11 /* 8 bit branch */
  74. #define R_SH_PCDISP 12 /* 12 bit branch */
  75. #define R_SH_IMM32 14 /* 32 bit immediate */
  76. #define R_SH_IMM8 16 /* 8 bit immediate */
  77. #define R_SH_IMAGEBASE 16 /* Windows CE */
  78. #define R_SH_IMM8BY2 17 /* 8 bit immediate *2 */
  79. #define R_SH_IMM8BY4 18 /* 8 bit immediate *4 */
  80. #define R_SH_IMM4 19 /* 4 bit immediate */
  81. #define R_SH_IMM4BY2 20 /* 4 bit immediate *2 */
  82. #define R_SH_IMM4BY4 21 /* 4 bit immediate *4 */
  83. #define R_SH_PCRELIMM8BY2 22 /* PC rel 8 bits *2 unsigned */
  84. #define R_SH_PCRELIMM8BY4 23 /* PC rel 8 bits *4 unsigned */
  85. #define R_SH_IMM16 24 /* 16 bit immediate */
  86. /* The switch table reloc types are used for relaxing. They are
  87. generated for expressions such as
  88. .word L1 - L2
  89. The r_offset field holds the difference between the reloc address
  90. and L2. */
  91. #define R_SH_SWITCH8 33 /* 8 bit switch table entry */
  92. #define R_SH_SWITCH16 25 /* 16 bit switch table entry */
  93. #define R_SH_SWITCH32 26 /* 32 bit switch table entry */
  94. /* The USES reloc type is used for relaxing. The compiler will
  95. generate .uses pseudo-ops when it finds a function call which it
  96. can relax. The r_offset field of the USES reloc holds the PC
  97. relative offset to the instruction which loads the register used in
  98. the function call. */
  99. #define R_SH_USES 27 /* .uses pseudo-op */
  100. /* The COUNT reloc type is used for relaxing. The assembler will
  101. generate COUNT relocs for addresses referred to by the register
  102. loads associated with USES relocs. The r_offset field of the COUNT
  103. reloc holds the number of times the address is referenced in the
  104. object file. */
  105. #define R_SH_COUNT 28 /* Count of constant pool uses */
  106. /* The ALIGN reloc type is used for relaxing. The r_offset field is
  107. the power of two to which subsequent portions of the object file
  108. must be aligned. */
  109. #define R_SH_ALIGN 29 /* .align pseudo-op */
  110. /* The CODE and DATA reloc types are used for aligning load and store
  111. instructions. The assembler will generate a CODE reloc before a
  112. block of instructions. It will generate a DATA reloc before data.
  113. A section should be processed assuming it contains data, unless a
  114. CODE reloc is seen. The only relevant pieces of information in the
  115. CODE and DATA relocs are the section and the address. The symbol
  116. and offset are meaningless. */
  117. #define R_SH_CODE 30 /* start of code */
  118. #define R_SH_DATA 31 /* start of data */
  119. /* The LABEL reloc type is used for aligning load and store
  120. instructions. The assembler will generate a LABEL reloc for each
  121. label within a block of instructions. This permits the linker to
  122. avoid swapping instructions which are the targets of branches. */
  123. #define R_SH_LABEL 32 /* label */
  124. /* NB: R_SH_SWITCH8 is 33 */
  125. #define R_SH_LOOP_START 34
  126. #define R_SH_LOOP_END 35