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