write.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* write.h
  2. Copyright (C) 1987-2022 Free Software Foundation, Inc.
  3. This file is part of GAS, the GNU Assembler.
  4. GAS 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, or (at your option)
  7. any later version.
  8. GAS 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 GAS; see the file COPYING. If not, write to the Free
  14. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  15. 02110-1301, USA. */
  16. #ifndef __write_h__
  17. #define __write_h__
  18. /* This is the name of a fake symbol which will never appear in the
  19. assembler output. S_IS_LOCAL detects it because of the \001. */
  20. #ifndef FAKE_LABEL_NAME
  21. #define FAKE_LABEL_NAME "L0\001"
  22. #endif
  23. /* This is a special character that is used to indicate a fake label.
  24. It must be present in FAKE_LABEL_NAME, although it does not have to
  25. be the first character. It must not be a character that would be
  26. found in a valid symbol name.
  27. Also be aware that the function _bfd_elf_is_local_label_name in
  28. bfd/elf.c has an implicit assumption that FAKE_LABEL_CHAR is '\001'.
  29. If this is not the case then FAKE_LABEL_NAME must start with ".L" in
  30. order for the function to continue working. */
  31. #ifndef FAKE_LABEL_CHAR
  32. #define FAKE_LABEL_CHAR '\001'
  33. #endif
  34. /*
  35. * FixSs may be built up in any order.
  36. */
  37. struct fix
  38. {
  39. /* Next fixS in linked list, or NULL. */
  40. struct fix *fx_next;
  41. /* These small fields are grouped together for compactness of
  42. this structure, and efficiency of access on some architectures. */
  43. /* Is this a pc-relative relocation? */
  44. unsigned fx_pcrel : 1;
  45. /* Has this relocation already been applied? */
  46. unsigned fx_done : 1;
  47. /* Suppress overflow complaints on large addends. This is used
  48. in the PowerPC ELF config to allow large addends on the
  49. BFD_RELOC_{LO16,HI16,HI16_S} relocations.
  50. @@ Can this be determined from BFD? */
  51. unsigned fx_no_overflow : 1;
  52. /* The value is signed when checking for overflow. */
  53. unsigned fx_signed : 1;
  54. /* Some bits for the CPU specific code. */
  55. unsigned fx_tcbit : 1;
  56. unsigned fx_tcbit2 : 1;
  57. /* Spare bits. */
  58. unsigned fx_unused : 10;
  59. /* pc-relative offset adjust (only used by some CPU specific code) */
  60. int fx_pcrel_adjust : 8;
  61. /* How many bytes are involved? */
  62. unsigned fx_size : 8;
  63. bfd_reloc_code_real_type fx_r_type;
  64. /* Which frag does this fix apply to? */
  65. fragS *fx_frag;
  66. /* The location within the frag where the fixup occurs. */
  67. unsigned long fx_where;
  68. /* NULL or Symbol whose value we add in. */
  69. symbolS *fx_addsy;
  70. /* NULL or Symbol whose value we subtract. */
  71. symbolS *fx_subsy;
  72. /* Absolute number we add in. */
  73. valueT fx_offset;
  74. /* The value of dot when the fixup expression was parsed. */
  75. addressT fx_dot_value;
  76. /* The frag fx_dot_value is based on. */
  77. fragS *fx_dot_frag;
  78. /* This field is sort of misnamed. It appears to be a sort of random
  79. scratch field, for use by the back ends. The main gas code doesn't
  80. do anything but initialize it to zero. The use of it does need to
  81. be coordinated between the cpu and format files, though. E.g., some
  82. coff targets pass the `addend' field from the cpu file via this
  83. field. I don't know why the `fx_offset' field above can't be used
  84. for that; investigate later and document. KR */
  85. valueT fx_addnumber;
  86. /* The location of the instruction which created the reloc, used
  87. in error messages. */
  88. const char *fx_file;
  89. unsigned fx_line;
  90. #ifdef USING_CGEN
  91. struct {
  92. /* CGEN_INSN entry for this instruction. */
  93. const struct cgen_insn *insn;
  94. /* Target specific data, usually reloc number. */
  95. int opinfo;
  96. /* Which ifield this fixup applies to. */
  97. struct cgen_maybe_multi_ifield * field;
  98. /* is this field is the MSB field in a set? */
  99. int msb_field_p;
  100. } fx_cgen;
  101. #endif
  102. #ifdef TC_FIX_TYPE
  103. /* Location where a backend can attach additional data
  104. needed to perform fixups. */
  105. TC_FIX_TYPE tc_fix_data;
  106. #endif
  107. };
  108. typedef struct fix fixS;
  109. struct reloc_list
  110. {
  111. struct reloc_list *next;
  112. union
  113. {
  114. struct
  115. {
  116. symbolS *offset_sym;
  117. reloc_howto_type *howto;
  118. symbolS *sym;
  119. bfd_vma addend;
  120. } a;
  121. struct
  122. {
  123. asection *sec;
  124. asymbol *s;
  125. arelent r;
  126. } b;
  127. } u;
  128. const char *file;
  129. unsigned int line;
  130. };
  131. extern int finalize_syms;
  132. extern symbolS *abs_section_sym;
  133. extern addressT dot_value;
  134. extern fragS *dot_frag;
  135. extern struct reloc_list* reloc_list;
  136. extern void append (char **, char *, unsigned long);
  137. extern void record_alignment (segT, unsigned);
  138. extern int get_recorded_alignment (segT);
  139. extern void write_object_file (void);
  140. extern long relax_frag (segT, fragS *, long);
  141. extern int relax_segment (struct frag *, segT, int);
  142. extern void number_to_chars_littleendian (char *, valueT, int);
  143. extern void number_to_chars_bigendian (char *, valueT, int);
  144. extern fixS *fix_new (fragS *, unsigned long, unsigned long, symbolS *,
  145. offsetT, int, bfd_reloc_code_real_type);
  146. extern fixS *fix_at_start (fragS *, unsigned long, symbolS *,
  147. offsetT, int, bfd_reloc_code_real_type);
  148. extern fixS *fix_new_exp (fragS *, unsigned long, unsigned long,
  149. expressionS *, int, bfd_reloc_code_real_type);
  150. extern void write_print_statistics (FILE *);
  151. extern void as_bad_subtract (fixS *);
  152. #endif /* __write_h__ */