tc-avr.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /* This file is tc-avr.h
  2. Copyright (C) 1999-2015 Free Software Foundation, Inc.
  3. Contributed by Denis Chertykov <denisc@overta.ru>
  4. This file is part of GAS, the GNU Assembler.
  5. GAS is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GAS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GAS; see the file COPYING. If not, write to the Free
  15. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  16. 02110-1301, USA. */
  17. /* By convention, you should define this macro in the `.h' file. For
  18. example, `tc-m68k.h' defines `TC_M68K'. You might have to use this
  19. if it is necessary to add CPU specific code to the object format
  20. file. */
  21. #define TC_AVR
  22. /* This macro is the BFD target name to use when creating the output
  23. file. This will normally depend upon the `OBJ_FMT' macro. */
  24. #define TARGET_FORMAT "elf32-avr"
  25. /* This macro is the BFD architecture to pass to `bfd_set_arch_mach'. */
  26. #define TARGET_ARCH bfd_arch_avr
  27. /* This macro is the BFD machine number to pass to
  28. `bfd_set_arch_mach'. If it is not defined, GAS will use 0. */
  29. #define TARGET_MACH 0
  30. /* You should define this macro to be non-zero if the target is big
  31. endian, and zero if the target is little endian. */
  32. #define TARGET_BYTES_BIG_ENDIAN 0
  33. /* If you define this macro, GAS will warn about the use of
  34. nonstandard escape sequences in a string. */
  35. #define ONLY_STANDARD_ESCAPES
  36. #define DIFF_EXPR_OK /* .-foo gets turned into PC relative relocs */
  37. /* GAS will call this function for any expression that can not be
  38. recognized. When the function is called, `input_line_pointer'
  39. will point to the start of the expression. */
  40. #define md_operand(x)
  41. typedef struct
  42. {
  43. /* Name of the expression modifier allowed with .byte, .word, etc. */
  44. const char *name;
  45. /* Only allowed with n bytes of data. */
  46. int nbytes;
  47. /* Associated RELOC. */
  48. bfd_reloc_code_real_type reloc;
  49. /* Part of the error message. */
  50. const char *error;
  51. } exp_mod_data_t;
  52. extern const exp_mod_data_t exp_mod_data[];
  53. #define TC_PARSE_CONS_RETURN_TYPE const exp_mod_data_t *
  54. #define TC_PARSE_CONS_RETURN_NONE exp_mod_data
  55. /* You may define this macro to parse an expression used in a data
  56. allocation pseudo-op such as `.word'. You can use this to
  57. recognize relocation directives that may appear in such directives. */
  58. #define TC_PARSE_CONS_EXPRESSION(EXPR,N) avr_parse_cons_expression (EXPR, N)
  59. extern const exp_mod_data_t *avr_parse_cons_expression (expressionS *, int);
  60. /* You may define this macro to generate a fixup for a data
  61. allocation pseudo-op. */
  62. #define TC_CONS_FIX_NEW avr_cons_fix_new
  63. extern void avr_cons_fix_new (fragS *,int, int, expressionS *,
  64. const exp_mod_data_t *);
  65. /* This should just call either `number_to_chars_bigendian' or
  66. `number_to_chars_littleendian', whichever is appropriate. On
  67. targets like the MIPS which support options to change the
  68. endianness, which function to call is a runtime decision. On
  69. other targets, `md_number_to_chars' can be a simple macro. */
  70. #define md_number_to_chars number_to_chars_littleendian
  71. /* `md_short_jump_size'
  72. `md_long_jump_size'
  73. `md_create_short_jump'
  74. `md_create_long_jump'
  75. If `WORKING_DOT_WORD' is defined, GAS will not do broken word
  76. processing (*note Broken words::.). Otherwise, you should set
  77. `md_short_jump_size' to the size of a short jump (a jump that is
  78. just long enough to jump around a long jmp) and
  79. `md_long_jump_size' to the size of a long jump (a jump that can go
  80. anywhere in the function), You should define
  81. `md_create_short_jump' to create a short jump around a long jump,
  82. and define `md_create_long_jump' to create a long jump. */
  83. #define WORKING_DOT_WORD
  84. /* If you define this macro, it means that `tc_gen_reloc' may return
  85. multiple relocation entries for a single fixup. In this case, the
  86. return value of `tc_gen_reloc' is a pointer to a null terminated
  87. array. */
  88. #undef RELOC_EXPANSION_POSSIBLE
  89. /* No shared lib support, so we don't need to ensure externally
  90. visible symbols can be overridden. */
  91. #define EXTERN_FORCE_RELOC 0
  92. /* If defined, this macro allows control over whether fixups for a
  93. given section will be processed when the linkrelax variable is
  94. set. Define it to zero and handle things in md_apply_fix instead.*/
  95. #define TC_LINKRELAX_FIXUP(SEG) 0
  96. /* If this macro returns non-zero, it guarantees that a relocation will be emitted
  97. even when the value can be resolved locally. Do that if linkrelax is turned on */
  98. #define TC_FORCE_RELOCATION(fix) avr_force_relocation (fix)
  99. #define TC_FORCE_RELOCATION_SUB_SAME(fix, seg) \
  100. (! SEG_NORMAL (seg) || avr_force_relocation (fix))
  101. extern int avr_force_relocation (struct fix *);
  102. /* Values passed to md_apply_fix don't include the symbol value. */
  103. #define MD_APPLY_SYM_VALUE(FIX) 0
  104. /* If you define this macro, it should return the offset between the
  105. address of a PC relative fixup and the position from which the PC
  106. relative adjustment should be made. On many processors, the base
  107. of a PC relative instruction is the next instruction, so this
  108. macro would return the length of an instruction. */
  109. #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC)
  110. extern long md_pcrel_from_section (struct fix *, segT);
  111. /* The number of bytes to put into a word in a listing. This affects
  112. the way the bytes are clumped together in the listing. For
  113. example, a value of 2 might print `1234 5678' where a value of 1
  114. would print `12 34 56 78'. The default value is 4. */
  115. #define LISTING_WORD_SIZE 2
  116. /* AVR port uses `$' as a logical line separator. */
  117. #define LEX_DOLLAR 0
  118. /* An `.lcomm' directive with no explicit alignment parameter will
  119. use this macro to set P2VAR to the alignment that a request for
  120. SIZE bytes will have. The alignment is expressed as a power of
  121. two. If no alignment should take place, the macro definition
  122. should do nothing. Some targets define a `.bss' directive that is
  123. also affected by this macro. The default definition will set
  124. P2VAR to the truncated power of two of sizes up to eight bytes. */
  125. #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) (P2VAR) = 0
  126. /* We don't want gas to fixup the following program memory related relocations.
  127. We will need them in case that we want to do linker relaxation.
  128. We could in principle keep these fixups in gas when not relaxing.
  129. However, there is no serious performance penalty when making the linker
  130. make the fixup work. Check also that fx_addsy is not NULL, in order to make
  131. sure that the fixup refers to some sort of label. */
  132. #define TC_VALIDATE_FIX(FIXP,SEG,SKIP) \
  133. if ( (FIXP->fx_r_type == BFD_RELOC_AVR_7_PCREL \
  134. || FIXP->fx_r_type == BFD_RELOC_AVR_13_PCREL \
  135. || FIXP->fx_r_type == BFD_RELOC_AVR_LO8_LDI_PM \
  136. || FIXP->fx_r_type == BFD_RELOC_AVR_LO8_LDI_GS \
  137. || FIXP->fx_r_type == BFD_RELOC_AVR_HI8_LDI_PM \
  138. || FIXP->fx_r_type == BFD_RELOC_AVR_HI8_LDI_GS \
  139. || FIXP->fx_r_type == BFD_RELOC_AVR_HH8_LDI_PM \
  140. || FIXP->fx_r_type == BFD_RELOC_AVR_LO8_LDI_PM_NEG \
  141. || FIXP->fx_r_type == BFD_RELOC_AVR_HI8_LDI_PM_NEG \
  142. || FIXP->fx_r_type == BFD_RELOC_AVR_HH8_LDI_PM_NEG \
  143. || FIXP->fx_r_type == BFD_RELOC_AVR_8_LO \
  144. || FIXP->fx_r_type == BFD_RELOC_AVR_8_HI \
  145. || FIXP->fx_r_type == BFD_RELOC_AVR_8_HLO \
  146. || FIXP->fx_r_type == BFD_RELOC_AVR_16_PM) \
  147. && FIXP->fx_addsy != NULL \
  148. && FIXP->fx_subsy == NULL) \
  149. { \
  150. symbol_mark_used_in_reloc (FIXP->fx_addsy); \
  151. goto SKIP; \
  152. }
  153. /* This macro is evaluated for any fixup with a fx_subsy that
  154. fixup_segment cannot reduce to a number. If the macro returns
  155. false an error will be reported. */
  156. #define TC_VALIDATE_FIX_SUB(fix, seg) avr_validate_fix_sub (fix)
  157. extern int avr_validate_fix_sub (struct fix *);
  158. /* This target is buggy, and sets fix size too large. */
  159. #define TC_FX_SIZE_SLACK(FIX) 2
  160. /* AVR instructions are 2 or 4 bytes long. */
  161. #define DWARF2_LINE_MIN_INSN_LENGTH 2
  162. /* 32 bits pseudo-addresses are used on AVR. */
  163. #define DWARF2_ADDR_SIZE(bfd) 4
  164. /* Enable cfi directives. */
  165. #define TARGET_USE_CFIPOP 1
  166. /* The stack grows down, and is only byte aligned. */
  167. #define DWARF2_CIE_DATA_ALIGNMENT -1
  168. /* Define the column that represents the PC. */
  169. #define DWARF2_DEFAULT_RETURN_COLUMN 36
  170. /* Define a hook to setup initial CFI state. */
  171. extern void tc_cfi_frame_initial_instructions (void);
  172. #define tc_cfi_frame_initial_instructions tc_cfi_frame_initial_instructions
  173. /* The difference between same-section symbols may be affected by linker
  174. relaxation, so do not resolve such expressions in the assembler. */
  175. #define md_allow_local_subtract(l,r,s) avr_allow_local_subtract (l, r, s)
  176. extern bfd_boolean avr_allow_local_subtract (expressionS *, expressionS *, segT);
  177. #define elf_tc_final_processing avr_elf_final_processing
  178. extern void avr_elf_final_processing (void);
  179. #define md_post_relax_hook avr_post_relax_hook ()
  180. extern void avr_post_relax_hook (void);
  181. #define HANDLE_ALIGN(fragP) avr_handle_align (fragP)
  182. extern void avr_handle_align (fragS *fragP);
  183. struct avr_frag_data
  184. {
  185. unsigned is_org : 1;
  186. unsigned is_align : 1;
  187. unsigned has_fill : 1;
  188. char fill;
  189. offsetT alignment;
  190. };
  191. #define TC_FRAG_TYPE struct avr_frag_data