* gas/hppa/reloc/reloc.exp (roundmode test): Tweak expected output
[deliverable/binutils-gdb.git] / bfd / libecoff.h
CommitLineData
dae31cf5
ILT
1/* BFD ECOFF object file private structure.
2 Copyright (C) 1993 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
a3a33af3
ILT
21#include "bfdlink.h"
22
23#ifndef ECOFF_H
24#include "coff/ecoff.h"
25#endif
26
dae31cf5 27/* This is the backend information kept for ECOFF files. This
a3a33af3
ILT
28 structure is constant for a particular backend. The first element
29 is the COFF backend data structure, so that ECOFF targets can use
30 the generic COFF code. */
dae31cf5 31
a3a33af3
ILT
32#define ecoff_backend(abfd) \
33 ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
dae31cf5
ILT
34
35struct ecoff_backend_data
36{
a3a33af3
ILT
37 /* COFF backend information. This must be the first field. */
38 bfd_coff_backend_data coff;
dae31cf5
ILT
39 /* Supported architecture. */
40 enum bfd_architecture arch;
a3a33af3
ILT
41 /* Initial portion of armap string. */
42 const char *armap_start;
dae31cf5
ILT
43 /* The page boundary used to align sections in a demand-paged
44 executable file. E.g., 0x1000. */
45 bfd_vma round;
a3a33af3
ILT
46 /* True if the .rdata section is part of the text segment, as on the
47 Alpha. False if .rdata is part of the data segment, as on the
48 MIPS. */
49 boolean rdata_in_text;
dae31cf5
ILT
50 /* Bitsize of constructor entries. */
51 unsigned int constructor_bitsize;
a3a33af3
ILT
52 /* Reloc to use for constructor entries. */
53 CONST struct reloc_howto_struct *constructor_reloc;
54 /* How to swap debugging information. */
55 struct ecoff_debug_swap debug_swap;
dae31cf5
ILT
56 /* External reloc size. */
57 bfd_size_type external_reloc_size;
58 /* Reloc swapping functions. */
59 void (*swap_reloc_in) PARAMS ((bfd *, PTR, struct internal_reloc *));
60 void (*swap_reloc_out) PARAMS ((bfd *, const struct internal_reloc *, PTR));
a3a33af3
ILT
61 /* Backend reloc tweaking. */
62 void (*adjust_reloc_in) PARAMS ((bfd *, const struct internal_reloc *,
63 arelent *));
64 void (*adjust_reloc_out) PARAMS ((bfd *, const arelent *,
65 struct internal_reloc *));
66 /* Relocate section contents while linking. */
67 boolean (*relocate_section) PARAMS ((bfd *output_bfd, struct bfd_link_info *,
68 bfd *input_bfd, asection *input_section,
69 bfd_byte *contents,
70 PTR external_relocs));
dae31cf5
ILT
71};
72
73/* This is the target specific information kept for ECOFF files. */
74
75#define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
76
77typedef struct ecoff_tdata
78{
dae31cf5
ILT
79 /* The reloc file position, set by
80 ecoff_compute_section_file_positions. */
81 file_ptr reloc_filepos;
82
83 /* The symbol table file position, set by ecoff_mkobject_hook. */
84 file_ptr sym_filepos;
85
86 /* The start and end of the text segment. Only valid for an
87 existing file, not for one we are creating. */
88 unsigned long text_start;
89 unsigned long text_end;
90
91 /* The cached gp value. This is used when relocating. */
92 bfd_vma gp;
93
94 /* The maximum size of objects to optimize using gp. This is
95 typically set by the -G option to the compiler, assembler or
96 linker. */
97 int gp_size;
98
99 /* The register masks. When linking, all the masks found in the
a3a33af3
ILT
100 input files are combined into the masks of the output file.
101 These are not all used for all targets, but that's OK, because
102 the relevant ones are the only ones swapped in and out. */
dae31cf5 103 unsigned long gprmask;
a3a33af3 104 unsigned long fprmask;
dae31cf5
ILT
105 unsigned long cprmask[4];
106
a3a33af3
ILT
107 /* The ECOFF symbolic debugging information. */
108 struct ecoff_debug_info debug_info;
dae31cf5
ILT
109
110 /* The unswapped ECOFF symbolic information. */
111 PTR raw_syments;
112
dae31cf5
ILT
113 /* The canonical BFD symbols. */
114 struct ecoff_symbol_struct *canonical_symbols;
115
a3a33af3
ILT
116 /* A mapping from external symbol numbers to entries in the linker
117 hash table, used when linking. */
118 struct ecoff_link_hash_entry **sym_hashes;
119
120 /* A mapping from reloc symbol indices to sections, used when
121 linking. */
122 asection **symndx_to_section;
123
469984d1
ILT
124 /* True if this BFD was written by the backend linker. */
125 boolean linker;
126
dae31cf5
ILT
127} ecoff_data_type;
128
129/* Each canonical asymbol really looks like this. */
130
131typedef struct ecoff_symbol_struct
132{
133 /* The actual symbol which the rest of BFD works with */
134 asymbol symbol;
135
136 /* The fdr for this symbol. */
137 FDR *fdr;
138
139 /* true if this is a local symbol rather than an external one. */
140 boolean local;
141
142 /* A pointer to the unswapped hidden information for this symbol.
143 This is either a struct sym_ext or a struct ext_ext, depending on
144 the value of the local field above. */
145 PTR native;
146} ecoff_symbol_type;
147
148/* We take the address of the first element of a asymbol to ensure that the
149 macro is only ever applied to an asymbol. */
150#define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
151
152/* This is a hack borrowed from coffcode.h; we need to save the index
153 of an external symbol when we write it out so that can set the
154 symbol index correctly when we write out the relocs. */
155#define ecoff_get_sym_index(symbol) ((unsigned long) (symbol)->udata)
156#define ecoff_set_sym_index(symbol, idx) ((symbol)->udata = (PTR) (idx))
157
a3a33af3
ILT
158/* When generating MIPS embedded PIC code, the linker relaxes the code
159 to turn PC relative branches into longer code sequences when the PC
160 relative branch is out of range. This involves reading the relocs
161 in bfd_relax_section as well as in bfd_final_link, and requires the
162 code to keep track of which relocs have been expanded. A pointer
163 to this structure is put in the used_by_bfd pointer of a section to
164 keep track of this information. The user_by_bfd pointer will be
165 NULL if the information was not needed. */
166
167struct ecoff_section_tdata
168{
169 /* The unswapped relocs for this section. These are stored in
170 memory so the input file does not have to be read twice. */
171 PTR external_relocs;
172
173 /* The contents of the section. These bytes may or may not be saved
174 in memory, but if it is this is a pointer to them. */
175 bfd_byte *contents;
176
177 /* Offset adjustments for PC relative branches. A number other than
14bf9e4b
ILT
178 1 is an addend for a PC relative branch, or a switch table entry
179 which is the difference of two .text locations; this addend
180 arises because the branch or difference crosses one or more
181 branches which were expanded into a larger code sequence. A 1
182 means that this branch was itself expanded into a larger code
183 sequence. 1 is not a possible offset, since all offsets must be
184 multiples of the instruction size, which is 4; also, the only
185 relocs with non-zero offsets will be PC relative branches or
186 switch table entries within the same object file. If this field
187 is NULL, no branches were expanded and no offsets are required.
188 Otherwise there are as many entries as there are relocs in the
189 section, and the entry for any reloc that is not PC relative is
190 zero. */
a3a33af3
ILT
191 long *offsets;
192};
193
194/* An accessor macro for the ecoff_section_tdata structure. */
195#define ecoff_section_data(abfd, sec) \
196 ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
197
198/* ECOFF linker hash table entries. */
199
200struct ecoff_link_hash_entry
201{
202 struct bfd_link_hash_entry root;
203 /* Symbol index in output file. */
204 long indx;
205 /* BFD that ext field value came from. */
206 bfd *abfd;
207 /* ECOFF external symbol information. */
208 EXTR esym;
209};
210
211/* ECOFF linker hash table. */
212
213struct ecoff_link_hash_table
214{
215 struct bfd_link_hash_table root;
216};
217
218/* Make an ECOFF object. */
219extern boolean ecoff_mkobject PARAMS ((bfd *));
dae31cf5
ILT
220
221/* Read in the ECOFF symbolic debugging information. */
222extern boolean ecoff_slurp_symbolic_info PARAMS ((bfd *));
223
224/* Generic ECOFF BFD backend vectors. */
6812b607
ILT
225
226extern boolean ecoff_write_object_contents PARAMS ((bfd *abfd));
227extern bfd_target *ecoff_archive_p PARAMS ((bfd *abfd));
228
229#define ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
230#define ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
231extern boolean ecoff_new_section_hook PARAMS ((bfd *abfd,
232 asection *section));
233extern boolean ecoff_get_section_contents PARAMS ((bfd *abfd,
234 asection *section,
235 PTR location,
236 file_ptr offset,
237 bfd_size_type count));
238
469984d1 239extern boolean ecoff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
6812b607
ILT
240#define ecoff_bfd_copy_private_section_data \
241 _bfd_generic_bfd_copy_private_section_data
242
243extern boolean ecoff_slurp_armap PARAMS ((bfd *abfd));
244#define ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
245#define ecoff_truncate_arname bfd_dont_truncate_arname
246extern boolean ecoff_write_armap PARAMS ((bfd *abfd, unsigned int elength,
247 struct orl *map,
248 unsigned int orl_count,
249 int stridx));
250#define ecoff_openr_next_archived_file bfd_generic_openr_next_archived_file
251#define ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
252
326e32d7
ILT
253extern long ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
254extern long ecoff_get_symtab PARAMS ((bfd *abfd, asymbol **alocation));
6812b607 255extern asymbol *ecoff_make_empty_symbol PARAMS ((bfd *abfd));
dae31cf5
ILT
256extern void ecoff_print_symbol PARAMS ((bfd *abfd, PTR filep,
257 asymbol *symbol,
258 bfd_print_symbol_type how));
6812b607
ILT
259extern void ecoff_get_symbol_info PARAMS ((bfd *abfd,
260 asymbol *symbol,
261 symbol_info *ret));
262#define ecoff_bfd_is_local_label bfd_generic_is_local_label
263#define ecoff_get_lineno _bfd_nosymbols_get_lineno
dae31cf5
ILT
264extern boolean ecoff_find_nearest_line PARAMS ((bfd *abfd,
265 asection *section,
266 asymbol **symbols,
267 bfd_vma offset,
268 CONST char **filename_ptr,
269 CONST char **fnname_ptr,
270 unsigned int *retline_ptr));
6812b607
ILT
271#define ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
272
273#define ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
274extern long ecoff_canonicalize_reloc PARAMS ((bfd *abfd,
275 asection *section,
276 arelent **relptr,
277 asymbol **symbols));
278/* ecoff_bfd_reloc_type_lookup defined by backend. */
279
dae31cf5
ILT
280extern boolean ecoff_set_arch_mach PARAMS ((bfd *abfd,
281 enum bfd_architecture arch,
282 unsigned long machine));
dae31cf5
ILT
283extern boolean ecoff_set_section_contents PARAMS ((bfd *abfd,
284 asection *section,
285 PTR location,
286 file_ptr offset,
287 bfd_size_type count));
6812b607
ILT
288
289extern int ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
290/* ecoff_bfd_get_relocated_section_contents defined by backend. */
291/* ecoff_bfd_relax_section defined by backend. */
a3a33af3
ILT
292extern struct bfd_link_hash_table *ecoff_bfd_link_hash_table_create
293 PARAMS ((bfd *));
294extern boolean ecoff_bfd_link_add_symbols
295 PARAMS ((bfd *, struct bfd_link_info *));
296extern boolean ecoff_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *));
dae31cf5
ILT
297
298/* Hook functions for the generic COFF section reading code. */
6812b607 299
a3a33af3 300extern PTR ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
dae31cf5 301extern asection *ecoff_make_section_hook PARAMS ((bfd *abfd, char *name));
dae31cf5
ILT
302#define ecoff_set_alignment_hook \
303 ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
304extern boolean ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
305extern long ecoff_sec_to_styp_flags PARAMS ((CONST char *name,
306 flagword flags));
307extern flagword ecoff_styp_to_sec_flags PARAMS ((bfd *abfd, PTR hdr));
308extern boolean ecoff_slurp_symbol_table PARAMS ((bfd *abfd));
This page took 0.069171 seconds and 4 git commands to generate.