12159047fSniklas /* write.h 2b55d4692Sfgsch Copyright 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001 3b55d4692Sfgsch Free Software Foundation, Inc. 42159047fSniklas 52159047fSniklas This file is part of GAS, the GNU Assembler. 62159047fSniklas 72159047fSniklas GAS is free software; you can redistribute it and/or modify 82159047fSniklas it under the terms of the GNU General Public License as published by 92159047fSniklas the Free Software Foundation; either version 2, or (at your option) 102159047fSniklas any later version. 112159047fSniklas 122159047fSniklas GAS is distributed in the hope that it will be useful, 132159047fSniklas but WITHOUT ANY WARRANTY; without even the implied warranty of 142159047fSniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 152159047fSniklas GNU General Public License for more details. 162159047fSniklas 172159047fSniklas You should have received a copy of the GNU General Public License 186a4c786fSespie along with GAS; see the file COPYING. If not, write to the Free 196a4c786fSespie Software Foundation, 59 Temple Place - Suite 330, Boston, MA 206a4c786fSespie 02111-1307, USA. */ 212159047fSniklas 22b305b0f1Sespie #ifndef __write_h__ 23b305b0f1Sespie #define __write_h__ 24b305b0f1Sespie 252159047fSniklas #ifndef TC_I960 262159047fSniklas #ifdef hpux 272159047fSniklas #define EXEC_MACHINE_TYPE HP9000S200_ID 282159047fSniklas #endif 292159047fSniklas #endif /* TC_I960 */ 302159047fSniklas 316a4c786fSespie #ifndef BFD_ASSEMBLER 326a4c786fSespie 332159047fSniklas #ifndef LOCAL_LABEL 342159047fSniklas #define LOCAL_LABEL(name) (name [0] == 'L' ) 352159047fSniklas #endif 362159047fSniklas 372159047fSniklas #define S_LOCAL_NAME(s) (LOCAL_LABEL (S_GET_NAME (s))) 382159047fSniklas 396a4c786fSespie #endif /* ! BFD_ASSEMBLER */ 406a4c786fSespie 416a4c786fSespie /* This is the name of a fake symbol which will never appear in the 426a4c786fSespie assembler output. S_IS_LOCAL detects it because of the \001. */ 43*007c2a45Smiod #ifndef FAKE_LABEL_NAME 446a4c786fSespie #define FAKE_LABEL_NAME "L0\001" 45*007c2a45Smiod #endif 466a4c786fSespie 472159047fSniklas #include "bit_fix.h" 482159047fSniklas 492159047fSniklas /* 502159047fSniklas * FixSs may be built up in any order. 512159047fSniklas */ 522159047fSniklas 532159047fSniklas struct fix 542159047fSniklas { 552159047fSniklas /* These small fields are grouped together for compactness of 562159047fSniklas this structure, and efficiency of access on some architectures. */ 572159047fSniklas 58b305b0f1Sespie /* pc-relative offset adjust (only used by m68k) */ 592159047fSniklas char fx_pcrel_adjust; 602159047fSniklas 612159047fSniklas /* How many bytes are involved? */ 622159047fSniklas unsigned char fx_size; 632159047fSniklas 642159047fSniklas /* Is this a pc-relative relocation? */ 652159047fSniklas unsigned fx_pcrel : 1; 662159047fSniklas 672159047fSniklas /* Is this a relocation to a procedure linkage table entry? If so, 682159047fSniklas some of the reductions we try to apply are invalid. A better way 692159047fSniklas might be to represent PLT entries with different kinds of 702159047fSniklas symbols, and use normal relocations (with undefined symbols); 712159047fSniklas look into it for version 2.6. */ 722159047fSniklas unsigned fx_plt : 1; 732159047fSniklas 742159047fSniklas /* Is this value an immediate displacement? */ 752159047fSniklas /* Only used on i960 and ns32k; merge it into TC_FIX_TYPE sometime. */ 762159047fSniklas unsigned fx_im_disp : 2; 772159047fSniklas 782159047fSniklas /* A bit for the CPU specific code. 792159047fSniklas This probably can be folded into tc_fix_data, below. */ 802159047fSniklas unsigned fx_tcbit : 1; 812159047fSniklas 822159047fSniklas /* Has this relocation already been applied? */ 832159047fSniklas unsigned fx_done : 1; 842159047fSniklas 852159047fSniklas /* Suppress overflow complaints on large addends. This is used 862159047fSniklas in the PowerPC ELF config to allow large addends on the 872159047fSniklas BFD_RELOC_{LO16,HI16,HI16_S} relocations. 882159047fSniklas 892159047fSniklas @@ Can this be determined from BFD? */ 902159047fSniklas unsigned fx_no_overflow : 1; 912159047fSniklas 926a4c786fSespie /* The value is signed when checking for overflow. */ 936a4c786fSespie unsigned fx_signed : 1; 946a4c786fSespie 952159047fSniklas /* Which frag does this fix apply to? */ 962159047fSniklas fragS *fx_frag; 972159047fSniklas 982159047fSniklas /* Where is the first byte to fix up? */ 992159047fSniklas long fx_where; 1002159047fSniklas 1012159047fSniklas /* NULL or Symbol whose value we add in. */ 1022159047fSniklas symbolS *fx_addsy; 1032159047fSniklas 1042159047fSniklas /* NULL or Symbol whose value we subtract. */ 1052159047fSniklas symbolS *fx_subsy; 1062159047fSniklas 1072159047fSniklas /* Absolute number we add in. */ 1082159047fSniklas valueT fx_offset; 1092159047fSniklas 110c074d1c9Sdrahn /* The value of dot when the fixup expression was parsed. */ 111c074d1c9Sdrahn addressT fx_dot_value; 112c074d1c9Sdrahn 1132159047fSniklas /* Next fixS in linked list, or NULL. */ 1142159047fSniklas struct fix *fx_next; 1152159047fSniklas 1162159047fSniklas /* If NULL, no bitfix's to do. */ 1172159047fSniklas /* Only i960-coff and ns32k use this, and i960-coff stores an 118191aa565Sniklas integer. This can probably be folded into tc_fix_data, below. 119191aa565Sniklas @@ Alpha also uses it, but only to disable certain relocation 120191aa565Sniklas processing. */ 1212159047fSniklas bit_fixS *fx_bit_fixP; 1222159047fSniklas 1232159047fSniklas #ifdef BFD_ASSEMBLER 1242159047fSniklas bfd_reloc_code_real_type fx_r_type; 1252159047fSniklas #else 1262159047fSniklas #ifdef NEED_FX_R_TYPE 1272159047fSniklas /* Hack for machines where the type of reloc can't be 1282159047fSniklas worked out by looking at how big it is. */ 1292159047fSniklas int fx_r_type; 1302159047fSniklas #endif 1312159047fSniklas #endif 1322159047fSniklas 1332159047fSniklas /* This field is sort of misnamed. It appears to be a sort of random 1342159047fSniklas scratch field, for use by the back ends. The main gas code doesn't 1352159047fSniklas do anything but initialize it to zero. The use of it does need to 1362159047fSniklas be coordinated between the cpu and format files, though. E.g., some 1372159047fSniklas coff targets pass the `addend' field from the cpu file via this 1382159047fSniklas field. I don't know why the `fx_offset' field above can't be used 1392159047fSniklas for that; investigate later and document. KR */ 1402159047fSniklas valueT fx_addnumber; 1412159047fSniklas 1422159047fSniklas /* The location of the instruction which created the reloc, used 1432159047fSniklas in error messages. */ 1442159047fSniklas char *fx_file; 1452159047fSniklas unsigned fx_line; 1462159047fSniklas 147b305b0f1Sespie #ifdef USING_CGEN 148b305b0f1Sespie struct { 149b305b0f1Sespie /* CGEN_INSN entry for this instruction. */ 150b305b0f1Sespie const struct cgen_insn *insn; 151b305b0f1Sespie /* Target specific data, usually reloc number. */ 152b305b0f1Sespie int opinfo; 153b305b0f1Sespie } fx_cgen; 154b305b0f1Sespie #endif 155b305b0f1Sespie 1562159047fSniklas #ifdef TC_FIX_TYPE 1572159047fSniklas /* Location where a backend can attach additional data 1582159047fSniklas needed to perform fixups. */ 1592159047fSniklas TC_FIX_TYPE tc_fix_data; 1602159047fSniklas #endif 1612159047fSniklas }; 1622159047fSniklas 1632159047fSniklas typedef struct fix fixS; 1642159047fSniklas 165c074d1c9Sdrahn extern int finalize_syms; 166c074d1c9Sdrahn extern symbolS *abs_section_sym; 167c074d1c9Sdrahn extern addressT dot_value; 168c074d1c9Sdrahn 1692159047fSniklas #ifndef BFD_ASSEMBLER 1702159047fSniklas extern char *next_object_file_charP; 1712159047fSniklas 1722159047fSniklas #ifndef MANY_SEGMENTS 1732159047fSniklas COMMON fixS *text_fix_root, *text_fix_tail; /* Chains fixSs. */ 1742159047fSniklas COMMON fixS *data_fix_root, *data_fix_tail; /* Chains fixSs. */ 1752159047fSniklas COMMON fixS *bss_fix_root, *bss_fix_tail; /* Chains fixSs. */ 1762159047fSniklas extern struct frag *text_last_frag; /* Last frag in segment. */ 1772159047fSniklas extern struct frag *data_last_frag; /* Last frag in segment. */ 1782159047fSniklas #endif 1792159047fSniklas COMMON fixS **seg_fix_rootP, **seg_fix_tailP; /* -> one of above. */ 1802159047fSniklas #endif 1812159047fSniklas 1822159047fSniklas extern long string_byte_count; 1832159047fSniklas extern int section_alignment[]; 1842159047fSniklas 1850c6d0228Sniklas extern bit_fixS *bit_fix_new 186*007c2a45Smiod (int size, int offset, long base_type, long base_adj, long min, 187*007c2a45Smiod long max, long add); 188*007c2a45Smiod extern void append (char **charPP, char *fromP, unsigned long length); 189*007c2a45Smiod extern void record_alignment (segT seg, int align); 190*007c2a45Smiod extern int get_recorded_alignment (segT seg); 191*007c2a45Smiod extern void subsegs_finish (void); 192*007c2a45Smiod extern void write_object_file (void); 193*007c2a45Smiod extern long relax_frag (segT, fragS *, long); 194*007c2a45Smiod extern int relax_segment (struct frag * seg_frag_root, segT seg_type); 1952159047fSniklas 196*007c2a45Smiod extern void number_to_chars_littleendian (char *, valueT, int); 197*007c2a45Smiod extern void number_to_chars_bigendian (char *, valueT, int); 1982159047fSniklas 1992159047fSniklas #ifdef BFD_ASSEMBLER 2000c6d0228Sniklas extern fixS *fix_new 201*007c2a45Smiod (fragS * frag, int where, int size, symbolS * add_symbol, 202*007c2a45Smiod offsetT offset, int pcrel, bfd_reloc_code_real_type r_type); 2030c6d0228Sniklas extern fixS *fix_new_exp 204*007c2a45Smiod (fragS * frag, int where, int size, expressionS *exp, int pcrel, 205*007c2a45Smiod bfd_reloc_code_real_type r_type); 2062159047fSniklas #else 2070c6d0228Sniklas extern fixS *fix_new 208*007c2a45Smiod (fragS * frag, int where, int size, symbolS * add_symbol, 209*007c2a45Smiod offsetT offset, int pcrel, int r_type); 2100c6d0228Sniklas extern fixS *fix_new_exp 211*007c2a45Smiod (fragS * frag, int where, int size, expressionS *exp, int pcrel, 212*007c2a45Smiod int r_type); 2132159047fSniklas #endif 2142159047fSniklas 215*007c2a45Smiod extern void write_print_statistics (FILE *); 2160c6d0228Sniklas 217b305b0f1Sespie #endif /* __write_h__ */ 218