133965Sjdp/* write.h 2218822Sdim Copyright 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 3218822Sdim 2002, 2003, 2005, 2006, 2007 477298Sobrien Free Software Foundation, Inc. 533965Sjdp 633965Sjdp This file is part of GAS, the GNU Assembler. 733965Sjdp 833965Sjdp GAS is free software; you can redistribute it and/or modify 933965Sjdp it under the terms of the GNU General Public License as published by 1033965Sjdp the Free Software Foundation; either version 2, or (at your option) 1133965Sjdp any later version. 1233965Sjdp 1333965Sjdp GAS is distributed in the hope that it will be useful, 1433965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1533965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1633965Sjdp GNU General Public License for more details. 1733965Sjdp 1833965Sjdp You should have received a copy of the GNU General Public License 1933965Sjdp along with GAS; see the file COPYING. If not, write to the Free 20218822Sdim Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 21218822Sdim 02110-1301, USA. */ 2233965Sjdp 2360484Sobrien#ifndef __write_h__ 2460484Sobrien#define __write_h__ 2560484Sobrien 2633965Sjdp/* This is the name of a fake symbol which will never appear in the 2733965Sjdp assembler output. S_IS_LOCAL detects it because of the \001. */ 28130561Sobrien#ifndef FAKE_LABEL_NAME 2933965Sjdp#define FAKE_LABEL_NAME "L0\001" 30130561Sobrien#endif 3133965Sjdp 3233965Sjdp#include "bit_fix.h" 3333965Sjdp 3433965Sjdp/* 3533965Sjdp * FixSs may be built up in any order. 3633965Sjdp */ 3733965Sjdp 3833965Sjdpstruct fix 3933965Sjdp{ 4033965Sjdp /* These small fields are grouped together for compactness of 4133965Sjdp this structure, and efficiency of access on some architectures. */ 4233965Sjdp 4333965Sjdp /* Is this a pc-relative relocation? */ 4433965Sjdp unsigned fx_pcrel : 1; 4533965Sjdp 4633965Sjdp /* Is this value an immediate displacement? */ 47218822Sdim /* Only used on ns32k; merge it into TC_FIX_TYPE sometime. */ 4833965Sjdp unsigned fx_im_disp : 2; 4933965Sjdp 50218822Sdim /* Some bits for the CPU specific code. */ 5133965Sjdp unsigned fx_tcbit : 1; 52218822Sdim unsigned fx_tcbit2 : 1; 5333965Sjdp 5433965Sjdp /* Has this relocation already been applied? */ 5533965Sjdp unsigned fx_done : 1; 5633965Sjdp 5733965Sjdp /* Suppress overflow complaints on large addends. This is used 5833965Sjdp in the PowerPC ELF config to allow large addends on the 5933965Sjdp BFD_RELOC_{LO16,HI16,HI16_S} relocations. 6033965Sjdp 6133965Sjdp @@ Can this be determined from BFD? */ 6233965Sjdp unsigned fx_no_overflow : 1; 6333965Sjdp 6433965Sjdp /* The value is signed when checking for overflow. */ 6533965Sjdp unsigned fx_signed : 1; 6633965Sjdp 67218822Sdim /* pc-relative offset adjust (only used by m68k and m68hc11) */ 68218822Sdim char fx_pcrel_adjust; 69218822Sdim 70218822Sdim /* How many bytes are involved? */ 71218822Sdim unsigned char fx_size; 72218822Sdim 7333965Sjdp /* Which frag does this fix apply to? */ 7433965Sjdp fragS *fx_frag; 7533965Sjdp 7633965Sjdp /* Where is the first byte to fix up? */ 7733965Sjdp long fx_where; 7833965Sjdp 7977298Sobrien /* NULL or Symbol whose value we add in. */ 8033965Sjdp symbolS *fx_addsy; 8133965Sjdp 8277298Sobrien /* NULL or Symbol whose value we subtract. */ 8333965Sjdp symbolS *fx_subsy; 8433965Sjdp 8577298Sobrien /* Absolute number we add in. */ 8633965Sjdp valueT fx_offset; 8733965Sjdp 88130561Sobrien /* The value of dot when the fixup expression was parsed. */ 89130561Sobrien addressT fx_dot_value; 90130561Sobrien 9133965Sjdp /* Next fixS in linked list, or NULL. */ 9233965Sjdp struct fix *fx_next; 9333965Sjdp 9433965Sjdp /* If NULL, no bitfix's to do. */ 9533965Sjdp /* Only i960-coff and ns32k use this, and i960-coff stores an 9633965Sjdp integer. This can probably be folded into tc_fix_data, below. 9733965Sjdp @@ Alpha also uses it, but only to disable certain relocation 9833965Sjdp processing. */ 9933965Sjdp bit_fixS *fx_bit_fixP; 10033965Sjdp 10133965Sjdp bfd_reloc_code_real_type fx_r_type; 10233965Sjdp 10333965Sjdp /* This field is sort of misnamed. It appears to be a sort of random 10433965Sjdp scratch field, for use by the back ends. The main gas code doesn't 10533965Sjdp do anything but initialize it to zero. The use of it does need to 10633965Sjdp be coordinated between the cpu and format files, though. E.g., some 10733965Sjdp coff targets pass the `addend' field from the cpu file via this 10833965Sjdp field. I don't know why the `fx_offset' field above can't be used 10933965Sjdp for that; investigate later and document. KR */ 11033965Sjdp valueT fx_addnumber; 11133965Sjdp 11233965Sjdp /* The location of the instruction which created the reloc, used 11333965Sjdp in error messages. */ 11433965Sjdp char *fx_file; 11533965Sjdp unsigned fx_line; 11633965Sjdp 11760484Sobrien#ifdef USING_CGEN 11860484Sobrien struct { 11960484Sobrien /* CGEN_INSN entry for this instruction. */ 12060484Sobrien const struct cgen_insn *insn; 12160484Sobrien /* Target specific data, usually reloc number. */ 12260484Sobrien int opinfo; 123218822Sdim /* Which ifield this fixup applies to. */ 124218822Sdim struct cgen_maybe_multi_ifield * field; 125218822Sdim /* is this field is the MSB field in a set? */ 126218822Sdim int msb_field_p; 12760484Sobrien } fx_cgen; 12860484Sobrien#endif 12960484Sobrien 13033965Sjdp#ifdef TC_FIX_TYPE 13133965Sjdp /* Location where a backend can attach additional data 13233965Sjdp needed to perform fixups. */ 13333965Sjdp TC_FIX_TYPE tc_fix_data; 13433965Sjdp#endif 13533965Sjdp}; 13633965Sjdp 13733965Sjdptypedef struct fix fixS; 13833965Sjdp 139218822Sdimstruct reloc_list 140218822Sdim{ 141218822Sdim struct reloc_list *next; 142218822Sdim union 143218822Sdim { 144218822Sdim struct 145218822Sdim { 146218822Sdim symbolS *offset_sym; 147218822Sdim reloc_howto_type *howto; 148218822Sdim symbolS *sym; 149218822Sdim bfd_vma addend; 150218822Sdim } a; 151218822Sdim struct 152218822Sdim { 153218822Sdim asection *sec; 154218822Sdim asymbol *s; 155218822Sdim arelent r; 156218822Sdim } b; 157218822Sdim } u; 158218822Sdim char *file; 159218822Sdim unsigned int line; 160218822Sdim}; 161218822Sdim 16289857Sobrienextern int finalize_syms; 163130561Sobrienextern symbolS *abs_section_sym; 164130561Sobrienextern addressT dot_value; 165218822Sdimextern struct reloc_list* reloc_list; 16689857Sobrien 167130561Sobrienextern void append (char **charPP, char *fromP, unsigned long length); 168130561Sobrienextern void record_alignment (segT seg, int align); 169130561Sobrienextern int get_recorded_alignment (segT seg); 170130561Sobrienextern void subsegs_finish (void); 171130561Sobrienextern void write_object_file (void); 172130561Sobrienextern long relax_frag (segT, fragS *, long); 173218822Sdimextern int relax_segment (struct frag *, segT, int); 174130561Sobrienextern void number_to_chars_littleendian (char *, valueT, int); 175130561Sobrienextern void number_to_chars_bigendian (char *, valueT, int); 17633965Sjdpextern fixS *fix_new 177130561Sobrien (fragS * frag, int where, int size, symbolS * add_symbol, 178130561Sobrien offsetT offset, int pcrel, bfd_reloc_code_real_type r_type); 17933965Sjdpextern fixS *fix_new_exp 180130561Sobrien (fragS * frag, int where, int size, expressionS *exp, int pcrel, 181130561Sobrien bfd_reloc_code_real_type r_type); 182130561Sobrienextern void write_print_statistics (FILE *); 18333965Sjdp 18460484Sobrien#endif /* __write_h__ */ 185