* Makefile.in, as.texinfo: Renamed asdoc-config.texi to asconfig.texi.
[deliverable/binutils-gdb.git] / gas / doc / internals.texi
CommitLineData
582ffe70
KR
1@node Assembler Internals
2@chapter Assembler Internals
3@cindex internals
4
5@menu
6* Data types:: Data types
7@end menu
8
9@node foo
10@section foo
11
12BFD_ASSEMBLER
13BFD, MANY_SECTIONS, BFD_HEADERS
14
15
16@node Data types
17@section Data types
18@cindex internals, data types
19
20@subheading Symbols
21@cindex internals, symbols
22@cindex symbols, internal
23
24... `local' symbols ... flags ...
25
26The definition for @code{struct symbol}, also known as @code{symbolS},
27is located in @file{struc-symbol.h}. Symbol structures can contain the
28following fields:
29
30@table @code
31@item sy_value
32This is an @code{expressionS} that describes the value of the symbol.
33It might refer to another symbol; if so, its true value may not be known
34until @code{foo} is run.
35
36More generally, however, ... undefined? ... or an offset from the start
37of a frag pointed to by the @code{sy_frag} field.
38
39@item sy_resolved
40This field is non-zero if the symbol's value has been completely
41resolved. It is used during the final pass over the symbol table.
42
43@item sy_resolving
44This field is used to detect loops while resolving the symbol's value.
45
46@item sy_used_in_reloc
47This field is non-zero if the symbol is used by a relocation entry. If
48a local symbol is used in a relocation entry, it must be possible to
49redirect those relocations to other symbols, or this symbol cannot be
50removed from the final symbol list.
51
52@item sy_next
53@itemx sy_previous
54These pointers to other @code{symbolS} structures describe a singly or
55doubly linked list. (If @code{SYMBOLS_NEED_BACKPOINTERS} is not
56defined, the @code{sy_previous} field will be omitted.) These fields
57should be accessed with @code{symbol_next} and @code{symbol_previous}.
58
59@item sy_frag
60This points to the @code{fragS} that this symbol is attached to.
61
62@item sy_used
63Whether the symbol is used as an operand or in an expression. Note: Not
64all the backends keep this information accurate; backends which use this
65bit are responsible for setting it when a symbol is used in backend
66routines.
67
68@item bsym
69If @code{BFD_ASSEMBLER} is defined, this points to the @code{asymbol}
70that will be used in writing the object file.
71
72@item sy_name_offset
73(Only used if @code{BFD_ASSEMBLER} is not defined.)
74This is the position of the symbol's name in the symbol table of the
75object file. On some formats, this will start at position 4, with
76position 0 reserved for unnamed symbols. This field is not used until
77@code{write_object_file} is called.
78
79@item sy_symbol
80(Only used if @code{BFD_ASSEMBLER} is not defined.)
81This is the format-specific symbol structure, as it would be written into
82the object file.
83
84@item sy_number
85(Only used if @code{BFD_ASSEMBLER} is not defined.)
86This is a 24-bit symbol number, for use in constructing relocation table
87entries.
88
89@item sy_obj
90This format-specific data is of type @code{OBJ_SYMFIELD_TYPE}. If no
91macro by that name is defined in @file{obj-format.h}, this field is not
92defined.
93
94@item sy_tc
95This processor-specific data is of type @code{TC_SYMFIELD_TYPE}. If no
96macro by that name is defined in @file{targ-cpu.h}, this field is not
97defined.
98
99@item TARGET_SYMBOL_FIELDS
100If this macro is defined, it defines additional fields in the symbol
101structure. This macro is obsolete, and should be replaced when possible
102by uses of @code{OBJ_SYMFIELD_TYPE} and @code{TC_SYMFIELD_TYPE}.
103
104@end table
105
106Access with S_SET_SEGMENT, S_SET_VALUE, S_GET_VALUE, S_GET_SEGMENT,
107etc., etc.
108
109@foo Expressions
110@cindex internals, expressions
111@cindex expressions, internal
112
113Expressions are stored as a combination of operator, symbols, blah.
114
115@subheading Fixups
116@cindex internals, fixups
117@cindex fixups
118
119@subheading Frags
120@cindex internals, frags
121@cindex frags
122
123@subheading Broken Words
124@cindex internals, broken words
125@cindex broken words
126@cindex promises, promises
127
128@node What Happens?
129@section What Happens?
130
131Blah blah blah, initialization, argument parsing, file reading,
132whitespace munging, opcode parsing and lookup, operand parsing. Now
133it's time to write the output file.
134
135In @code{BFD_ASSEMBLER} mode, processing of relocations and symbols and
136creation of the output file is initiated by calling
137@code{write_object_file}.
138
139@node Target Dependent Definitions
140@section Target Dependent Definitions
141
142@subheader Format-specific definitions
143
144@defmac obj_sec_sym_ok_for_reloc section
145(@code{BFD_ASSEMBLER} only.)
146Is it okay to use this section's section-symbol in a relocation entry?
147If not, a new internal-linkage symbol is generated and emitted if such a
148relocation entry is needed. (Default: Always use a new symbol.)
149
150@defmac EMIT_SECTION_SYMBOLS
151(@code{BFD_ASSEMBLER} only.)
152Should section symbols be included in the symbol list if they're used in
153relocations? Some formats can generate section-relative relocations,
154and thus don't need
155(Default: 1.)
156
157@node Source File Summary
158@section Source File Summary
159
160The code in the @file{obj-coff} back end assumes @code{BFD_ASSEMBLER} is
161defined; the code in @file{obj-coffbfd} uses @code{BFD},
162@code{BFD_HEADERS}, and @code{MANY_SEGMENTS}, but does a lot of the file
163positioning itself. This confusing situation arose from the history of
164the code.
165
166Originally, @file{obj-coff} was a purely non-BFD version, and
167@file{obj-coffbfd} was created to use BFD for low-level byte-swapping.
168When the @code{BFD_ASSEMBLER} conversion started, the first COFF target
169to be converted was using @file{obj-coff}, and the two files had
170diverged somewhat, and I didn't feel like first converting the support
171of that target over to use the low-level BFD interface.
172
173Currently, all COFF targets use one of the two BFD interfaces, so the
174non-BFD code can be removed. Eventually, all should be converted to
175using one COFF back end, which uses the high-level BFD interface.
This page took 0.03189 seconds and 4 git commands to generate.