xref: /openbsd-src/gnu/usr.bin/binutils-2.17/gas/write.h (revision 3d8817e467ea46cf4772788d6804dd293abfb01a)
1*3d8817e4Smiod /* write.h
2*3d8817e4Smiod    Copyright 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
3*3d8817e4Smiod    2002, 2003, 2005, 2006 Free Software Foundation, Inc.
4*3d8817e4Smiod 
5*3d8817e4Smiod    This file is part of GAS, the GNU Assembler.
6*3d8817e4Smiod 
7*3d8817e4Smiod    GAS is free software; you can redistribute it and/or modify
8*3d8817e4Smiod    it under the terms of the GNU General Public License as published by
9*3d8817e4Smiod    the Free Software Foundation; either version 2, or (at your option)
10*3d8817e4Smiod    any later version.
11*3d8817e4Smiod 
12*3d8817e4Smiod    GAS is distributed in the hope that it will be useful,
13*3d8817e4Smiod    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*3d8817e4Smiod    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*3d8817e4Smiod    GNU General Public License for more details.
16*3d8817e4Smiod 
17*3d8817e4Smiod    You should have received a copy of the GNU General Public License
18*3d8817e4Smiod    along with GAS; see the file COPYING.  If not, write to the Free
19*3d8817e4Smiod    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20*3d8817e4Smiod    02110-1301, USA.  */
21*3d8817e4Smiod 
22*3d8817e4Smiod #ifndef __write_h__
23*3d8817e4Smiod #define __write_h__
24*3d8817e4Smiod 
25*3d8817e4Smiod #ifndef TC_I960
26*3d8817e4Smiod #ifdef hpux
27*3d8817e4Smiod #define EXEC_MACHINE_TYPE HP9000S200_ID
28*3d8817e4Smiod #endif
29*3d8817e4Smiod #endif /* TC_I960 */
30*3d8817e4Smiod 
31*3d8817e4Smiod /* This is the name of a fake symbol which will never appear in the
32*3d8817e4Smiod    assembler output.  S_IS_LOCAL detects it because of the \001.  */
33*3d8817e4Smiod #ifndef FAKE_LABEL_NAME
34*3d8817e4Smiod #define FAKE_LABEL_NAME "L0\001"
35*3d8817e4Smiod #endif
36*3d8817e4Smiod 
37*3d8817e4Smiod #include "bit_fix.h"
38*3d8817e4Smiod 
39*3d8817e4Smiod /*
40*3d8817e4Smiod  * FixSs may be built up in any order.
41*3d8817e4Smiod  */
42*3d8817e4Smiod 
43*3d8817e4Smiod struct fix
44*3d8817e4Smiod {
45*3d8817e4Smiod   /* These small fields are grouped together for compactness of
46*3d8817e4Smiod      this structure, and efficiency of access on some architectures.  */
47*3d8817e4Smiod 
48*3d8817e4Smiod   /* pc-relative offset adjust (only used by m68k) */
49*3d8817e4Smiod   char fx_pcrel_adjust;
50*3d8817e4Smiod 
51*3d8817e4Smiod   /* How many bytes are involved? */
52*3d8817e4Smiod   unsigned char fx_size;
53*3d8817e4Smiod 
54*3d8817e4Smiod   /* Is this a pc-relative relocation?  */
55*3d8817e4Smiod   unsigned fx_pcrel : 1;
56*3d8817e4Smiod 
57*3d8817e4Smiod   /* Is this a relocation to a procedure linkage table entry?  If so,
58*3d8817e4Smiod      some of the reductions we try to apply are invalid.  A better way
59*3d8817e4Smiod      might be to represent PLT entries with different kinds of
60*3d8817e4Smiod      symbols, and use normal relocations (with undefined symbols);
61*3d8817e4Smiod      look into it for version 2.6.  */
62*3d8817e4Smiod   unsigned fx_plt : 1;
63*3d8817e4Smiod 
64*3d8817e4Smiod   /* Is this value an immediate displacement?  */
65*3d8817e4Smiod   /* Only used on i960 and ns32k; merge it into TC_FIX_TYPE sometime.  */
66*3d8817e4Smiod   unsigned fx_im_disp : 2;
67*3d8817e4Smiod 
68*3d8817e4Smiod   /* A bit for the CPU specific code.
69*3d8817e4Smiod      This probably can be folded into tc_fix_data, below.  */
70*3d8817e4Smiod   unsigned fx_tcbit : 1;
71*3d8817e4Smiod 
72*3d8817e4Smiod   /* Has this relocation already been applied?  */
73*3d8817e4Smiod   unsigned fx_done : 1;
74*3d8817e4Smiod 
75*3d8817e4Smiod   /* Suppress overflow complaints on large addends.  This is used
76*3d8817e4Smiod      in the PowerPC ELF config to allow large addends on the
77*3d8817e4Smiod      BFD_RELOC_{LO16,HI16,HI16_S} relocations.
78*3d8817e4Smiod 
79*3d8817e4Smiod      @@ Can this be determined from BFD?  */
80*3d8817e4Smiod   unsigned fx_no_overflow : 1;
81*3d8817e4Smiod 
82*3d8817e4Smiod   /* The value is signed when checking for overflow.  */
83*3d8817e4Smiod   unsigned fx_signed : 1;
84*3d8817e4Smiod 
85*3d8817e4Smiod   /* Which frag does this fix apply to?  */
86*3d8817e4Smiod   fragS *fx_frag;
87*3d8817e4Smiod 
88*3d8817e4Smiod   /* Where is the first byte to fix up?  */
89*3d8817e4Smiod   long fx_where;
90*3d8817e4Smiod 
91*3d8817e4Smiod   /* NULL or Symbol whose value we add in.  */
92*3d8817e4Smiod   symbolS *fx_addsy;
93*3d8817e4Smiod 
94*3d8817e4Smiod   /* NULL or Symbol whose value we subtract.  */
95*3d8817e4Smiod   symbolS *fx_subsy;
96*3d8817e4Smiod 
97*3d8817e4Smiod   /* Absolute number we add in.  */
98*3d8817e4Smiod   valueT fx_offset;
99*3d8817e4Smiod 
100*3d8817e4Smiod   /* The value of dot when the fixup expression was parsed.  */
101*3d8817e4Smiod   addressT fx_dot_value;
102*3d8817e4Smiod 
103*3d8817e4Smiod   /* Next fixS in linked list, or NULL.  */
104*3d8817e4Smiod   struct fix *fx_next;
105*3d8817e4Smiod 
106*3d8817e4Smiod   /* If NULL, no bitfix's to do.  */
107*3d8817e4Smiod   /* Only i960-coff and ns32k use this, and i960-coff stores an
108*3d8817e4Smiod      integer.  This can probably be folded into tc_fix_data, below.
109*3d8817e4Smiod      @@ Alpha also uses it, but only to disable certain relocation
110*3d8817e4Smiod      processing.  */
111*3d8817e4Smiod   bit_fixS *fx_bit_fixP;
112*3d8817e4Smiod 
113*3d8817e4Smiod   bfd_reloc_code_real_type fx_r_type;
114*3d8817e4Smiod 
115*3d8817e4Smiod   /* This field is sort of misnamed.  It appears to be a sort of random
116*3d8817e4Smiod      scratch field, for use by the back ends.  The main gas code doesn't
117*3d8817e4Smiod      do anything but initialize it to zero.  The use of it does need to
118*3d8817e4Smiod      be coordinated between the cpu and format files, though.  E.g., some
119*3d8817e4Smiod      coff targets pass the `addend' field from the cpu file via this
120*3d8817e4Smiod      field.  I don't know why the `fx_offset' field above can't be used
121*3d8817e4Smiod      for that; investigate later and document. KR  */
122*3d8817e4Smiod   valueT fx_addnumber;
123*3d8817e4Smiod 
124*3d8817e4Smiod   /* The location of the instruction which created the reloc, used
125*3d8817e4Smiod      in error messages.  */
126*3d8817e4Smiod   char *fx_file;
127*3d8817e4Smiod   unsigned fx_line;
128*3d8817e4Smiod 
129*3d8817e4Smiod #ifdef USING_CGEN
130*3d8817e4Smiod   struct {
131*3d8817e4Smiod     /* CGEN_INSN entry for this instruction.  */
132*3d8817e4Smiod     const struct cgen_insn *insn;
133*3d8817e4Smiod     /* Target specific data, usually reloc number.  */
134*3d8817e4Smiod     int opinfo;
135*3d8817e4Smiod   } fx_cgen;
136*3d8817e4Smiod #endif
137*3d8817e4Smiod 
138*3d8817e4Smiod #ifdef TC_FIX_TYPE
139*3d8817e4Smiod   /* Location where a backend can attach additional data
140*3d8817e4Smiod      needed to perform fixups.  */
141*3d8817e4Smiod   TC_FIX_TYPE tc_fix_data;
142*3d8817e4Smiod #endif
143*3d8817e4Smiod };
144*3d8817e4Smiod 
145*3d8817e4Smiod typedef struct fix fixS;
146*3d8817e4Smiod 
147*3d8817e4Smiod extern int finalize_syms;
148*3d8817e4Smiod extern symbolS *abs_section_sym;
149*3d8817e4Smiod extern addressT dot_value;
150*3d8817e4Smiod extern long string_byte_count;
151*3d8817e4Smiod extern int section_alignment[];
152*3d8817e4Smiod 
153*3d8817e4Smiod extern void append (char **charPP, char *fromP, unsigned long length);
154*3d8817e4Smiod extern void record_alignment (segT seg, int align);
155*3d8817e4Smiod extern int get_recorded_alignment (segT seg);
156*3d8817e4Smiod extern void subsegs_finish (void);
157*3d8817e4Smiod extern void write_object_file (void);
158*3d8817e4Smiod extern long relax_frag (segT, fragS *, long);
159*3d8817e4Smiod extern int relax_segment (struct frag *, segT, int);
160*3d8817e4Smiod extern void number_to_chars_littleendian (char *, valueT, int);
161*3d8817e4Smiod extern void number_to_chars_bigendian (char *, valueT, int);
162*3d8817e4Smiod extern fixS *fix_new
163*3d8817e4Smiod   (fragS * frag, int where, int size, symbolS * add_symbol,
164*3d8817e4Smiod    offsetT offset, int pcrel, bfd_reloc_code_real_type r_type);
165*3d8817e4Smiod extern fixS *fix_new_exp
166*3d8817e4Smiod   (fragS * frag, int where, int size, expressionS *exp, int pcrel,
167*3d8817e4Smiod    bfd_reloc_code_real_type r_type);
168*3d8817e4Smiod extern void write_print_statistics (FILE *);
169*3d8817e4Smiod 
170*3d8817e4Smiod #endif /* __write_h__ */
171