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