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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.18.50/] [bfd/] [doc/] [bfdsumm.texi] - Blame information for rev 262

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

Line No. Rev Author Line
1 38 julius
@c This summary of BFD is shared by the BFD and LD docs.
2
When an object file is opened, BFD subroutines automatically determine
3
the format of the input object file.  They then build a descriptor in
4
memory with pointers to routines that will be used to access elements of
5
the object file's data structures.
6
 
7
As different information from the object files is required,
8
BFD reads from different sections of the file and processes them.
9
For example, a very common operation for the linker is processing symbol
10
tables.  Each BFD back end provides a routine for converting
11
between the object file's representation of symbols and an internal
12
canonical format. When the linker asks for the symbol table of an object
13
file, it calls through a memory pointer to the routine from the
14
relevant BFD back end which reads and converts the table into a canonical
15
form.  The linker then operates upon the canonical form. When the link is
16
finished and the linker writes the output file's symbol table,
17
another BFD back end routine is called to take the newly
18
created symbol table and convert it into the chosen output format.
19
 
20
@menu
21
* BFD information loss::        Information Loss
22
* Canonical format::            The BFD canonical object-file format
23
@end menu
24
 
25
@node BFD information loss
26
@subsection Information Loss
27
 
28
@emph{Information can be lost during output.} The output formats
29
supported by BFD do not provide identical facilities, and
30
information which can be described in one form has nowhere to go in
31
another format. One example of this is alignment information in
32
@code{b.out}. There is nowhere in an @code{a.out} format file to store
33
alignment information on the contained data, so when a file is linked
34
from @code{b.out} and an @code{a.out} image is produced, alignment
35
information will not propagate to the output file. (The linker will
36
still use the alignment information internally, so the link is performed
37
correctly).
38
 
39
Another example is COFF section names. COFF files may contain an
40
unlimited number of sections, each one with a textual section name. If
41
the target of the link is a format which does not have many sections (e.g.,
42
@code{a.out}) or has sections without names (e.g., the Oasys format), the
43
link cannot be done simply. You can circumvent this problem by
44
describing the desired input-to-output section mapping with the linker command
45
language.
46
 
47
@emph{Information can be lost during canonicalization.} The BFD
48
internal canonical form of the external formats is not exhaustive; there
49
are structures in input formats for which there is no direct
50
representation internally.  This means that the BFD back ends
51
cannot maintain all possible data richness through the transformation
52
between external to internal and back to external formats.
53
 
54
This limitation is only a problem when an application reads one
55
format and writes another.  Each BFD back end is responsible for
56
maintaining as much data as possible, and the internal BFD
57
canonical form has structures which are opaque to the BFD core,
58
and exported only to the back ends. When a file is read in one format,
59
the canonical form is generated for BFD and the application. At the
60
same time, the back end saves away any information which may otherwise
61
be lost. If the data is then written back in the same format, the back
62
end routine will be able to use the canonical form provided by the
63
BFD core as well as the information it prepared earlier.  Since
64
there is a great deal of commonality between back ends,
65
there is no information lost when
66
linking or copying big endian COFF to little endian COFF, or @code{a.out} to
67
@code{b.out}.  When a mixture of formats is linked, the information is
68
only lost from the files whose format differs from the destination.
69
 
70
@node Canonical format
71
@subsection The BFD canonical object-file format
72
 
73
The greatest potential for loss of information occurs when there is the least
74
overlap between the information provided by the source format, that
75
stored by the canonical format, and that needed by the
76
destination format. A brief description of the canonical form may help
77
you understand which kinds of data you can count on preserving across
78
conversions.
79
@cindex BFD canonical format
80
@cindex internal object-file format
81
 
82
@table @emph
83
@item files
84
Information stored on a per-file basis includes target machine
85
architecture, particular implementation format type, a demand pageable
86
bit, and a write protected bit.  Information like Unix magic numbers is
87
not stored here---only the magic numbers' meaning, so a @code{ZMAGIC}
88
file would have both the demand pageable bit and the write protected
89
text bit set.  The byte order of the target is stored on a per-file
90
basis, so that big- and little-endian object files may be used with one
91
another.
92
 
93
@item sections
94
Each section in the input file contains the name of the section, the
95
section's original address in the object file, size and alignment
96
information, various flags, and pointers into other BFD data
97
structures.
98
 
99
@item symbols
100
Each symbol contains a pointer to the information for the object file
101
which originally defined it, its name, its value, and various flag
102
bits.  When a BFD back end reads in a symbol table, it relocates all
103
symbols to make them relative to the base of the section where they were
104
defined.  Doing this ensures that each symbol points to its containing
105
section.  Each symbol also has a varying amount of hidden private data
106
for the BFD back end.  Since the symbol points to the original file, the
107
private data format for that symbol is accessible.  @code{ld} can
108
operate on a collection of symbols of wildly different formats without
109
problems.
110
 
111
Normal global and simple local symbols are maintained on output, so an
112
output file (no matter its format) will retain symbols pointing to
113
functions and to global, static, and common variables.  Some symbol
114
information is not worth retaining; in @code{a.out}, type information is
115
stored in the symbol table as long symbol names.  This information would
116
be useless to most COFF debuggers; the linker has command line switches
117
to allow users to throw it away.
118
 
119
There is one word of type information within the symbol, so if the
120
format supports symbol type information within symbols (for example, COFF,
121
IEEE, Oasys) and the type is simple enough to fit within one word
122
(nearly everything but aggregates), the information will be preserved.
123
 
124
@item relocation level
125
Each canonical BFD relocation record contains a pointer to the symbol to
126
relocate to, the offset of the data to relocate, the section the data
127
is in, and a pointer to a relocation type descriptor. Relocation is
128
performed by passing messages through the relocation type
129
descriptor and the symbol pointer. Therefore, relocations can be performed
130
on output data using a relocation method that is only available in one of the
131
input formats. For instance, Oasys provides a byte relocation format.
132
A relocation record requesting this relocation type would point
133
indirectly to a routine to perform this, so the relocation may be
134
performed on a byte being written to a 68k COFF file, even though 68k COFF
135
has no such relocation type.
136
 
137
@item line numbers
138
Object formats can contain, for debugging purposes, some form of mapping
139
between symbols, source line numbers, and addresses in the output file.
140
These addresses have to be relocated along with the symbol information.
141
Each symbol with an associated list of line number records points to the
142
first record of the list.  The head of a line number list consists of a
143
pointer to the symbol, which allows finding out the address of the
144
function whose line number is being described. The rest of the list is
145
made up of pairs: offsets into the section and line numbers. Any format
146
which can simply derive this information can pass it successfully
147
between formats (COFF, IEEE and Oasys).
148
@end table

powered by: WebSVN 2.1.0

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