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