* libbfd.c (bfd_read): Check result of read against desired result
[binutils.git] / gas / write.h
blob186d2ada1b67498ef116d063213baf673adf901d
1 /* write.h
2 Copyright (C) 1987, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
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 2, or (at your option)
9 any later version.
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.
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, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
21 #ifndef __write_h__
22 #define __write_h__
24 #ifndef TC_I960
25 #ifdef hpux
26 #define EXEC_MACHINE_TYPE HP9000S200_ID
27 #endif
28 #endif /* TC_I960 */
30 #ifndef BFD_ASSEMBLER
32 #ifndef LOCAL_LABEL
33 #define LOCAL_LABEL(name) (name [0] == 'L' )
34 #endif
36 #define S_LOCAL_NAME(s) (LOCAL_LABEL (S_GET_NAME (s)))
38 #endif /* ! BFD_ASSEMBLER */
40 /* This is the name of a fake symbol which will never appear in the
41 assembler output. S_IS_LOCAL detects it because of the \001. */
42 #define FAKE_LABEL_NAME "L0\001"
44 #include "bit_fix.h"
47 * FixSs may be built up in any order.
50 struct fix
52 /* These small fields are grouped together for compactness of
53 this structure, and efficiency of access on some architectures. */
55 /* pc-relative offset adjust (only used by m68k) */
56 char fx_pcrel_adjust;
58 /* How many bytes are involved? */
59 unsigned char fx_size;
61 /* Is this a pc-relative relocation? */
62 unsigned fx_pcrel : 1;
64 /* Is this a relocation to a procedure linkage table entry? If so,
65 some of the reductions we try to apply are invalid. A better way
66 might be to represent PLT entries with different kinds of
67 symbols, and use normal relocations (with undefined symbols);
68 look into it for version 2.6. */
69 unsigned fx_plt : 1;
71 /* Is this value an immediate displacement? */
72 /* Only used on i960 and ns32k; merge it into TC_FIX_TYPE sometime. */
73 unsigned fx_im_disp : 2;
75 /* A bit for the CPU specific code.
76 This probably can be folded into tc_fix_data, below. */
77 unsigned fx_tcbit : 1;
79 /* Has this relocation already been applied? */
80 unsigned fx_done : 1;
82 /* Suppress overflow complaints on large addends. This is used
83 in the PowerPC ELF config to allow large addends on the
84 BFD_RELOC_{LO16,HI16,HI16_S} relocations.
86 @@ Can this be determined from BFD? */
87 unsigned fx_no_overflow : 1;
89 /* The value is signed when checking for overflow. */
90 unsigned fx_signed : 1;
92 /* Which frag does this fix apply to? */
93 fragS *fx_frag;
95 /* Where is the first byte to fix up? */
96 long fx_where;
98 /* NULL or Symbol whose value we add in. */
99 symbolS *fx_addsy;
101 /* NULL or Symbol whose value we subtract. */
102 symbolS *fx_subsy;
104 /* Absolute number we add in. */
105 valueT fx_offset;
107 /* Next fixS in linked list, or NULL. */
108 struct fix *fx_next;
110 /* If NULL, no bitfix's to do. */
111 /* Only i960-coff and ns32k use this, and i960-coff stores an
112 integer. This can probably be folded into tc_fix_data, below.
113 @@ Alpha also uses it, but only to disable certain relocation
114 processing. */
115 bit_fixS *fx_bit_fixP;
117 #ifdef BFD_ASSEMBLER
118 bfd_reloc_code_real_type fx_r_type;
119 #else
120 #ifdef NEED_FX_R_TYPE
121 /* Hack for machines where the type of reloc can't be
122 worked out by looking at how big it is. */
123 int fx_r_type;
124 #endif
125 #endif
127 /* This field is sort of misnamed. It appears to be a sort of random
128 scratch field, for use by the back ends. The main gas code doesn't
129 do anything but initialize it to zero. The use of it does need to
130 be coordinated between the cpu and format files, though. E.g., some
131 coff targets pass the `addend' field from the cpu file via this
132 field. I don't know why the `fx_offset' field above can't be used
133 for that; investigate later and document. KR */
134 valueT fx_addnumber;
136 /* The location of the instruction which created the reloc, used
137 in error messages. */
138 char *fx_file;
139 unsigned fx_line;
141 #ifdef USING_CGEN
142 struct {
143 /* CGEN_INSN entry for this instruction. */
144 const struct cgen_insn *insn;
145 /* Target specific data, usually reloc number. */
146 int opinfo;
147 } fx_cgen;
148 #endif
150 #ifdef TC_FIX_TYPE
151 /* Location where a backend can attach additional data
152 needed to perform fixups. */
153 TC_FIX_TYPE tc_fix_data;
154 #endif
157 typedef struct fix fixS;
159 #ifndef BFD_ASSEMBLER
160 extern char *next_object_file_charP;
162 #ifndef MANY_SEGMENTS
163 COMMON fixS *text_fix_root, *text_fix_tail; /* Chains fixSs. */
164 COMMON fixS *data_fix_root, *data_fix_tail; /* Chains fixSs. */
165 COMMON fixS *bss_fix_root, *bss_fix_tail; /* Chains fixSs. */
166 extern struct frag *text_last_frag; /* Last frag in segment. */
167 extern struct frag *data_last_frag; /* Last frag in segment. */
168 #endif
169 COMMON fixS **seg_fix_rootP, **seg_fix_tailP; /* -> one of above. */
170 #endif
172 extern long string_byte_count;
173 extern int section_alignment[];
175 extern bit_fixS *bit_fix_new
176 PARAMS ((int size, int offset, long base_type, long base_adj, long min,
177 long max, long add));
178 extern void append PARAMS ((char **charPP, char *fromP, unsigned long length));
179 extern void record_alignment PARAMS ((segT seg, int align));
180 extern void subsegs_finish PARAMS ((void));
181 extern void write_object_file PARAMS ((void));
182 extern long relax_frag PARAMS ((fragS *, long));
183 extern void relax_segment
184 PARAMS ((struct frag * seg_frag_root, segT seg_type));
186 extern void number_to_chars_littleendian PARAMS ((char *, valueT, int));
187 extern void number_to_chars_bigendian PARAMS ((char *, valueT, int));
189 #ifdef BFD_ASSEMBLER
190 extern fixS *fix_new
191 PARAMS ((fragS * frag, int where, int size, symbolS * add_symbol,
192 offsetT offset, int pcrel, bfd_reloc_code_real_type r_type));
193 extern fixS *fix_new_exp
194 PARAMS ((fragS * frag, int where, int size, expressionS *exp, int pcrel,
195 bfd_reloc_code_real_type r_type));
196 #else
197 extern fixS *fix_new
198 PARAMS ((fragS * frag, int where, int size, symbolS * add_symbol,
199 offsetT offset, int pcrel, int r_type));
200 extern fixS *fix_new_exp
201 PARAMS ((fragS * frag, int where, int size, expressionS *exp, int pcrel,
202 int r_type));
203 #endif
205 extern void write_print_statistics PARAMS ((FILE *));
207 #endif /* __write_h__ */
208 /* end of write.h */