OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [gdb-5.0/] [bfd/] [doc/] [bfd.info-6] - Blame information for rev 1778

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
This is bfd.info, produced by Makeinfo version 3.12f from bfd.texinfo.
2
 
3
START-INFO-DIR-ENTRY
4
* Bfd: (bfd).                   The Binary File Descriptor library.
5
END-INFO-DIR-ENTRY
6
 
7
   This file documents the BFD library.
8
 
9
   Copyright (C) 1991 Free Software Foundation, Inc.
10
 
11
   Permission is granted to make and distribute verbatim copies of this
12
manual provided the copyright notice and this permission notice are
13
preserved on all copies.
14
 
15
   Permission is granted to copy and distribute modified versions of
16
this manual under the conditions for verbatim copying, subject to the
17
terms of the GNU General Public License, which includes the provision
18
that the entire resulting derived work is distributed under the terms
19
of a permission notice identical to this one.
20
 
21
   Permission is granted to copy and distribute translations of this
22
manual into another language, under the above conditions for modified
23
versions.
24
 
25

26
File: bfd.info,  Node: coff,  Next: elf,  Prev: aout,  Up: BFD back ends
27
 
28
coff backends
29
=============
30
 
31
   BFD supports a number of different flavours of coff format.  The
32
major differences between formats are the sizes and alignments of
33
fields in structures on disk, and the occasional extra field.
34
 
35
   Coff in all its varieties is implemented with a few common files and
36
a number of implementation specific files. For example, The 88k bcs
37
coff format is implemented in the file `coff-m88k.c'. This file
38
`#include's `coff/m88k.h' which defines the external structure of the
39
coff format for the 88k, and `coff/internal.h' which defines the
40
internal structure. `coff-m88k.c' also defines the relocations used by
41
the 88k format *Note Relocations::.
42
 
43
   The Intel i960 processor version of coff is implemented in
44
`coff-i960.c'. This file has the same structure as `coff-m88k.c',
45
except that it includes `coff/i960.h' rather than `coff-m88k.h'.
46
 
47
Porting to a new version of coff
48
--------------------------------
49
 
50
   The recommended method is to select from the existing
