source: trunk/src/binutils/bfd/doc/bfd.info-6@ 195

Last change on this file since 195 was 10, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 46.0 KB
Line 
1This is bfd.info, produced by makeinfo version 4.0 from bfd.texinfo.
2
3START-INFO-DIR-ENTRY
4* Bfd: (bfd). The Binary File Descriptor library.
5END-INFO-DIR-ENTRY
6
7 This file documents the BFD library.
8
9 Copyright (C) 1991, 2000 Free Software Foundation, Inc.
10
11 Permission is granted to copy, distribute and/or modify this document
12 under the terms of the GNU Free Documentation License, Version 1.1
13 or any later version published by the Free Software Foundation;
14 with no Invariant Sections, with no Front-Cover Texts, and with no
15 Back-Cover Texts. A copy of the license is included in the
16section entitled "GNU Free Documentation License".
17
18
19File: bfd.info, Node: coff, Next: elf, Prev: aout, Up: BFD back ends
20
21coff backends
22=============
23
24 BFD supports a number of different flavours of coff format. The
25major differences between formats are the sizes and alignments of
26fields in structures on disk, and the occasional extra field.
27
28 Coff in all its varieties is implemented with a few common files and
29a number of implementation specific files. For example, The 88k bcs
30coff format is implemented in the file `coff-m88k.c'. This file
31`#include's `coff/m88k.h' which defines the external structure of the
32coff format for the 88k, and `coff/internal.h' which defines the
33internal structure. `coff-m88k.c' also defines the relocations used by
34the 88k format *Note Relocations::.
35
36 The Intel i960 processor version of coff is implemented in
37`coff-i960.c'. This file has the same structure as `coff-m88k.c',
38except that it includes `coff/i960.h' rather than `coff-m88k.h'.
39
40Porting to a new version of coff
41--------------------------------
42
43 The recommended method is to select from the existing
44implementations the version of coff which is most like the one you want
45to use. For example, we'll say that i386 coff is the one you select,
46and that your coff flavour is called foo. Copy `i386coff.c' to
47`foocoff.c', copy `../include/coff/i386.h' to `../include/coff/foo.h',
48and add the lines to `targets.c' and `Makefile.in' so that your new
49back end is used. Alter the shapes of the structures in
50`../include/coff/foo.h' so that they match what you need. You will
51probably also have to add `#ifdef's to the code in `coff/internal.h' and
52`coffcode.h' if your version of coff is too wild.
53
54 You can verify that your new BFD backend works quite simply by
55building `objdump' from the `binutils' directory, and making sure that
56its version of what's going on and your host system's idea (assuming it
57has the pretty standard coff dump utility, usually called `att-dump' or
58just `dump') are the same. Then clean up your code, and send what
59you've done to Cygnus. Then your stuff will be in the next release, and
60you won't have to keep integrating it.
61
62How the coff backend works
63--------------------------
64
65File layout
66...........
67
68 The Coff backend is split into generic routines that are applicable
69to any Coff target and routines that are specific to a particular
70target. The target-specific routines are further split into ones which
71are basically the same for all Coff targets except that they use the
72external symbol format or use different values for certain constants.
73
74 The generic routines are in `coffgen.c'. These routines work for
75any Coff target. They use some hooks into the target specific code;
76the hooks are in a `bfd_coff_backend_data' structure, one of which
77exists for each target.
78
79 The essentially similar target-specific routines are in
80`coffcode.h'. This header file includes executable C code. The
81various Coff targets first include the appropriate Coff header file,
82make any special defines that are needed, and then include `coffcode.h'.
83
84 Some of the Coff targets then also have additional routines in the
85target source file itself.
86
87 For example, `coff-i960.c' includes `coff/internal.h' and
88`coff/i960.h'. It then defines a few constants, such as `I960', and
89includes `coffcode.h'. Since the i960 has complex relocation types,
90`coff-i960.c' also includes some code to manipulate the i960 relocs.
91This code is not in `coffcode.h' because it would not be used by any
92other target.
93
94Bit twiddling
95.............
96
97 Each flavour of coff supported in BFD has its own header file
98describing the external layout of the structures. There is also an
99internal description of the coff layout, in `coff/internal.h'. A major
100function of the coff backend is swapping the bytes and twiddling the
101bits to translate the external form of the structures into the normal
102internal form. This is all performed in the `bfd_swap'_thing_direction
103routines. Some elements are different sizes between different versions
104of coff; it is the duty of the coff version specific include file to
105override the definitions of various packing routines in `coffcode.h'.
106E.g., the size of line number entry in coff is sometimes 16 bits, and
107sometimes 32 bits. `#define'ing `PUT_LNSZ_LNNO' and `GET_LNSZ_LNNO'
108will select the correct one. No doubt, some day someone will find a
109version of coff which has a varying field size not catered to at the
110moment. To port BFD, that person will have to add more `#defines'.
111Three of the bit twiddling routines are exported to `gdb';
112`coff_swap_aux_in', `coff_swap_sym_in' and `coff_swap_lineno_in'. `GDB'
113reads the symbol table on its own, but uses BFD to fix things up. More
114of the bit twiddlers are exported for `gas'; `coff_swap_aux_out',
115`coff_swap_sym_out', `coff_swap_lineno_out', `coff_swap_reloc_out',
116`coff_swap_filehdr_out', `coff_swap_aouthdr_out',
117`coff_swap_scnhdr_out'. `Gas' currently keeps track of all the symbol
118table and reloc drudgery itself, thereby saving the internal BFD
119overhead, but uses BFD to swap things on the way out, making cross
120ports much safer. Doing so also allows BFD (and thus the linker) to
121use the same header files as `gas', which makes one avenue to disaster
122disappear.
123
124Symbol reading
125..............
126
127 The simple canonical form for symbols used by BFD is not rich enough
128to keep all the information available in a coff symbol table. The back
129end gets around this problem by keeping the original symbol table
130around, "behind the scenes".
131
132 When a symbol table is requested (through a call to
133`bfd_canonicalize_symtab'), a request gets through to
134`coff_get_normalized_symtab'. This reads the symbol table from the coff
135file and swaps all the structures inside into the internal form. It
136also fixes up all the pointers in the table (represented in the file by
137offsets from the first symbol in the table) into physical pointers to
138elements in the new internal table. This involves some work since the
139meanings of fields change depending upon context: a field that is a
140pointer to another structure in the symbol table at one moment may be
141the size in bytes of a structure at the next. Another pass is made
142over the table. All symbols which mark file names (`C_FILE' symbols)
143are modified so that the internal string points to the value in the
144auxent (the real filename) rather than the normal text associated with
145the symbol (`".file"').
146
147 At this time the symbol names are moved around. Coff stores all
148symbols less than nine characters long physically within the symbol
149table; longer strings are kept at the end of the file in the string
150table. This pass moves all strings into memory and replaces them with
151pointers to the strings.
152
153 The symbol table is massaged once again, this time to create the
154canonical table used by the BFD application. Each symbol is inspected
155in turn, and a decision made (using the `sclass' field) about the
156various flags to set in the `asymbol'. *Note Symbols::. The generated
157canonical table shares strings with the hidden internal symbol table.
158
159 Any linenumbers are read from the coff file too, and attached to the
160symbols which own the functions the linenumbers belong to.
161
162Symbol writing
163..............
164
165 Writing a symbol to a coff file which didn't come from a coff file
166will lose any debugging information. The `asymbol' structure remembers
167the BFD from which the symbol was taken, and on output the back end
168makes sure that the same destination target as source target is present.
169
170 When the symbols have come from a coff file then all the debugging
171information is preserved.
172
173 Symbol tables are provided for writing to the back end in a vector
174of pointers to pointers. This allows applications like the linker to
175accumulate and output large symbol tables without having to do too much
176byte copying.
177
178 This function runs through the provided symbol table and patches
179each symbol marked as a file place holder (`C_FILE') to point to the
180next file place holder in the list. It also marks each `offset' field
181in the list with the offset from the first symbol of the current symbol.
182
183 Another function of this procedure is to turn the canonical value
184form of BFD into the form used by coff. Internally, BFD expects symbol
185values to be offsets from a section base; so a symbol physically at
1860x120, but in a section starting at 0x100, would have the value 0x20.
187Coff expects symbols to contain their final value, so symbols have
188their values changed at this point to reflect their sum with their
189owning section. This transformation uses the `output_section' field of
190the `asymbol''s `asection' *Note Sections::.
191
192 * `coff_mangle_symbols'
193 This routine runs though the provided symbol table and uses the
194offsets generated by the previous pass and the pointers generated when
195the symbol table was read in to create the structured hierachy required
196by coff. It changes each pointer to a symbol into the index into the
197symbol table of the asymbol.
198
199 * `coff_write_symbols'
200 This routine runs through the symbol table and patches up the
201symbols from their internal form into the coff way, calls the bit
202twiddlers, and writes out the table to the file.
203
204`coff_symbol_type'
205..................
206
207 *Description*
208The hidden information for an `asymbol' is described in a
209`combined_entry_type':
210
211
212 typedef struct coff_ptr_struct
213 {
214
215 /* Remembers the offset from the first symbol in the file for
216 this symbol. Generated by coff_renumber_symbols. */
217 unsigned int offset;
218
219 /* Should the value of this symbol be renumbered. Used for
220 XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */
221 unsigned int fix_value : 1;
222
223 /* Should the tag field of this symbol be renumbered.
224 Created by coff_pointerize_aux. */
225 unsigned int fix_tag : 1;
226
227 /* Should the endidx field of this symbol be renumbered.
228 Created by coff_pointerize_aux. */
229 unsigned int fix_end : 1;
230
231 /* Should the x_csect.x_scnlen field be renumbered.
232 Created by coff_pointerize_aux. */
233 unsigned int fix_scnlen : 1;
234
235 /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
236 index into the line number entries. Set by
237 coff_slurp_symbol_table. */
238 unsigned int fix_line : 1;
239
240 /* The container for the symbol structure as read and translated
241 from the file. */
242
243 union {
244 union internal_auxent auxent;
245 struct internal_syment syment;
246 } u;
247 } combined_entry_type;
248
249
250 /* Each canonical asymbol really looks like this: */
251
252 typedef struct coff_symbol_struct
253 {
254 /* The actual symbol which the rest of BFD works with */
255 asymbol symbol;
256
257 /* A pointer to the hidden information for this symbol */
258 combined_entry_type *native;
259
260 /* A pointer to the linenumber information for this symbol */
261 struct lineno_cache_entry *lineno;
262
263 /* Have the line numbers been relocated yet ? */
264 boolean done_lineno;
265 } coff_symbol_type;
266
267`bfd_coff_backend_data'
268.......................
269
270 /* COFF symbol classifications. */
271
272 enum coff_symbol_classification
273 {
274 /* Global symbol. */
275 COFF_SYMBOL_GLOBAL,
276 /* Common symbol. */
277 COFF_SYMBOL_COMMON,
278 /* Undefined symbol. */
279 COFF_SYMBOL_UNDEFINED,
280 /* Local symbol. */
281 COFF_SYMBOL_LOCAL,
282 /* PE section symbol. */
283 COFF_SYMBOL_PE_SECTION
284 };
285 Special entry points for gdb to swap in coff symbol table parts:
286 typedef struct
287 {
288 void (*_bfd_coff_swap_aux_in) PARAMS ((
289 bfd *abfd,
290 PTR ext,
291 int type,
292 int class,
293 int indaux,
294 int numaux,
295 PTR in));
296
297 void (*_bfd_coff_swap_sym_in) PARAMS ((
298 bfd *abfd ,
299 PTR ext,
300 PTR in));
301
302 void (*_bfd_coff_swap_lineno_in) PARAMS ((
303 bfd *abfd,
304 PTR ext,
305 PTR in));
306 Special entry points for gas to swap out coff parts:
307 unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
308 bfd *abfd,
309 PTR in,
310 int type,
311 int class,
312 int indaux,
313 int numaux,
314 PTR ext));
315
316 unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
317 bfd *abfd,
318 PTR in,
319 PTR ext));
320
321 unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
322 bfd *abfd,
323 PTR in,
324 PTR ext));
325
326 unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
327 bfd *abfd,
328 PTR src,
329 PTR dst));
330
331 unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
332 bfd *abfd,
333 PTR in,
334 PTR out));
335
336 unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
337 bfd *abfd,
338 PTR in,
339 PTR out));
340
341 unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
342 bfd *abfd,
343 PTR in,
344 PTR out));
345 Special entry points for generic COFF routines to call target
346dependent COFF routines:
347 unsigned int _bfd_filhsz;
348 unsigned int _bfd_aoutsz;
349 unsigned int _bfd_scnhsz;
350 unsigned int _bfd_symesz;
351 unsigned int _bfd_auxesz;
352 unsigned int _bfd_relsz;
353 unsigned int _bfd_linesz;
354 unsigned int _bfd_filnmlen;
355 boolean _bfd_coff_long_filenames;
356 boolean _bfd_coff_long_section_names;
357 unsigned int _bfd_coff_default_section_alignment_power;
358 boolean _bfd_coff_force_symnames_in_strings;
359 unsigned int _bfd_coff_debug_string_prefix_length;
360 void (*_bfd_coff_swap_filehdr_in) PARAMS ((
361 bfd *abfd,
362 PTR ext,
363 PTR in));
364 void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
365 bfd *abfd,
366 PTR ext,
367 PTR in));
368 void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
369 bfd *abfd,
370 PTR ext,
371 PTR in));
372 void (*_bfd_coff_swap_reloc_in) PARAMS ((
373 bfd *abfd,
374 PTR ext,
375 PTR in));
376 boolean (*_bfd_coff_bad_format_hook) PARAMS ((
377 bfd *abfd,
378 PTR internal_filehdr));
379 boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
380 bfd *abfd,
381 PTR internal_filehdr));
382 PTR (*_bfd_coff_mkobject_hook) PARAMS ((
383 bfd *abfd,
384 PTR internal_filehdr,
385 PTR internal_aouthdr));
386 flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
387 bfd *abfd,
388 PTR internal_scnhdr,
389 const char *name,
390 asection *section));
391 void (*_bfd_set_alignment_hook) PARAMS ((
392 bfd *abfd,
393 asection *sec,
394 PTR internal_scnhdr));
395 boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
396 bfd *abfd));
397 boolean (*_bfd_coff_symname_in_debug) PARAMS ((
398 bfd *abfd,
399 struct internal_syment *sym));
400 boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
401 bfd *abfd,
402 combined_entry_type *table_base,
403 combined_entry_type *symbol,
404 unsigned int indaux,
405 combined_entry_type *aux));
406 boolean (*_bfd_coff_print_aux) PARAMS ((
407 bfd *abfd,
408 FILE *file,
409 combined_entry_type *table_base,
410 combined_entry_type *symbol,
411 combined_entry_type *aux,
412 unsigned int indaux));
413 void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
414 bfd *abfd,
415 struct bfd_link_info *link_info,
416 struct bfd_link_order *link_order,
417 arelent *reloc,
418 bfd_byte *data,
419 unsigned int *src_ptr,
420 unsigned int *dst_ptr));
421 int (*_bfd_coff_reloc16_estimate) PARAMS ((
422 bfd *abfd,
423 asection *input_section,
424 arelent *r,
425 unsigned int shrink,
426 struct bfd_link_info *link_info));
427 enum coff_symbol_classification (*_bfd_coff_classify_symbol) PARAMS ((
428 bfd *abfd,
429 struct internal_syment *));
430 boolean (*_bfd_coff_compute_section_file_positions) PARAMS ((
431 bfd *abfd));
432 boolean (*_bfd_coff_start_final_link) PARAMS ((
433 bfd *output_bfd,
434 struct bfd_link_info *info));
435 boolean (*_bfd_coff_relocate_section) PARAMS ((
436 bfd *output_bfd,
437 struct bfd_link_info *info,
438 bfd *input_bfd,
439 asection *input_section,
440 bfd_byte *contents,
441 struct internal_reloc *relocs,
442 struct internal_syment *syms,
443 asection **sections));
444 reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
445 bfd *abfd,
446 asection *sec,
447 struct internal_reloc *rel,
448 struct coff_link_hash_entry *h,
449 struct internal_syment *sym,
450 bfd_vma *addendp));
451 boolean (*_bfd_coff_adjust_symndx) PARAMS ((
452 bfd *obfd,
453 struct bfd_link_info *info,
454 bfd *ibfd,
455 asection *sec,
456 struct internal_reloc *reloc,
457 boolean *adjustedp));
458 boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
459 struct bfd_link_info *info,
460 bfd *abfd,
461 const char *name,
462 flagword flags,
463 asection *section,
464 bfd_vma value,
465 const char *string,
466 boolean copy,
467 boolean collect,
468 struct bfd_link_hash_entry **hashp));
469
470 boolean (*_bfd_coff_link_output_has_begun) PARAMS ((
471 bfd * abfd,
472 struct coff_final_link_info * pfinfo));
473 boolean (*_bfd_coff_final_link_postscript) PARAMS ((
474 bfd * abfd,
475 struct coff_final_link_info * pfinfo));
476
477 } bfd_coff_backend_data;
478
479 #define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
480
481 #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
482 ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
483
484 #define bfd_coff_swap_sym_in(a,e,i) \
485 ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
486
487 #define bfd_coff_swap_lineno_in(a,e,i) \
488 ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
489
490 #define bfd_coff_swap_reloc_out(abfd, i, o) \
491 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
492
493 #define bfd_coff_swap_lineno_out(abfd, i, o) \
494 ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
495
496 #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
497 ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
498
499 #define bfd_coff_swap_sym_out(abfd, i,o) \
500 ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
501
502 #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
503 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
504
505 #define bfd_coff_swap_filehdr_out(abfd, i,o) \
506 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
507
508 #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
509 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
510
511 #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
512 #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
513 #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
514 #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
515 #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
516 #define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
517 #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
518 #define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
519 #define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
520 #define bfd_coff_long_section_names(abfd) \
521 (coff_backend_info (abfd)->_bfd_coff_long_section_names)
522 #define bfd_coff_default_section_alignment_power(abfd) \
523 (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
524 #define bfd_coff_swap_filehdr_in(abfd, i,o) \
525 ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
526
527 #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
528 ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
529
530 #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
531 ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
532
533 #define bfd_coff_swap_reloc_in(abfd, i, o) \
534 ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
535
536 #define bfd_coff_bad_format_hook(abfd, filehdr) \
537 ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
538
539 #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
540 ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
541 #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
542 ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
543
544 #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section)\
545 ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
546 (abfd, scnhdr, name, section))
547
548 #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
549 ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
550
551 #define bfd_coff_slurp_symbol_table(abfd)\
552 ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
553
554 #define bfd_coff_symname_in_debug(abfd, sym)\
555 ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
556
557 #define bfd_coff_force_symnames_in_strings(abfd)\
558 (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
559
560 #define bfd_coff_debug_string_prefix_length(abfd)\
561 (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
562
563 #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
564 ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
565 (abfd, file, base, symbol, aux, indaux))
566
567 #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
568 ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
569 (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
570
571 #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
572 ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
573 (abfd, section, reloc, shrink, link_info))
574
575 #define bfd_coff_classify_symbol(abfd, sym)\
576 ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
577 (abfd, sym))
578
579 #define bfd_coff_compute_section_file_positions(abfd)\
580 ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
581 (abfd))
582
583 #define bfd_coff_start_final_link(obfd, info)\
584 ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
585 (obfd, info))
586 #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
587 ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
588 (obfd, info, ibfd, o, con, rel, isyms, secs))
589 #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
590 ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
591 (abfd, sec, rel, h, sym, addendp))
592 #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
593 ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
594 (obfd, info, ibfd, sec, rel, adjustedp))
595 #define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
596 ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
597 (info, abfd, name, flags, section, value, string, cp, coll, hashp))
598
599 #define bfd_coff_link_output_has_begun(a,p) \
600 ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
601 #define bfd_coff_final_link_postscript(a,p) \
602 ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
603
604Writing relocations
605...................
606
607 To write relocations, the back end steps though the canonical
608relocation table and create an `internal_reloc'. The symbol index to
609use is removed from the `offset' field in the symbol table supplied.
610The address comes directly from the sum of the section base address and
611the relocation offset; the type is dug directly from the howto field.
612Then the `internal_reloc' is swapped into the shape of an
613`external_reloc' and written out to disk.
614
615Reading linenumbers
616...................
617
618 Creating the linenumber table is done by reading in the entire coff
619linenumber table, and creating another table for internal use.
620
621 A coff linenumber table is structured so that each function is
622marked as having a line number of 0. Each line within the function is
623an offset from the first line in the function. The base of the line
624number information for the table is stored in the symbol associated
625with the function.
626
627 Note: The PE format uses line number 0 for a flag indicating a new
628source file.
629
630 The information is copied from the external to the internal table,
631and each symbol which marks a function is marked by pointing its...
632
633 How does this work ?
634
635Reading relocations
636...................
637
638 Coff relocations are easily transformed into the internal BFD form
639(`arelent').
640
641 Reading a coff relocation table is done in the following stages:
642
643 * Read the entire coff relocation table into memory.
644
645 * Process each relocation in turn; first swap it from the external
646 to the internal form.
647
648 * Turn the symbol referenced in the relocation's symbol index into a
649 pointer into the canonical symbol table. This table is the same
650 as the one returned by a call to `bfd_canonicalize_symtab'. The
651 back end will call that routine and save the result if a
652 canonicalization hasn't been done.
653
654 * The reloc index is turned into a pointer to a howto structure, in
655 a back end specific way. For instance, the 386 and 960 use the
656 `r_type' to directly produce an index into a howto table vector;
657 the 88k subtracts a number from the `r_type' field and creates an
658 addend field.
659
660
661File: bfd.info, Node: elf, Prev: coff, Up: BFD back ends
662
663ELF backends
664============
665
666 BFD support for ELF formats is being worked on. Currently, the best
667supported back ends are for sparc and i386 (running svr4 or Solaris 2).
668
669 Documentation of the internals of the support code still needs to be
670written. The code is changing quickly enough that we haven't bothered
671yet.
672
673`bfd_elf_find_section'
674......................
675
676 *Synopsis*
677 struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
678 *Description*
679Helper functions for GDB to locate the string tables. Since BFD hides
680string tables from callers, GDB needs to use an internal hook to find
681them. Sun's .stabstr, in particular, isn't even pointed to by the
682.stab section, so ordinary mechanisms wouldn't work to find it, even if
683we had some.
684
685
686File: bfd.info, Node: GNU Free Documentation License, Next: Index, Prev: BFD back ends, Up: Top
687
688GNU Free Documentation License
689******************************
690
691 GNU Free Documentation License
692
693 Version 1.1, March 2000
694
695 Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple
696Place, Suite 330, Boston, MA 02111-1307 USA
697
698 Everyone is permitted to copy and distribute verbatim copies of
699this license document, but changing it is not allowed.
700
701 0. PREAMBLE
702
703 The purpose of this License is to make a manual, textbook, or other
704written document "free" in the sense of freedom: to assure everyone the
705effective freedom to copy and redistribute it, with or without
706modifying it, either commercially or noncommercially. Secondarily,
707this License preserves for the author and publisher a way to get credit
708for their work, while not being considered responsible for
709modifications made by others.
710
711 This License is a kind of "copyleft", which means that derivative
712works of the document must themselves be free in the same sense. It
713complements the GNU General Public License, which is a copyleft license
714designed for free software.
715
716 We have designed this License in order to use it for manuals for free
717software, because free software needs free documentation: a free
718program should come with manuals providing the same freedoms that the
719software does. But this License is not limited to software manuals; it
720can be used for any textual work, regardless of subject matter or
721whether it is published as a printed book. We recommend this License
722principally for works whose purpose is instruction or reference.
723
724 1. APPLICABILITY AND DEFINITIONS
725
726 This License applies to any manual or other work that contains a
727notice placed by the copyright holder saying it can be distributed
728under the terms of this License. The "Document", below, refers to any
729such manual or work. Any member of the public is a licensee, and is
730addressed as "you".
731
732 A "Modified Version" of the Document means any work containing the
733Document or a portion of it, either copied verbatim, or with
734modifications and/or translated into another language.
735
736 A "Secondary Section" is a named appendix or a front-matter section
737of the Document that deals exclusively with the relationship of the
738publishers or authors of the Document to the Document's overall subject
739(or to related matters) and contains nothing that could fall directly
740within that overall subject. (For example, if the Document is in part a
741textbook of mathematics, a Secondary Section may not explain any
742mathematics.) The relationship could be a matter of historical
743connection with the subject or with related matters, or of legal,
744commercial, philosophical, ethical or political position regarding them.
745
746 The "Invariant Sections" are certain Secondary Sections whose titles
747are designated, as being those of Invariant Sections, in the notice
748that says that the Document is released under this License.
749
750 The "Cover Texts" are certain short passages of text that are listed,
751as Front-Cover Texts or Back-Cover Texts, in the notice that says that
752the Document is released under this License.
753
754 A "Transparent" copy of the Document means a machine-readable copy,
755represented in a format whose specification is available to the general
756public, whose contents can be viewed and edited directly and
757straightforwardly with generic text editors or (for images composed of
758pixels) generic paint programs or (for drawings) some widely available
759drawing editor, and that is suitable for input to text formatters or
760for automatic translation to a variety of formats suitable for input to
761text formatters. A copy made in an otherwise Transparent file format
762whose markup has been designed to thwart or discourage subsequent
763modification by readers is not Transparent. A copy that is not
764"Transparent" is called "Opaque".
765
766 Examples of suitable formats for Transparent copies include plain
767ASCII without markup, Texinfo input format, LaTeX input format, SGML or
768XML using a publicly available DTD, and standard-conforming simple HTML
769designed for human modification. Opaque formats include PostScript,
770PDF, proprietary formats that can be read and edited only by
771proprietary word processors, SGML or XML for which the DTD and/or
772processing tools are not generally available, and the machine-generated
773HTML produced by some word processors for output purposes only.
774
775 The "Title Page" means, for a printed book, the title page itself,
776plus such following pages as are needed to hold, legibly, the material
777this License requires to appear in the title page. For works in
778formats which do not have any title page as such, "Title Page" means
779the text near the most prominent appearance of the work's title,
780preceding the beginning of the body of the text.
781
782 2. VERBATIM COPYING
783
784 You may copy and distribute the Document in any medium, either
785commercially or noncommercially, provided that this License, the
786copyright notices, and the license notice saying this License applies
787to the Document are reproduced in all copies, and that you add no other
788conditions whatsoever to those of this License. You may not use
789technical measures to obstruct or control the reading or further
790copying of the copies you make or distribute. However, you may accept
791compensation in exchange for copies. If you distribute a large enough
792number of copies you must also follow the conditions in section 3.
793
794 You may also lend copies, under the same conditions stated above, and
795you may publicly display copies.
796
797 3. COPYING IN QUANTITY
798
799 If you publish printed copies of the Document numbering more than
800100, and the Document's license notice requires Cover Texts, you must
801enclose the copies in covers that carry, clearly and legibly, all these
802Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts
803on the back cover. Both covers must also clearly and legibly identify
804you as the publisher of these copies. The front cover must present the
805full title with all words of the title equally prominent and visible.
806You may add other material on the covers in addition. Copying with
807changes limited to the covers, as long as they preserve the title of
808the Document and satisfy these conditions, can be treated as verbatim
809copying in other respects.
810
811 If the required texts for either cover are too voluminous to fit
812legibly, you should put the first ones listed (as many as fit
813reasonably) on the actual cover, and continue the rest onto adjacent
814pages.
815
816 If you publish or distribute Opaque copies of the Document numbering
817more than 100, you must either include a machine-readable Transparent
818copy along with each Opaque copy, or state in or with each Opaque copy
819a publicly-accessible computer-network location containing a complete
820Transparent copy of the Document, free of added material, which the
821general network-using public has access to download anonymously at no
822charge using public-standard network protocols. If you use the latter
823option, you must take reasonably prudent steps, when you begin
824distribution of Opaque copies in quantity, to ensure that this
825Transparent copy will remain thus accessible at the stated location
826until at least one year after the last time you distribute an Opaque
827copy (directly or through your agents or retailers) of that edition to
828the public.
829
830 It is requested, but not required, that you contact the authors of
831the Document well before redistributing any large number of copies, to
832give them a chance to provide you with an updated version of the
833Document.
834
835 4. MODIFICATIONS
836
837 You may copy and distribute a Modified Version of the Document under
838the conditions of sections 2 and 3 above, provided that you release the
839Modified Version under precisely this License, with the Modified
840Version filling the role of the Document, thus licensing distribution
841and modification of the Modified Version to whoever possesses a copy of
842it. In addition, you must do these things in the Modified Version:
843
844 A. Use in the Title Page (and on the covers, if any) a title distinct
845 from that of the Document, and from those of previous versions
846(which should, if there were any, be listed in the History section
847of the Document). You may use the same title as a previous version
848if the original publisher of that version gives permission. B. List on
849the Title Page, as authors, one or more persons or entities
850responsible for authorship of the modifications in the Modified
851Version, together with at least five of the principal authors of the
852Document (all of its principal authors, if it has less than five). C.
853State on the Title page the name of the publisher of the Modified
854Version, as the publisher. D. Preserve all the copyright notices of
855the Document. E. Add an appropriate copyright notice for your
856modifications adjacent to the other copyright notices. F. Include,
857immediately after the copyright notices, a license notice giving the
858public permission to use the Modified Version under the terms of
859this License, in the form shown in the Addendum below. G. Preserve in
860that license notice the full lists of Invariant Sections and
861required Cover Texts given in the Document's license notice. H.
862Include an unaltered copy of this License. I. Preserve the section
863entitled "History", and its title, and add to it an item stating at
864least the title, year, new authors, and publisher of the Modified
865Version as given on the Title Page. If there is no section entitled
866"History" in the Document, create one stating the title, year,
867authors, and publisher of the Document as given on its Title Page,
868then add an item describing the Modified Version as stated in the
869previous sentence. J. Preserve the network location, if any, given in
870the Document for public access to a Transparent copy of the
871Document, and likewise the network locations given in the Document
872for previous versions it was based on. These may be placed in the
873"History" section. You may omit a network location for a work that
874was published at least four years before the Document itself, or if
875the original publisher of the version it refers to gives permission.
876K. In any section entitled "Acknowledgements" or "Dedications",
877preserve the section's title, and preserve in the section all the
878substance and tone of each of the contributor acknowledgements
879and/or dedications given therein. L. Preserve all the Invariant
880Sections of the Document, unaltered in their text and in their
881titles. Section numbers or the equivalent are not considered part
882of the section titles. M. Delete any section entitled "Endorsements".
883Such a section may not be included in the Modified Version. N. Do
884not retitle any existing section as "Endorsements" or to conflict in
885title with any Invariant Section.
886
887 If the Modified Version includes new front-matter sections or
888appendices that qualify as Secondary Sections and contain no material
889copied from the Document, you may at your option designate some or all
890of these sections as invariant. To do this, add their titles to the
891list of Invariant Sections in the Modified Version's license notice.
892These titles must be distinct from any other section titles.
893
894 You may add a section entitled "Endorsements", provided it contains
895nothing but endorsements of your Modified Version by various
896parties-for example, statements of peer review or that the text has
897been approved by an organization as the authoritative definition of a
898standard.
899
900 You may add a passage of up to five words as a Front-Cover Text, and
901a passage of up to 25 words as a Back-Cover Text, to the end of the list
902of Cover Texts in the Modified Version. Only one passage of
903Front-Cover Text and one of Back-Cover Text may be added by (or through
904arrangements made by) any one entity. If the Document already includes
905a cover text for the same cover, previously added by you or by
906arrangement made by the same entity you are acting on behalf of, you
907may not add another; but you may replace the old one, on explicit
908permission from the previous publisher that added the old one.
909
910 The author(s) and publisher(s) of the Document do not by this License
911give permission to use their names for publicity for or to assert or
912imply endorsement of any Modified Version.
913
914 5. COMBINING DOCUMENTS
915
916 You may combine the Document with other documents released under this
917License, under the terms defined in section 4 above for modified
918versions, provided that you include in the combination all of the
919Invariant Sections of all of the original documents, unmodified, and
920list them all as Invariant Sections of your combined work in its
921license notice.
922
923 The combined work need only contain one copy of this License, and
924multiple identical Invariant Sections may be replaced with a single
925copy. If there are multiple Invariant Sections with the same name but
926different contents, make the title of each such section unique by
927adding at the end of it, in parentheses, the name of the original
928author or publisher of that section if known, or else a unique number.
929Make the same adjustment to the section titles in the list of Invariant
930Sections in the license notice of the combined work.
931
932 In the combination, you must combine any sections entitled "History"
933in the various original documents, forming one section entitled
934"History"; likewise combine any sections entitled "Acknowledgements",
935and any sections entitled "Dedications". You must delete all sections
936entitled "Endorsements."
937
938 6. COLLECTIONS OF DOCUMENTS
939
940 You may make a collection consisting of the Document and other
941documents released under this License, and replace the individual
942copies of this License in the various documents with a single copy that
943is included in the collection, provided that you follow the rules of
944this License for verbatim copying of each of the documents in all other
945respects.
946
947 You may extract a single document from such a collection, and
948distribute it individually under this License, provided you insert a
949copy of this License into the extracted document, and follow this
950License in all other respects regarding verbatim copying of that
951document.
952
953 7. AGGREGATION WITH INDEPENDENT WORKS
954
955 A compilation of the Document or its derivatives with other separate
956and independent documents or works, in or on a volume of a storage or
957distribution medium, does not as a whole count as a Modified Version of
958the Document, provided no compilation copyright is claimed for the
959compilation. Such a compilation is called an "aggregate", and this
960License does not apply to the other self-contained works thus compiled
961with the Document, on account of their being thus compiled, if they are
962not themselves derivative works of the Document.
963
964 If the Cover Text requirement of section 3 is applicable to these
965copies of the Document, then if the Document is less than one quarter
966of the entire aggregate, the Document's Cover Texts may be placed on
967covers that surround only the Document within the aggregate. Otherwise
968they must appear on covers around the whole aggregate.
969
970 8. TRANSLATION
971
972 Translation is considered a kind of modification, so you may
973distribute translations of the Document under the terms of section 4.
974Replacing Invariant Sections with translations requires special
975permission from their copyright holders, but you may include
976translations of some or all Invariant Sections in addition to the
977original versions of these Invariant Sections. You may include a
978translation of this License provided that you also include the original
979English version of this License. In case of a disagreement between the
980translation and the original English version of this License, the
981original English version will prevail.
982
983 9. TERMINATION
984
985 You may not copy, modify, sublicense, or distribute the Document
986except as expressly provided for under this License. Any other attempt
987to copy, modify, sublicense or distribute the Document is void, and will
988automatically terminate your rights under this License. However,
989parties who have received copies, or rights, from you under this
990License will not have their licenses terminated so long as such parties
991remain in full compliance.
992
993 10. FUTURE REVISIONS OF THIS LICENSE
994
995 The Free Software Foundation may publish new, revised versions of
996the GNU Free Documentation License from time to time. Such new
997versions will be similar in spirit to the present version, but may
998differ in detail to address new problems or concerns. See
999http://www.gnu.org/copyleft/.
1000
1001 Each version of the License is given a distinguishing version number.
1002If the Document specifies that a particular numbered version of this
1003License "or any later version" applies to it, you have the option of
1004following the terms and conditions either of that specified version or
1005of any later version that has been published (not as a draft) by the
1006Free Software Foundation. If the Document does not specify a version
1007number of this License, you may choose any version ever published (not
1008as a draft) by the Free Software Foundation.
1009
1010 ADDENDUM: How to use this License for your documents
1011
1012 To use this License in a document you have written, include a copy of
1013the License in the document and put the following copyright and license
1014notices just after the title page:
1015
1016 Copyright (c) YEAR YOUR NAME.
1017 Permission is granted to copy, distribute and/or modify this document
1018 under the terms of the GNU Free Documentation License, Version 1.1
1019 or any later version published by the Free Software Foundation;
1020 with the Invariant Sections being LIST THEIR TITLES, with the
1021 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
1022 A copy of the license is included in the section entitled "GNU
1023 Free Documentation License".
1024
1025 If you have no Invariant Sections, write "with no Invariant Sections"
1026instead of saying which ones are invariant. If you have no Front-Cover
1027Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
1028LIST"; likewise for Back-Cover Texts.
1029
1030 If your document contains nontrivial examples of program code, we
1031recommend releasing these examples in parallel under your choice of
1032free software license, such as the GNU General Public License, to
1033permit their use in free software.
1034
Note: See TracBrowser for help on using the repository browser.