1 /* write.h 2 Copyright (C) 1987, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. 3 4 This file is part of GAS, the GNU Assembler. 5 6 GAS is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 GAS is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GAS; see the file COPYING. If not, write to 18 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 19 20 #ifndef __write_h__ 21 #define __write_h__ 22 23 #ifndef TC_I960 24 #ifdef hpux 25 #define EXEC_MACHINE_TYPE HP9000S200_ID 26 #endif 27 #endif /* TC_I960 */ 28 29 #ifndef LOCAL_LABEL 30 #define LOCAL_LABEL(name) (name [0] == 'L' ) 31 #endif /* LOCAL_LABEL */ 32 33 #ifndef FAKE_LABEL_NAME 34 #define FAKE_LABEL_NAME "L0\001" 35 #endif 36 37 #define S_LOCAL_NAME(s) (LOCAL_LABEL(S_GET_NAME(s))) 38 39 #include "bit_fix.h" 40 41 /* 42 * FixSs may be built up in any order. 43 */ 44 45 struct fix 46 { 47 /* These small fields are grouped together for compactness of 48 this structure, and efficiency of access on some architectures. */ 49 50 /* pc-relative offset adjust (only used by m68k) */ 51 char fx_pcrel_adjust; 52 53 /* How many bytes are involved? */ 54 unsigned char fx_size; 55 56 /* Is this a pc-relative relocation? */ 57 unsigned fx_pcrel : 1; 58 59 /* Is this a relocation to a procedure linkage table entry? If so, 60 some of the reductions we try to apply are invalid. A better way 61 might be to represent PLT entries with different kinds of 62 symbols, and use normal relocations (with undefined symbols); 63 look into it for version 2.6. */ 64 unsigned fx_plt : 1; 65 66 /* Is this value an immediate displacement? */ 67 /* Only used on i960 and ns32k; merge it into TC_FIX_TYPE sometime. */ 68 unsigned fx_im_disp : 2; 69 70 /* A bit for the CPU specific code. 71 This probably can be folded into tc_fix_data, below. */ 72 unsigned fx_tcbit : 1; 73 74 /* Has this relocation already been applied? */ 75 unsigned fx_done : 1; 76 77 /* Suppress overflow complaints on large addends. This is used 78 in the PowerPC ELF config to allow large addends on the 79 BFD_RELOC_{LO16,HI16,HI16_S} relocations. 80 81 @@ Can this be determined from BFD? */ 82 unsigned fx_no_overflow : 1; 83 84 /* Which frag does this fix apply to? */ 85 fragS *fx_frag; 86 87 /* Where is the first byte to fix up? */ 88 long fx_where; 89 90 /* NULL or Symbol whose value we add in. */ 91 symbolS *fx_addsy; 92 93 /* NULL or Symbol whose value we subtract. */ 94 symbolS *fx_subsy; 95 96 #if defined(TE_NetBSD) || defined (TE_OpenBSD) 97 /* NULL or __GLOBAL_OFFSET_TABLE_ . */ 98 symbolS *fx_gotsy; 99 #endif 100 101 /* Absolute number we add in. */ 102 valueT fx_offset; 103 104 /* Next fixS in linked list, or NULL. */ 105 struct fix *fx_next; 106 107 /* If NULL, no bitfix's to do. */ 108 /* Only i960-coff and ns32k use this, and i960-coff stores an 109 integer. This can probably be folded into tc_fix_data, below. 110 @@ Alpha also uses it, but only to disable certain relocation 111 processing. */ 112 bit_fixS *fx_bit_fixP; 113 114 #ifdef BFD_ASSEMBLER 115 bfd_reloc_code_real_type fx_r_type; 116 #else 117 #ifdef NEED_FX_R_TYPE 118 /* Hack for machines where the type of reloc can't be 119 worked out by looking at how big it is. */ 120 int fx_r_type; 121 #endif 122 #endif 123 124 /* This field is sort of misnamed. It appears to be a sort of random 125 scratch field, for use by the back ends. The main gas code doesn't 126 do anything but initialize it to zero. The use of it does need to 127 be coordinated between the cpu and format files, though. E.g., some 128 coff targets pass the `addend' field from the cpu file via this 129 field. I don't know why the `fx_offset' field above can't be used 130 for that; investigate later and document. KR */ 131 valueT fx_addnumber; 132 133 /* The location of the instruction which created the reloc, used 134 in error messages. */ 135 char *fx_file; 136 unsigned fx_line; 137 138 #ifdef USING_CGEN 139 struct { 140 /* CGEN_INSN entry for this instruction. */ 141 const struct cgen_insn *insn; 142 /* Target specific data, usually reloc number. */ 143 int opinfo; 144 } fx_cgen; 145 #endif 146 147 #ifdef TC_FIX_TYPE 148 /* Location where a backend can attach additional data 149 needed to perform fixups. */ 150 TC_FIX_TYPE tc_fix_data; 151 #endif 152 }; 153 154 typedef struct fix fixS; 155 156 #ifndef BFD_ASSEMBLER 157 extern char *next_object_file_charP; 158 159 #ifndef MANY_SEGMENTS 160 COMMON fixS *text_fix_root, *text_fix_tail; /* Chains fixSs. */ 161 COMMON fixS *data_fix_root, *data_fix_tail; /* Chains fixSs. */ 162 COMMON fixS *bss_fix_root, *bss_fix_tail; /* Chains fixSs. */ 163 extern struct frag *text_last_frag; /* Last frag in segment. */ 164 extern struct frag *data_last_frag; /* Last frag in segment. */ 165 #endif 166 COMMON fixS **seg_fix_rootP, **seg_fix_tailP; /* -> one of above. */ 167 #endif 168 169 extern long string_byte_count; 170 extern int section_alignment[]; 171 172 extern bit_fixS *bit_fix_new 173 PARAMS ((int size, int offset, long base_type, long base_adj, long min, 174 long max, long add)); 175 extern void append PARAMS ((char **charPP, char *fromP, unsigned long length)); 176 extern void record_alignment PARAMS ((segT seg, int align)); 177 extern void subsegs_finish PARAMS ((void)); 178 extern void write_object_file PARAMS ((void)); 179 extern void relax_segment 180 PARAMS ((struct frag * seg_frag_root, segT seg_type)); 181 182 extern void number_to_chars_littleendian PARAMS ((char *, valueT, int)); 183 extern void number_to_chars_bigendian PARAMS ((char *, valueT, int)); 184 185 #ifdef BFD_ASSEMBLER 186 extern fixS *fix_new 187 PARAMS ((fragS * frag, int where, int size, symbolS * add_symbol, 188 offsetT offset, int pcrel, bfd_reloc_code_real_type r_type)); 189 extern fixS *fix_new_exp 190 PARAMS ((fragS * frag, int where, int size, expressionS *exp, int pcrel, 191 bfd_reloc_code_real_type r_type)); 192 #else 193 extern fixS *fix_new 194 PARAMS ((fragS * frag, int where, int size, symbolS * add_symbol, 195 offsetT offset, int pcrel, int r_type)); 196 extern fixS *fix_new_exp 197 PARAMS ((fragS * frag, int where, int size, expressionS *exp, int pcrel, 198 int r_type)); 199 #endif 200 201 extern void write_print_statistics PARAMS ((FILE *)); 202 203 #endif /* __write_h__ */ 204 /* end of write.h */ 205