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