51
implementations the version of coff which is most like the one you want
52
to use.  For example, we'll say that i386 coff is the one you select,
53
and that your coff flavour is called foo.  Copy `i386coff.c' to
54
`foocoff.c', copy `../include/coff/i386.h' to `../include/coff/foo.h',
55
and add the lines to `targets.c' and `Makefile.in' so that your new
56
back end is used. Alter the shapes of the structures in
57
`../include/coff/foo.h' so that they match what you need. You will
58
probably also have to add `#ifdef's to the code in `coff/internal.h' and
59
`coffcode.h' if your version of coff is too wild.
60
 
61
   You can verify that your new BFD backend works quite simply by
62
building `objdump' from the `binutils' directory, and making sure that
63
its version of what's going on and your host system's idea (assuming it
64
has the pretty standard coff dump utility, usually called `att-dump' or
65
just `dump') are the same.  Then clean up your code, and send what
66
you've done to Cygnus. Then your stuff will be in the next release, and
67
you won't have to keep integrating it.
68
 
69
How the coff backend works
70
--------------------------
71
 
72
File layout
73
...........
74
 
75
   The Coff backend is split into generic routines that are applicable
76
to any Coff target and routines that are specific to a particular
77
target.  The target-specific routines are further split into ones which
78
are basically the same for all Coff targets except that they use the
79
external symbol format or use different values for certain constants.
80
 
81
   The generic routines are in `coffgen.c'.  These routines work for
82
any Coff target.  They use some hooks into the target specific code;
83
the hooks are in a `bfd_coff_backend_data' structure, one of which
84
exists for each target.
85
 
86
   The essentially similar target-specific routines are in
87
`coffcode.h'.  This header file includes executable C code.  The
88
various Coff targets first include the appropriate Coff header file,
89
make any special defines that are needed, and then include `coffcode.h'.
90
 
91
   Some of the Coff targets then also have additional routines in the
92
target source file itself.
93
 
94
   For example, `coff-i960.c' includes `coff/internal.h' and
95
`coff/i960.h'.  It then defines a few constants, such as `I960', and
96
includes `coffcode.h'.  Since the i960 has complex relocation types,
97
`coff-i960.c' also includes some code to manipulate the i960 relocs.
98
This code is not in `coffcode.h' because it would not be used by any
99
other target.
100
 
101
Bit twiddling
102
.............
103
 
104
   Each flavour of coff supported in BFD has its own header file
105
describing the external layout of the structures. There is also an
106
internal description of the coff layout, in `coff/internal.h'. A major
107
function of the coff backend is swapping the bytes and twiddling the
108
bits to translate the external form of the structures into the normal
109
internal form. This is all performed in the `bfd_swap'_thing_direction
110
routines. Some elements are different sizes between different versions
111
of coff; it is the duty of the coff version specific include file to
112
override the definitions of various packing routines in `coffcode.h'.
113
E.g., the size of line number entry in coff is sometimes 16 bits, and
114
sometimes 32 bits. `#define'ing `PUT_LNSZ_LNNO' and `GET_LNSZ_LNNO'
115
will select the correct one. No doubt, some day someone will find a
116
version of coff which has a varying field size not catered to at the
117
moment. To port BFD, that person will have to add more `#defines'.
118
Three of the bit twiddling routines are exported to `gdb';
119
`coff_swap_aux_in', `coff_swap_sym_in' and `coff_swap_lineno_in'. `GDB'
120
reads the symbol table on its own, but uses BFD to fix things up.  More
121
of the bit twiddlers are exported for `gas'; `coff_swap_aux_out',
122
`coff_swap_sym_out', `coff_swap_lineno_out', `coff_swap_reloc_out',
123
`coff_swap_filehdr_out', `coff_swap_aouthdr_out',
124
`coff_swap_scnhdr_out'. `Gas' currently keeps track of all the symbol
125
table and reloc drudgery itself, thereby saving the internal BFD
126
overhead, but uses BFD to swap things on the way out, making cross
127
ports much safer.  Doing so also allows BFD (and thus the linker) to
128
use the same header files as `gas', which makes one avenue to disaster
129
disappear.
130
 
131
Symbol reading
132
..............
133
 
134
   The simple canonical form for symbols used by BFD is not rich enough
135
to keep all the information available in a coff symbol table. The back
136
end gets around this problem by keeping the original symbol table
137
around, "behind the scenes".
138
 
139
   When a symbol table is requested (through a call to
140
`bfd_canonicalize_symtab'), a request gets through to
141
`coff_get_normalized_symtab'. This reads the symbol table from the coff
142
file and swaps all the structures inside into the internal form. It
143
also fixes up all the pointers in the table (represented in the file by
144
offsets from the first symbol in the table) into physical pointers to
145
elements in the new internal table. This involves some work since the
146
meanings of fields change depending upon context: a field that is a
147
pointer to another structure in the symbol table at one moment may be
148
the size in bytes of a structure at the next.  Another pass is made
149
over the table. All symbols which mark file names (`C_FILE' symbols)
150
are modified so that the internal string points to the value in the
151
auxent (the real filename) rather than the normal text associated with
152
the symbol (`".file"').
153
 
154
   At this time the symbol names are moved around. Coff stores all
155
symbols less than nine characters long physically within the symbol
156
table; longer strings are kept at the end of the file in the string
157
table. This pass moves all strings into memory and replaces them with
158
pointers to the strings.
159
 
160
   The symbol table is massaged once again, this time to create the
161
canonical table used by the BFD application. Each symbol is inspected
162
in turn, and a decision made (using the `sclass' field) about the
163
various flags to set in the `asymbol'.  *Note Symbols::. The generated
164
canonical table shares strings with the hidden internal symbol table.
165
 
166
   Any linenumbers are read from the coff file too, and attached to the
167
symbols which own the functions the linenumbers belong to.
168
 
169
Symbol writing
170
..............
171
 
172
   Writing a symbol to a coff file which didn't come from a coff file
173
will lose any debugging information. The `asymbol' structure remembers
174
the BFD from which the symbol was taken, and on output the back end
175
makes sure that the same destination target as source target is present.
176
 
177
   When the symbols have come from a coff file then all the debugging
178
information is preserved.
179
 
180
   Symbol tables are provided for writing to the back end in a vector
181
of pointers to pointers. This allows applications like the linker to
182
accumulate and output large symbol tables without having to do too much
183
byte copying.
184
 
185
   This function runs through the provided symbol table and patches
186
each symbol marked as a file place holder (`C_FILE') to point to the
187
next file place holder in the list. It also marks each `offset' field
188
in the list with the offset from the first symbol of the current symbol.
189
 
190
   Another function of this procedure is to turn the canonical value
191
form of BFD into the form used by coff. Internally, BFD expects symbol
192
values to be offsets from a section base; so a symbol physically at
193
0x120, but in a section starting at 0x100, would have the value 0x20.
194
Coff expects symbols to contain their final value, so symbols have
195
their values changed at this point to reflect their sum with their
196
owning section.  This transformation uses the `output_section' field of
197
the `asymbol''s `asection' *Note Sections::.
198
 
199
   * `coff_mangle_symbols'
200
   This routine runs though the provided symbol table and uses the
201
offsets generated by the previous pass and the pointers generated when
202
the symbol table was read in to create the structured hierachy required
203
by coff. It changes each pointer to a symbol into the index into the
204
symbol table of the asymbol.
205
 
206
   * `coff_write_symbols'
207
   This routine runs through the symbol table and patches up the
208
symbols from their internal form into the coff way, calls the bit
209
twiddlers, and writes out the table to the file.
210
 
211
`coff_symbol_type'
212
..................
213
 
214
   *Description*
215
The hidden information for an `asymbol' is described in a
216
`combined_entry_type':
217
 
218
 
219
     typedef struct coff_ptr_struct
220
     {
221
 
222
            /* Remembers the offset from the first symbol in the file for
223
               this symbol. Generated by coff_renumber_symbols. */
224
     unsigned int offset;
225
 
226
            /* Should the value of this symbol be renumbered.  Used for
227
               XCOFF C_BSTAT symbols.  Set by coff_slurp_symbol_table.  */
228
     unsigned int fix_value : 1;
229
 
230
            /* Should the tag field of this symbol be renumbered.
231
               Created by coff_pointerize_aux. */
232
     unsigned int fix_tag : 1;
233
 
234
            /* Should the endidx field of this symbol be renumbered.
235
               Created by coff_pointerize_aux. */
236
     unsigned int fix_end : 1;
237
 
238
            /* Should the x_csect.x_scnlen field be renumbered.
239
               Created by coff_pointerize_aux. */
240
     unsigned int fix_scnlen : 1;
241
 
242
            /* Fix up an XCOFF C_BINCL/C_EINCL symbol.  The value is the
243
               index into the line number entries.  Set by
244
               coff_slurp_symbol_table.  */
245
     unsigned int fix_line : 1;
246
 
247
            /* The container for the symbol structure as read and translated
248
                from the file. */
249
 
250
     union {
251
        union internal_auxent auxent;
252
        struct internal_syment syment;
253
      } u;
254
     } combined_entry_type;
255
 
256
 
257
     /* Each canonical asymbol really looks like this: */
258
 
259
     typedef struct coff_symbol_struct
260
     {
261
        /* The actual symbol which the rest of BFD works with */
262
     asymbol symbol;
263
 
264
        /* A pointer to the hidden information for this symbol */
265
     combined_entry_type *native;
266
 
267
        /* A pointer to the linenumber information for this symbol */
268
     struct lineno_cache_entry *lineno;
269
 
270
        /* Have the line numbers been relocated yet ? */
271
     boolean done_lineno;
272
     } coff_symbol_type;
273
 
274
`bfd_coff_backend_data'
275
.......................
276
 
277
     /* COFF symbol classifications.  */
278
 
279
     enum coff_symbol_classification
280
     {
281
       /* Global symbol.  */
282
       COFF_SYMBOL_GLOBAL,
283
       /* Common symbol.  */
284
       COFF_SYMBOL_COMMON,
285
       /* Undefined symbol.  */
286
       COFF_SYMBOL_UNDEFINED,
287
       /* Local symbol.  */
288
       COFF_SYMBOL_LOCAL,
289
       /* PE section symbol.  */
290
       COFF_SYMBOL_PE_SECTION
291
     };
292
   Special entry points for gdb to swap in coff symbol table parts:
293
     typedef struct
294
     {
295
       void (*_bfd_coff_swap_aux_in) PARAMS ((
296
            bfd            *abfd,
297
            PTR             ext,
298
            int             type,
299
            int             class,
300
            int             indaux,
301
            int             numaux,
302
            PTR             in));
303
 
304
       void (*_bfd_coff_swap_sym_in) PARAMS ((
305
            bfd            *abfd ,
306
            PTR             ext,
307
            PTR             in));
308
 
309
       void (*_bfd_coff_swap_lineno_in) PARAMS ((
310
            bfd            *abfd,
311
            PTR            ext,
312
            PTR             in));
313
   Special entry points for gas to swap out coff parts:
314
      unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
315
            bfd     *abfd,
316
            PTR     in,
317
            int     type,
318
            int     class,
319
            int     indaux,
320
            int     numaux,
321
            PTR     ext));
322
 
323
      unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
324
           bfd      *abfd,
325
           PTR      in,
326
           PTR      ext));
327
 
328
      unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
329
            bfd     *abfd,
330
            PTR     in,
331
            PTR     ext));
332
 
333
      unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
334
            bfd     *abfd,
335
            PTR     src,
336
            PTR     dst));
337
 
338
      unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
339
            bfd     *abfd,
340
            PTR     in,
341
            PTR     out));
342
 
343
      unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
344
            bfd     *abfd,
345
            PTR     in,
346
            PTR     out));
347
 
348
      unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
349
            bfd     *abfd,
350
            PTR     in,
351
            PTR     out));
352
   Special entry points for generic COFF routines to call target
353
dependent COFF routines:
354
      unsigned int _bfd_filhsz;
355
      unsigned int _bfd_aoutsz;
356
      unsigned int _bfd_scnhsz;
357
      unsigned int _bfd_symesz;
358
      unsigned int _bfd_auxesz;
359
      unsigned int _bfd_relsz;
360
      unsigned int _bfd_linesz;
361
      unsigned int _bfd_filnmlen;
362
      boolean _bfd_coff_long_filenames;
363
      boolean _bfd_coff_long_section_names;
364
      unsigned int _bfd_coff_default_section_alignment_power;
365
      void (*_bfd_coff_swap_filehdr_in) PARAMS ((
366
            bfd     *abfd,
367
            PTR     ext,
368
            PTR     in));
369
      void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
370
            bfd     *abfd,
371
            PTR     ext,
372
            PTR     in));
373
      void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
374
            bfd     *abfd,
375
            PTR     ext,
376
            PTR     in));
377
      void (*_bfd_coff_swap_reloc_in) PARAMS ((
378
            bfd     *abfd,
379
            PTR     ext,
380
            PTR     in));
381
      boolean (*_bfd_coff_bad_format_hook) PARAMS ((
382
            bfd     *abfd,
383
            PTR     internal_filehdr));
384
      boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
385
            bfd     *abfd,
386
            PTR     internal_filehdr));
387
      PTR (*_bfd_coff_mkobject_hook) PARAMS ((
388
            bfd     *abfd,
389
            PTR     internal_filehdr,
390
            PTR     internal_aouthdr));
391
      flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
392
            bfd     *abfd,
393
            PTR     internal_scnhdr,
394
            const char *name,
395
            asection *section));
396
      void (*_bfd_set_alignment_hook) PARAMS ((
397
            bfd     *abfd,
398
            asection *sec,
399
            PTR     internal_scnhdr));
400
      boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
401
            bfd     *abfd));
402
      boolean (*_bfd_coff_symname_in_debug) PARAMS ((
403
            bfd     *abfd,
404
            struct internal_syment *sym));
405
      boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
406
            bfd *abfd,
407
            combined_entry_type *table_base,
408
            combined_entry_type *symbol,
409
            unsigned int indaux,
410
            combined_entry_type *aux));
411
      boolean (*_bfd_coff_print_aux) PARAMS ((
412
            bfd *abfd,
413
            FILE *file,
414
            combined_entry_type *table_base,
415
            combined_entry_type *symbol,
416
            combined_entry_type *aux,
417
            unsigned int indaux));
418
      void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
419
            bfd     *abfd,
420
            struct bfd_link_info *link_info,
421
            struct bfd_link_order *link_order,
422
            arelent *reloc,
423
            bfd_byte *data,
424
            unsigned int *src_ptr,
425
            unsigned int *dst_ptr));
426
      int (*_bfd_coff_reloc16_estimate) PARAMS ((
427
            bfd *abfd,
428
            asection *input_section,
429
            arelent *r,
430
            unsigned int shrink,
431
            struct bfd_link_info *link_info));
432
      enum coff_symbol_classification (*_bfd_coff_classify_symbol) PARAMS ((
433
            bfd *abfd,
434
            struct internal_syment *));
435
      boolean (*_bfd_coff_compute_section_file_positions) PARAMS ((
436
            bfd *abfd));
437
      boolean (*_bfd_coff_start_final_link) PARAMS ((
438
            bfd *output_bfd,
439
            struct bfd_link_info *info));
440
      boolean (*_bfd_coff_relocate_section) PARAMS ((
441
            bfd *output_bfd,
442
            struct bfd_link_info *info,
443
            bfd *input_bfd,
444
            asection *input_section,
445
            bfd_byte *contents,
446
            struct internal_reloc *relocs,
447
            struct internal_syment *syms,
448
            asection **sections));
449
      reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
450
            bfd *abfd,
451
            asection *sec,
452
            struct internal_reloc *rel,
453
            struct coff_link_hash_entry *h,
454
            struct internal_syment *sym,
455
            bfd_vma *addendp));
456
      boolean (*_bfd_coff_adjust_symndx) PARAMS ((
457
            bfd *obfd,
458
            struct bfd_link_info *info,
459
            bfd *ibfd,
460
            asection *sec,
461
            struct internal_reloc *reloc,
462
            boolean *adjustedp));
463
      boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
464
            struct bfd_link_info *info,
465
            bfd *abfd,
466
            const char *name,
467
            flagword flags,
468
            asection *section,
469
            bfd_vma value,
470
            const char *string,
471
            boolean copy,
472
            boolean collect,
473
            struct bfd_link_hash_entry **hashp));
474
 
475
      boolean (*_bfd_coff_link_output_has_begun) PARAMS ((
476
            bfd * abfd,
477
            struct coff_final_link_info * pfinfo));
478
      boolean (*_bfd_coff_final_link_postscript) PARAMS ((
479
            bfd * abfd,
480
            struct coff_final_link_info * pfinfo));
481
 
482
     } bfd_coff_backend_data;
483
 
484
     #define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
485
 
486
     #define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
487
             ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
488
 
489
     #define bfd_coff_swap_sym_in(a,e,i) \
490
             ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
491
 
492
     #define bfd_coff_swap_lineno_in(a,e,i) \
493
             ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
494
 
495
     #define bfd_coff_swap_reloc_out(abfd, i, o) \
496
             ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
497
 
498
     #define bfd_coff_swap_lineno_out(abfd, i, o) \
499
             ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
500
 
501
     #define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
502
             ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
503
 
504
     #define bfd_coff_swap_sym_out(abfd, i,o) \
505
             ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
506
 
507
     #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
508
             ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
509
 
510
     #define bfd_coff_swap_filehdr_out(abfd, i,o) \
511
             ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
512
 
513
     #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
514
             ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
515
 
516
     #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
517
     #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
518
     #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
519
     #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
520
     #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
521
     #define bfd_coff_relsz(abfd)  (coff_backend_info (abfd)->_bfd_relsz)
522
     #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
523
     #define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
524
     #define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
525
     #define bfd_coff_long_section_names(abfd) \
526
             (coff_backend_info (abfd)->_bfd_coff_long_section_names)
527
     #define bfd_coff_default_section_alignment_power(abfd) \
528
             (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
529
     #define bfd_coff_swap_filehdr_in(abfd, i,o) \
530
             ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
531
 
532
     #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
533
             ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
534
 
535
     #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
536
             ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
537
 
538
     #define bfd_coff_swap_reloc_in(abfd, i, o) \
539
             ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
540
 
541
     #define bfd_coff_bad_format_hook(abfd, filehdr) \
542
             ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
543
 
544
     #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
545
             ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
546
     #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
547
             ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
548
 
549
     #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section)\
550
             ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
551
              (abfd, scnhdr, name, section))
552
 
553
     #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
554
             ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
555
 
556
     #define bfd_coff_slurp_symbol_table(abfd)\
557
             ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
558
 
559
     #define bfd_coff_symname_in_debug(abfd, sym)\
560
             ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
561
 
562
     #define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
563
             ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
564
              (abfd, file, base, symbol, aux, indaux))
565
 
566
     #define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
567
             ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
568
              (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
569
 
570
     #define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
571
             ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
572
              (abfd, section, reloc, shrink, link_info))
573
 
574
     #define bfd_coff_classify_symbol(abfd, sym)\
575
             ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
576
              (abfd, sym))
577
 
578
     #define bfd_coff_compute_section_file_positions(abfd)\
579
             ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
580
              (abfd))
581
 
582
     #define bfd_coff_start_final_link(obfd, info)\
583
             ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
584
              (obfd, info))
585
     #define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
586
             ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
587
              (obfd, info, ibfd, o, con, rel, isyms, secs))
588
     #define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
589
             ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
590
              (abfd, sec, rel, h, sym, addendp))
591
     #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
592
             ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
593
              (obfd, info, ibfd, sec, rel, adjustedp))
594
     #define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
595
             ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
596
              (info, abfd, name, flags, section, value, string, cp, coll, hashp))
597
 
598
     #define bfd_coff_link_output_has_begun(a,p) \
599
             ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
600
     #define bfd_coff_final_link_postscript(a,p) \
601
             ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
602
 
603
Writing relocations
604
...................
605
 
606
   To write relocations, the back end steps though the canonical
607
relocation table and create an `internal_reloc'. The symbol index to
608
use is removed from the `offset' field in the symbol table supplied.
609
The address comes directly from the sum of the section base address and
610
the relocation offset; the type is dug directly from the howto field.
611
Then the `internal_reloc' is swapped into the shape of an
612
`external_reloc' and written out to disk.
613
 
614
Reading linenumbers
615
...................
616
 
617
   Creating the linenumber table is done by reading in the entire coff
618
linenumber table, and creating another table for internal use.
619
 
620
   A coff linenumber table is structured so that each function is
621
marked as having a line number of 0. Each line within the function is
622
an offset from the first line in the function. The base of the line
623
number information for the table is stored in the symbol associated
624
with the function.
625
 
626
   Note: The PE format uses line number 0 for a flag indicating a new
627
source file.
628
 
629
   The information is copied from the external to the internal table,
630
and each symbol which marks a function is marked by pointing its...
631
 
632
   How does this work ?
633
 
634
Reading relocations
635
...................
636
 
637
   Coff relocations are easily transformed into the internal BFD form
638
(`arelent').
639
 
640
   Reading a coff relocation table is done in the following stages:
641
 
642
   * Read the entire coff relocation table into memory.
643
 
644
   * Process each relocation in turn; first swap it from the external
645
     to the internal form.
646
 
647
   * Turn the symbol referenced in the relocation's symbol index into a
648
     pointer into the canonical symbol table.  This table is the same
649
     as the one returned by a call to `bfd_canonicalize_symtab'. The
650
     back end will call that routine and save the result if a
651
     canonicalization hasn't been done.
652
 
653
   * The reloc index is turned into a pointer to a howto structure, in
654
     a back end specific way. For instance, the 386 and 960 use the
655
     `r_type' to directly produce an index into a howto table vector;
656
     the 88k subtracts a number from the `r_type' field and creates an
657
     addend field.
658
 
659

660
File: bfd.info,  Node: elf,  Prev: coff,  Up: BFD back ends
661
 
662
ELF backends
663
============
664
 
665
   BFD support for ELF formats is being worked on.  Currently, the best
666
supported back ends are for sparc and i386 (running svr4 or Solaris 2).
667
 
668
   Documentation of the internals of the support code still needs to be
669
written.  The code is changing quickly enough that we haven't bothered
670
yet.
671
 
672
`bfd_elf_find_section'
673
......................
674
 
675
   *Synopsis*
676
     struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
677
   *Description*
678
Helper functions for GDB to locate the string tables.  Since BFD hides
679
string tables from callers, GDB needs to use an internal hook to find
680
them.  Sun's .stabstr, in particular, isn't even pointed to by the
681
.stab section, so ordinary mechanisms wouldn't work to find it, even if
682
we had some.
683
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.