1 |
1181 |
sfurman |
This is bfd.info, produced by makeinfo version 4.1 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, 2000, 2001 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
|
16 |
|
|
section entitled "GNU Free Documentation License".
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
File: bfd.info, Node: typedef asection, Next: section prototypes, Prev: Section Output, Up: Sections
|
20 |
|
|
|
21 |
|
|
typedef asection
|
22 |
|
|
----------------
|
23 |
|
|
|
24 |
|
|
Here is the section structure:
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
/* This structure is used for a comdat section, as in PE. A comdat
|
28 |
|
|
section is associated with a particular symbol. When the linker
|
29 |
|
|
sees a comdat section, it keeps only one of the sections with a
|
30 |
|
|
given name and associated with a given symbol. */
|
31 |
|
|
|
32 |
|
|
struct bfd_comdat_info
|
33 |
|
|
{
|
34 |
|
|
/* The name of the symbol associated with a comdat section. */
|
35 |
|
|
const char *name;
|
36 |
|
|
|
37 |
|
|
/* The local symbol table index of the symbol associated with a
|
38 |
|
|
comdat section. This is only meaningful to the object file format
|
39 |
|
|
specific code; it is not an index into the list returned by
|
40 |
|
|
bfd_canonicalize_symtab. */
|
41 |
|
|
long symbol;
|
42 |
|
|
};
|
43 |
|
|
|
44 |
|
|
typedef struct sec
|
45 |
|
|
{
|
46 |
|
|
/* The name of the section; the name isn't a copy, the pointer is
|
47 |
|
|
the same as that passed to bfd_make_section. */
|
48 |
|
|
const char *name;
|
49 |
|
|
|
50 |
|
|
/* A unique sequence number. */
|
51 |
|
|
int id;
|
52 |
|
|
|
53 |
|
|
/* Which section in the bfd; 0..n-1 as sections are created in a bfd. */
|
54 |
|
|
int index;
|
55 |
|
|
|
56 |
|
|
/* The next section in the list belonging to the BFD, or NULL. */
|
57 |
|
|
struct sec *next;
|
58 |
|
|
|
59 |
|
|
/* The field flags contains attributes of the section. Some
|
60 |
|
|
flags are read in from the object file, and some are
|
61 |
|
|
synthesized from other information. */
|
62 |
|
|
flagword flags;
|
63 |
|
|
|
64 |
|
|
#define SEC_NO_FLAGS 0x000
|
65 |
|
|
|
66 |
|
|
/* Tells the OS to allocate space for this section when loading.
|
67 |
|
|
This is clear for a section containing debug information only. */
|
68 |
|
|
#define SEC_ALLOC 0x001
|
69 |
|
|
|
70 |
|
|
/* Tells the OS to load the section from the file when loading.
|
71 |
|
|
This is clear for a .bss section. */
|
72 |
|
|
#define SEC_LOAD 0x002
|
73 |
|
|
|
74 |
|
|
/* The section contains data still to be relocated, so there is
|
75 |
|
|
some relocation information too. */
|
76 |
|
|
#define SEC_RELOC 0x004
|
77 |
|
|
|
78 |
|
|
/* ELF reserves 4 processor specific bits and 8 operating system
|
79 |
|
|
specific bits in sh_flags; at present we can get away with just
|
80 |
|
|
one in communicating between the assembler and BFD, but this
|
81 |
|
|
isn't a good long-term solution. */
|
82 |
|
|
#define SEC_ARCH_BIT_0 0x008
|
83 |
|
|
|
84 |
|
|
/* A signal to the OS that the section contains read only data. */
|
85 |
|
|
#define SEC_READONLY 0x010
|
86 |
|
|
|
87 |
|
|
/* The section contains code only. */
|
88 |
|
|
#define SEC_CODE 0x020
|
89 |
|
|
|
90 |
|
|
/* The section contains data only. */
|
91 |
|
|
#define SEC_DATA 0x040
|
92 |
|
|
|
93 |
|
|
/* The section will reside in ROM. */
|
94 |
|
|
#define SEC_ROM 0x080
|
95 |
|
|
|
96 |
|
|
/* The section contains constructor information. This section
|
97 |
|
|
type is used by the linker to create lists of constructors and
|
98 |
|
|
destructors used by `g++'. When a back end sees a symbol
|
99 |
|
|
which should be used in a constructor list, it creates a new
|
100 |
|
|
section for the type of name (e.g., `__CTOR_LIST__'), attaches
|
101 |
|
|
the symbol to it, and builds a relocation. To build the lists
|
102 |
|
|
of constructors, all the linker has to do is catenate all the
|
103 |
|
|
sections called `__CTOR_LIST__' and relocate the data
|
104 |
|
|
contained within - exactly the operations it would peform on
|
105 |
|
|
standard data. */
|
106 |
|
|
#define SEC_CONSTRUCTOR 0x100
|
107 |
|
|
|
108 |
|
|
/* The section has contents - a data section could be
|
109 |
|
|
`SEC_ALLOC' | `SEC_HAS_CONTENTS'; a debug section could be
|
110 |
|
|
`SEC_HAS_CONTENTS' */
|
111 |
|
|
#define SEC_HAS_CONTENTS 0x200
|
112 |
|
|
|
113 |
|
|
/* An instruction to the linker to not output the section
|
114 |
|
|
even if it has information which would normally be written. */
|
115 |
|
|
#define SEC_NEVER_LOAD 0x400
|
116 |
|
|
|
117 |
|
|
/* The section is a COFF shared library section. This flag is
|
118 |
|
|
only for the linker. If this type of section appears in
|
119 |
|
|
the input file, the linker must copy it to the output file
|
120 |
|
|
without changing the vma or size. FIXME: Although this
|
121 |
|
|
was originally intended to be general, it really is COFF
|
122 |
|
|
specific (and the flag was renamed to indicate this). It
|
123 |
|
|
might be cleaner to have some more general mechanism to
|
124 |
|
|
allow the back end to control what the linker does with
|
125 |
|
|
sections. */
|
126 |
|
|
#define SEC_COFF_SHARED_LIBRARY 0x800
|
127 |
|
|
|
128 |
|
|
/* The section contains thread local data. */
|
129 |
|
|
#define SEC_THREAD_LOCAL 0x1000
|
130 |
|
|
|
131 |
|
|
/* The section has GOT references. This flag is only for the
|
132 |
|
|
linker, and is currently only used by the elf32-hppa back end.
|
133 |
|
|
It will be set if global offset table references were detected
|
134 |
|
|
in this section, which indicate to the linker that the section
|
135 |
|
|
contains PIC code, and must be handled specially when doing a
|
136 |
|
|
static link. */
|
137 |
|
|
#define SEC_HAS_GOT_REF 0x4000
|
138 |
|
|
|
139 |
|
|
/* The section contains common symbols (symbols may be defined
|
140 |
|
|
multiple times, the value of a symbol is the amount of
|
141 |
|
|
space it requires, and the largest symbol value is the one
|
142 |
|
|
used). Most targets have exactly one of these (which we
|
143 |
|
|
translate to bfd_com_section_ptr), but ECOFF has two. */
|
144 |
|
|
#define SEC_IS_COMMON 0x8000
|
145 |
|
|
|
146 |
|
|
/* The section contains only debugging information. For
|
147 |
|
|
example, this is set for ELF .debug and .stab sections.
|
148 |
|
|
strip tests this flag to see if a section can be
|
149 |
|
|
discarded. */
|
150 |
|
|
#define SEC_DEBUGGING 0x10000
|
151 |
|
|
|
152 |
|
|
/* The contents of this section are held in memory pointed to
|
153 |
|
|
by the contents field. This is checked by bfd_get_section_contents,
|
154 |
|
|
and the data is retrieved from memory if appropriate. */
|
155 |
|
|
#define SEC_IN_MEMORY 0x20000
|
156 |
|
|
|
157 |
|
|
/* The contents of this section are to be excluded by the
|
158 |
|
|
linker for executable and shared objects unless those
|
159 |
|
|
objects are to be further relocated. */
|
160 |
|
|
#define SEC_EXCLUDE 0x40000
|
161 |
|
|
|
162 |
|
|
/* The contents of this section are to be sorted based on the sum of
|
163 |
|
|
the symbol and addend values specified by the associated relocation
|
164 |
|
|
entries. Entries without associated relocation entries will be
|
165 |
|
|
appended to the end of the section in an unspecified order. */
|
166 |
|
|
#define SEC_SORT_ENTRIES 0x80000
|
167 |
|
|
|
168 |
|
|
/* When linking, duplicate sections of the same name should be
|
169 |
|
|
discarded, rather than being combined into a single section as
|
170 |
|
|
is usually done. This is similar to how common symbols are
|
171 |
|
|
handled. See SEC_LINK_DUPLICATES below. */
|
172 |
|
|
#define SEC_LINK_ONCE 0x100000
|
173 |
|
|
|
174 |
|
|
/* If SEC_LINK_ONCE is set, this bitfield describes how the linker
|
175 |
|
|
should handle duplicate sections. */
|
176 |
|
|
#define SEC_LINK_DUPLICATES 0x600000
|
177 |
|
|
|
178 |
|
|
/* This value for SEC_LINK_DUPLICATES means that duplicate
|
179 |
|
|
sections with the same name should simply be discarded. */
|
180 |
|
|
#define SEC_LINK_DUPLICATES_DISCARD 0x0
|
181 |
|
|
|
182 |
|
|
/* This value for SEC_LINK_DUPLICATES means that the linker
|
183 |
|
|
should warn if there are any duplicate sections, although
|
184 |
|
|
it should still only link one copy. */
|
185 |
|
|
#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000
|
186 |
|
|
|
187 |
|
|
/* This value for SEC_LINK_DUPLICATES means that the linker
|
188 |
|
|
should warn if any duplicate sections are a different size. */
|
189 |
|
|
#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000
|
190 |
|
|
|
191 |
|
|
/* This value for SEC_LINK_DUPLICATES means that the linker
|
192 |
|
|
should warn if any duplicate sections contain different
|
193 |
|
|
contents. */
|
194 |
|
|
#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000
|
195 |
|
|
|
196 |
|
|
/* This section was created by the linker as part of dynamic
|
197 |
|
|
relocation or other arcane processing. It is skipped when
|
198 |
|
|
going through the first-pass output, trusting that someone
|
199 |
|
|
else up the line will take care of it later. */
|
200 |
|
|
#define SEC_LINKER_CREATED 0x800000
|
201 |
|
|
|
202 |
|
|
/* This section should not be subject to garbage collection. */
|
203 |
|
|
#define SEC_KEEP 0x1000000
|
204 |
|
|
|
205 |
|
|
/* This section contains "short" data, and should be placed
|
206 |
|
|
"near" the GP. */
|
207 |
|
|
#define SEC_SMALL_DATA 0x2000000
|
208 |
|
|
|
209 |
|
|
/* This section contains data which may be shared with other
|
210 |
|
|
executables or shared objects. */
|
211 |
|
|
#define SEC_SHARED 0x4000000
|
212 |
|
|
|
213 |
|
|
/* When a section with this flag is being linked, then if the size of
|
214 |
|
|
the input section is less than a page, it should not cross a page
|
215 |
|
|
boundary. If the size of the input section is one page or more, it
|
216 |
|
|
should be aligned on a page boundary. */
|
217 |
|
|
#define SEC_BLOCK 0x8000000
|
218 |
|
|
|
219 |
|
|
/* Conditionally link this section; do not link if there are no
|
220 |
|
|
references found to any symbol in the section. */
|
221 |
|
|
#define SEC_CLINK 0x10000000
|
222 |
|
|
|
223 |
|
|
/* Attempt to merge identical entities in the section.
|
224 |
|
|
Entity size is given in the entsize field. */
|
225 |
|
|
#define SEC_MERGE 0x20000000
|
226 |
|
|
|
227 |
|
|
/* If given with SEC_MERGE, entities to merge are zero terminated
|
228 |
|
|
strings where entsize specifies character size instead of fixed
|
229 |
|
|
size entries. */
|
230 |
|
|
#define SEC_STRINGS 0x40000000
|
231 |
|
|
|
232 |
|
|
/* This section contains data about section groups. */
|
233 |
|
|
#define SEC_GROUP 0x80000000
|
234 |
|
|
|
235 |
|
|
/* End of section flags. */
|
236 |
|
|
|
237 |
|
|
/* Some internal packed boolean fields. */
|
238 |
|
|
|
239 |
|
|
/* See the vma field. */
|
240 |
|
|
unsigned int user_set_vma : 1;
|
241 |
|
|
|
242 |
|
|
/* Whether relocations have been processed. */
|
243 |
|
|
unsigned int reloc_done : 1;
|
244 |
|
|
|
245 |
|
|
/* A mark flag used by some of the linker backends. */
|
246 |
|
|
unsigned int linker_mark : 1;
|
247 |
|
|
|
248 |
|
|
/* Another mark flag used by some of the linker backends. Set for
|
249 |
|
|
output sections that have an input section. */
|
250 |
|
|
unsigned int linker_has_input : 1;
|
251 |
|
|
|
252 |
|
|
/* A mark flag used by some linker backends for garbage collection. */
|
253 |
|
|
unsigned int gc_mark : 1;
|
254 |
|
|
|
255 |
|
|
/* Used by the ELF code to mark sections which have been allocated
|
256 |
|
|
to segments. */
|
257 |
|
|
unsigned int segment_mark : 1;
|
258 |
|
|
|
259 |
|
|
/* End of internal packed boolean fields. */
|
260 |
|
|
|
261 |
|
|
/* The virtual memory address of the section - where it will be
|
262 |
|
|
at run time. The symbols are relocated against this. The
|
263 |
|
|
user_set_vma flag is maintained by bfd; if it's not set, the
|
264 |
|
|
backend can assign addresses (for example, in `a.out', where
|
265 |
|
|
the default address for `.data' is dependent on the specific
|
266 |
|
|
target and various flags). */
|
267 |
|
|
bfd_vma vma;
|
268 |
|
|
|
269 |
|
|
/* The load address of the section - where it would be in a
|
270 |
|
|
rom image; really only used for writing section header
|
271 |
|
|
information. */
|
272 |
|
|
bfd_vma lma;
|
273 |
|
|
|
274 |
|
|
/* The size of the section in octets, as it will be output.
|
275 |
|
|
Contains a value even if the section has no contents (e.g., the
|
276 |
|
|
size of `.bss'). This will be filled in after relocation. */
|
277 |
|
|
bfd_size_type _cooked_size;
|
278 |
|
|
|
279 |
|
|
/* The original size on disk of the section, in octets. Normally this
|
280 |
|
|
value is the same as the size, but if some relaxing has
|
281 |
|
|
been done, then this value will be bigger. */
|
282 |
|
|
bfd_size_type _raw_size;
|
283 |
|
|
|
284 |
|
|
/* If this section is going to be output, then this value is the
|
285 |
|
|
offset in *bytes* into the output section of the first byte in the
|
286 |
|
|
input section (byte ==> smallest addressable unit on the
|
287 |
|
|
target). In most cases, if this was going to start at the
|
288 |
|
|
100th octet (8-bit quantity) in the output section, this value
|
289 |
|
|
would be 100. However, if the target byte size is 16 bits
|
290 |
|
|
(bfd_octets_per_byte is "2"), this value would be 50. */
|
291 |
|
|
bfd_vma output_offset;
|
292 |
|
|
|
293 |
|
|
/* The output section through which to map on output. */
|
294 |
|
|
struct sec *output_section;
|
295 |
|
|
|
296 |
|
|
/* The alignment requirement of the section, as an exponent of 2 -
|
297 |
|
|
e.g., 3 aligns to 2^3 (or 8). */
|
298 |
|
|
unsigned int alignment_power;
|
299 |
|
|
|
300 |
|
|
/* If an input section, a pointer to a vector of relocation
|
301 |
|
|
records for the data in this section. */
|
302 |
|
|
struct reloc_cache_entry *relocation;
|
303 |
|
|
|
304 |
|
|
/* If an output section, a pointer to a vector of pointers to
|
305 |
|
|
relocation records for the data in this section. */
|
306 |
|
|
struct reloc_cache_entry **orelocation;
|
307 |
|
|
|
308 |
|
|
/* The number of relocation records in one of the above. */
|
309 |
|
|
unsigned reloc_count;
|
310 |
|
|
|
311 |
|
|
/* Information below is back end specific - and not always used
|
312 |
|
|
or updated. */
|
313 |
|
|
|
314 |
|
|
/* File position of section data. */
|
315 |
|
|
file_ptr filepos;
|
316 |
|
|
|
317 |
|
|
/* File position of relocation info. */
|
318 |
|
|
file_ptr rel_filepos;
|
319 |
|
|
|
320 |
|
|
/* File position of line data. */
|
321 |
|
|
file_ptr line_filepos;
|
322 |
|
|
|
323 |
|
|
/* Pointer to data for applications. */
|
324 |
|
|
PTR userdata;
|
325 |
|
|
|
326 |
|
|
/* If the SEC_IN_MEMORY flag is set, this points to the actual
|
327 |
|
|
contents. */
|
328 |
|
|
unsigned char *contents;
|
329 |
|
|
|
330 |
|
|
/* Attached line number information. */
|
331 |
|
|
alent *lineno;
|
332 |
|
|
|
333 |
|
|
/* Number of line number records. */
|
334 |
|
|
unsigned int lineno_count;
|
335 |
|
|
|
336 |
|
|
/* Entity size for merging purposes. */
|
337 |
|
|
unsigned int entsize;
|
338 |
|
|
|
339 |
|
|
/* Optional information about a COMDAT entry; NULL if not COMDAT. */
|
340 |
|
|
struct bfd_comdat_info *comdat;
|
341 |
|
|
|
342 |
|
|
/* When a section is being output, this value changes as more
|
343 |
|
|
linenumbers are written out. */
|
344 |
|
|
file_ptr moving_line_filepos;
|
345 |
|
|
|
346 |
|
|
/* What the section number is in the target world. */
|
347 |
|
|
int target_index;
|
348 |
|
|
|
349 |
|
|
PTR used_by_bfd;
|
350 |
|
|
|
351 |
|
|
/* If this is a constructor section then here is a list of the
|
352 |
|
|
relocations created to relocate items within it. */
|
353 |
|
|
struct relent_chain *constructor_chain;
|
354 |
|
|
|
355 |
|
|
/* The BFD which owns the section. */
|
356 |
|
|
bfd *owner;
|
357 |
|
|
|
358 |
|
|
/* A symbol which points at this section only. */
|
359 |
|
|
struct symbol_cache_entry *symbol;
|
360 |
|
|
struct symbol_cache_entry **symbol_ptr_ptr;
|
361 |
|
|
|
362 |
|
|
struct bfd_link_order *link_order_head;
|
363 |
|
|
struct bfd_link_order *link_order_tail;
|
364 |
|
|
} asection;
|
365 |
|
|
|
366 |
|
|
/* These sections are global, and are managed by BFD. The application
|
367 |
|
|
and target back end are not permitted to change the values in
|
368 |
|
|
these sections. New code should use the section_ptr macros rather
|
369 |
|
|
than referring directly to the const sections. The const sections
|
370 |
|
|
may eventually vanish. */
|
371 |
|
|
#define BFD_ABS_SECTION_NAME "*ABS*"
|
372 |
|
|
#define BFD_UND_SECTION_NAME "*UND*"
|
373 |
|
|
#define BFD_COM_SECTION_NAME "*COM*"
|
374 |
|
|
#define BFD_IND_SECTION_NAME "*IND*"
|
375 |
|
|
|
376 |
|
|
/* The absolute section. */
|
377 |
|
|
extern const asection bfd_abs_section;
|
378 |
|
|
#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
|
379 |
|
|
#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
|
380 |
|
|
/* Pointer to the undefined section. */
|
381 |
|
|
extern const asection bfd_und_section;
|
382 |
|
|
#define bfd_und_section_ptr ((asection *) &bfd_und_section)
|
383 |
|
|
#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
|
384 |
|
|
/* Pointer to the common section. */
|
385 |
|
|
extern const asection bfd_com_section;
|
386 |
|
|
#define bfd_com_section_ptr ((asection *) &bfd_com_section)
|
387 |
|
|
/* Pointer to the indirect section. */
|
388 |
|
|
extern const asection bfd_ind_section;
|
389 |
|
|
#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
|
390 |
|
|
#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
|
391 |
|
|
|
392 |
|
|
#define bfd_is_const_section(SEC) \
|
393 |
|
|
( ((SEC) == bfd_abs_section_ptr) \
|
394 |
|
|
|| ((SEC) == bfd_und_section_ptr) \
|
395 |
|
|
|| ((SEC) == bfd_com_section_ptr) \
|
396 |
|
|
|| ((SEC) == bfd_ind_section_ptr))
|
397 |
|
|
|
398 |
|
|
extern const struct symbol_cache_entry * const bfd_abs_symbol;
|
399 |
|
|
extern const struct symbol_cache_entry * const bfd_com_symbol;
|
400 |
|
|
extern const struct symbol_cache_entry * const bfd_und_symbol;
|
401 |
|
|
extern const struct symbol_cache_entry * const bfd_ind_symbol;
|
402 |
|
|
#define bfd_get_section_size_before_reloc(section) \
|
403 |
|
|
((section)->reloc_done ? (abort (), (bfd_size_type) 1) \
|
404 |
|
|
: (section)->_raw_size)
|
405 |
|
|
#define bfd_get_section_size_after_reloc(section) \
|
406 |
|
|
((section)->reloc_done ? (section)->_cooked_size \
|
407 |
|
|
: (abort (), (bfd_size_type) 1))
|
408 |
|
|
|
409 |
|
|
/* Macros to handle insertion and deletion of a bfd's sections. These
|
410 |
|
|
only handle the list pointers, ie. do not adjust section_count,
|
411 |
|
|
target_index etc. */
|
412 |
|
|
#define bfd_section_list_remove(ABFD, PS) \
|
413 |
|
|
do \
|
414 |
|
|
{ \
|
415 |
|
|
asection **_ps = PS; \
|
416 |
|
|
asection *_s = *_ps; \
|
417 |
|
|
*_ps = _s->next; \
|
418 |
|
|
if (_s->next == NULL) \
|
419 |
|
|
(ABFD)->section_tail = _ps; \
|
420 |
|
|
} \
|
421 |
|
|
while (0)
|
422 |
|
|
#define bfd_section_list_insert(ABFD, PS, S) \
|
423 |
|
|
do \
|
424 |
|
|
{ \
|
425 |
|
|
asection **_ps = PS; \
|
426 |
|
|
asection *_s = S; \
|
427 |
|
|
_s->next = *_ps; \
|
428 |
|
|
*_ps = _s; \
|
429 |
|
|
if (_s->next == NULL) \
|
430 |
|
|
(ABFD)->section_tail = &_s->next; \
|
431 |
|
|
} \
|
432 |
|
|
while (0)
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
File: bfd.info, Node: section prototypes, Prev: typedef asection, Up: Sections
|
436 |
|
|
|
437 |
|
|
Section prototypes
|
438 |
|
|
------------------
|
439 |
|
|
|
440 |
|
|
These are the functions exported by the section handling part of BFD.
|
441 |
|
|
|
442 |
|
|
`bfd_section_list_clear'
|
443 |
|
|
........................
|
444 |
|
|
|
445 |
|
|
*Synopsis*
|
446 |
|
|
void bfd_section_list_clear (bfd *);
|
447 |
|
|
*Description*
|
448 |
|
|
Clears the section list, and also resets the section count and hash
|
449 |
|
|
table entries.
|
450 |
|
|
|
451 |
|
|
`bfd_get_section_by_name'
|
452 |
|
|
.........................
|
453 |
|
|
|
454 |
|
|
*Synopsis*
|
455 |
|
|
asection *bfd_get_section_by_name(bfd *abfd, const char *name);
|
456 |
|
|
*Description*
|
457 |
|
|
Run through ABFD and return the one of the `asection's whose name
|
458 |
|
|
matches NAME, otherwise `NULL'. *Note Sections::, for more information.
|
459 |
|
|
|
460 |
|
|
This should only be used in special cases; the normal way to process
|
461 |
|
|
all sections of a given name is to use `bfd_map_over_sections' and
|
462 |
|
|
`strcmp' on the name (or better yet, base it on the section flags or
|
463 |
|
|
something else) for each section.
|
464 |
|
|
|
465 |
|
|
`bfd_get_unique_section_name'
|
466 |
|
|
.............................
|
467 |
|
|
|
468 |
|
|
*Synopsis*
|
469 |
|
|
char *bfd_get_unique_section_name(bfd *abfd,
|
470 |
|
|
const char *templat,
|
471 |
|
|
int *count);
|
472 |
|
|
*Description*
|
473 |
|
|
Invent a section name that is unique in ABFD by tacking a dot and a
|
474 |
|
|
digit suffix onto the original TEMPLAT. If COUNT is non-NULL, then it
|
475 |
|
|
specifies the first number tried as a suffix to generate a unique name.
|
476 |
|
|
The value pointed to by COUNT will be incremented in this case.
|
477 |
|
|
|
478 |
|
|
`bfd_make_section_old_way'
|
479 |
|
|
..........................
|
480 |
|
|
|
481 |
|
|
*Synopsis*
|
482 |
|
|
asection *bfd_make_section_old_way(bfd *abfd, const char *name);
|
483 |
|
|
*Description*
|
484 |
|
|
Create a new empty section called NAME and attach it to the end of the
|
485 |
|
|
chain of sections for the BFD ABFD. An attempt to create a section with
|
486 |
|
|
a name which is already in use returns its pointer without changing the
|
487 |
|
|
section chain.
|
488 |
|
|
|
489 |
|
|
It has the funny name since this is the way it used to be before it
|
490 |
|
|
was rewritten....
|
491 |
|
|
|
492 |
|
|
Possible errors are:
|
493 |
|
|
* `bfd_error_invalid_operation' - If output has already started for
|
494 |
|
|
this BFD.
|
495 |
|
|
|
496 |
|
|
* `bfd_error_no_memory' - If memory allocation fails.
|
497 |
|
|
|
498 |
|
|
`bfd_make_section_anyway'
|
499 |
|
|
.........................
|
500 |
|
|
|
501 |
|
|
*Synopsis*
|
502 |
|
|
asection *bfd_make_section_anyway(bfd *abfd, const char *name);
|
503 |
|
|
*Description*
|
504 |
|
|
Create a new empty section called NAME and attach it to the end of the
|
505 |
|
|
chain of sections for ABFD. Create a new section even if there is
|
506 |
|
|
already a section with that name.
|
507 |
|
|
|
508 |
|
|
Return `NULL' and set `bfd_error' on error; possible errors are:
|
509 |
|
|
* `bfd_error_invalid_operation' - If output has already started for
|
510 |
|
|
ABFD.
|
511 |
|
|
|
512 |
|
|
* `bfd_error_no_memory' - If memory allocation fails.
|
513 |
|
|
|
514 |
|
|
`bfd_make_section'
|
515 |
|
|
..................
|
516 |
|
|
|
517 |
|
|
*Synopsis*
|
518 |
|
|
asection *bfd_make_section(bfd *, const char *name);
|
519 |
|
|
*Description*
|
520 |
|
|
Like `bfd_make_section_anyway', but return `NULL' (without calling
|
521 |
|
|
bfd_set_error ()) without changing the section chain if there is
|
522 |
|
|
already a section named NAME. If there is an error, return `NULL' and
|
523 |
|
|
set `bfd_error'.
|
524 |
|
|
|
525 |
|
|
`bfd_set_section_flags'
|
526 |
|
|
.......................
|
527 |
|
|
|
528 |
|
|
*Synopsis*
|
529 |
|
|
boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);
|
530 |
|
|
*Description*
|
531 |
|
|
Set the attributes of the section SEC in the BFD ABFD to the value
|
532 |
|
|
FLAGS. Return `true' on success, `false' on error. Possible error
|
533 |
|
|
returns are:
|
534 |
|
|
|
535 |
|
|
* `bfd_error_invalid_operation' - The section cannot have one or
|
536 |
|
|
more of the attributes requested. For example, a .bss section in
|
537 |
|
|
`a.out' may not have the `SEC_HAS_CONTENTS' field set.
|
538 |
|
|
|
539 |
|
|
`bfd_map_over_sections'
|
540 |
|
|
.......................
|
541 |
|
|
|
542 |
|
|
*Synopsis*
|
543 |
|
|
void bfd_map_over_sections(bfd *abfd,
|
544 |
|
|
void (*func) (bfd *abfd,
|
545 |
|
|
asection *sect,
|
546 |
|
|
PTR obj),
|
547 |
|
|
PTR obj);
|
548 |
|
|
*Description*
|
549 |
|
|
Call the provided function FUNC for each section attached to the BFD
|
550 |
|
|
ABFD, passing OBJ as an argument. The function will be called as if by
|
551 |
|
|
|
552 |
|
|
func(abfd, the_section, obj);
|
553 |
|
|
|
554 |
|
|
This is the prefered method for iterating over sections; an
|
555 |
|
|
alternative would be to use a loop:
|
556 |
|
|
|
557 |
|
|
section *p;
|
558 |
|
|
for (p = abfd->sections; p != NULL; p = p->next)
|
559 |
|
|
func(abfd, p, ...)
|
560 |
|
|
|
561 |
|
|
`bfd_set_section_size'
|
562 |
|
|
......................
|
563 |
|
|
|
564 |
|
|
*Synopsis*
|
565 |
|
|
boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);
|
566 |
|
|
*Description*
|
567 |
|
|
Set SEC to the size VAL. If the operation is ok, then `true' is
|
568 |
|
|
returned, else `false'.
|
569 |
|
|
|
570 |
|
|
Possible error returns:
|
571 |
|
|
* `bfd_error_invalid_operation' - Writing has started to the BFD, so
|
572 |
|
|
setting the size is invalid.
|
573 |
|
|
|
574 |
|
|
`bfd_set_section_contents'
|
575 |
|
|
..........................
|
576 |
|
|
|
577 |
|
|
*Synopsis*
|
578 |
|
|
boolean bfd_set_section_contents (bfd *abfd, asection *section,
|
579 |
|
|
PTR data, file_ptr offset,
|
580 |
|
|
bfd_size_type count);
|
581 |
|
|
*Description*
|
582 |
|
|
Sets the contents of the section SECTION in BFD ABFD to the data
|
583 |
|
|
starting in memory at DATA. The data is written to the output section
|
584 |
|
|
starting at offset OFFSET for COUNT octets.
|
585 |
|
|
|
586 |
|
|
Normally `true' is returned, else `false'. Possible error returns
|
587 |
|
|
are:
|
588 |
|
|
* `bfd_error_no_contents' - The output section does not have the
|
589 |
|
|
`SEC_HAS_CONTENTS' attribute, so nothing can be written to it.
|
590 |
|
|
|
591 |
|
|
* and some more too
|
592 |
|
|
This routine is front end to the back end function
|
593 |
|
|
`_bfd_set_section_contents'.
|
594 |
|
|
|
595 |
|
|
`bfd_get_section_contents'
|
596 |
|
|
..........................
|
597 |
|
|
|
598 |
|
|
*Synopsis*
|
599 |
|
|
boolean bfd_get_section_contents (bfd *abfd, asection *section,
|
600 |
|
|
PTR location, file_ptr offset,
|
601 |
|
|
bfd_size_type count);
|
602 |
|
|
*Description*
|
603 |
|
|
Read data from SECTION in BFD ABFD into memory starting at LOCATION.
|
604 |
|
|
The data is read at an offset of OFFSET from the start of the input
|
605 |
|
|
section, and is read for COUNT bytes.
|
606 |
|
|
|
607 |
|
|
If the contents of a constructor with the `SEC_CONSTRUCTOR' flag set
|
608 |
|
|
are requested or if the section does not have the `SEC_HAS_CONTENTS'
|
609 |
|
|
flag set, then the LOCATION is filled with zeroes. If no errors occur,
|
610 |
|
|
`true' is returned, else `false'.
|
611 |
|
|
|
612 |
|
|
`bfd_copy_private_section_data'
|
613 |
|
|
...............................
|
614 |
|
|
|
615 |
|
|
*Synopsis*
|
616 |
|
|
boolean bfd_copy_private_section_data (bfd *ibfd, asection *isec,
|
617 |
|
|
bfd *obfd, asection *osec);
|
618 |
|
|
*Description*
|
619 |
|
|
Copy private section information from ISEC in the BFD IBFD to the
|
620 |
|
|
section OSEC in the BFD OBFD. Return `true' on success, `false' on
|
621 |
|
|
error. Possible error returns are:
|
622 |
|
|
|
623 |
|
|
* `bfd_error_no_memory' - Not enough memory exists to create private
|
624 |
|
|
data for OSEC.
|
625 |
|
|
|
626 |
|
|
#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
|
627 |
|
|
BFD_SEND (obfd, _bfd_copy_private_section_data, \
|
628 |
|
|
(ibfd, isection, obfd, osection))
|
629 |
|
|
|
630 |
|
|
`_bfd_strip_section_from_output'
|
631 |
|
|
................................
|
632 |
|
|
|
633 |
|
|
*Synopsis*
|
634 |
|
|
void _bfd_strip_section_from_output
|
635 |
|
|
(struct bfd_link_info *info, asection *section);
|
636 |
|
|
*Description*
|
637 |
|
|
Remove SECTION from the output. If the output section becomes empty,
|
638 |
|
|
remove it from the output bfd.
|
639 |
|
|
|
640 |
|
|
This function won't actually do anything except twiddle flags if
|
641 |
|
|
called too late in the linking process, when it's not safe to remove
|
642 |
|
|
sections.
|
643 |
|
|
|
644 |
|
|
`bfd_generic_discard_group'
|
645 |
|
|
...........................
|
646 |
|
|
|
647 |
|
|
*Synopsis*
|
648 |
|
|
boolean bfd_generic_discard_group (bfd *abfd, asection *group);
|
649 |
|
|
*Description*
|
650 |
|
|
Remove all members of GROUP from the output.
|
651 |
|
|
|
652 |
|
|
|
653 |
|
|
File: bfd.info, Node: Symbols, Next: Archives, Prev: Sections, Up: BFD front end
|
654 |
|
|
|
655 |
|
|
Symbols
|
656 |
|
|
=======
|
657 |
|
|
|
658 |
|
|
BFD tries to maintain as much symbol information as it can when it
|
659 |
|
|
moves information from file to file. BFD passes information to
|
660 |
|
|
applications though the `asymbol' structure. When the application
|
661 |
|
|
requests the symbol table, BFD reads the table in the native form and
|
662 |
|
|
translates parts of it into the internal format. To maintain more than
|
663 |
|
|
the information passed to applications, some targets keep some
|
664 |
|
|
information "behind the scenes" in a structure only the particular back
|
665 |
|
|
end knows about. For example, the coff back end keeps the original
|
666 |
|
|
symbol table structure as well as the canonical structure when a BFD is
|
667 |
|
|
read in. On output, the coff back end can reconstruct the output symbol
|
668 |
|
|
table so that no information is lost, even information unique to coff
|
669 |
|
|
which BFD doesn't know or understand. If a coff symbol table were read,
|
670 |
|
|
but were written through an a.out back end, all the coff specific
|
671 |
|
|
information would be lost. The symbol table of a BFD is not necessarily
|
672 |
|
|
read in until a canonicalize request is made. Then the BFD back end
|
673 |
|
|
fills in a table provided by the application with pointers to the
|
674 |
|
|
canonical information. To output symbols, the application provides BFD
|
675 |
|
|
with a table of pointers to pointers to `asymbol's. This allows
|
676 |
|
|
applications like the linker to output a symbol as it was read, since
|
677 |
|
|
the "behind the scenes" information will be still available.
|
678 |
|
|
|
679 |
|
|
* Menu:
|
680 |
|
|
|
681 |
|
|
* Reading Symbols::
|
682 |
|
|
* Writing Symbols::
|
683 |
|
|
* Mini Symbols::
|
684 |
|
|
* typedef asymbol::
|
685 |
|
|
* symbol handling functions::
|
686 |
|
|
|
687 |
|
|
|
688 |
|
|
File: bfd.info, Node: Reading Symbols, Next: Writing Symbols, Prev: Symbols, Up: Symbols
|
689 |
|
|
|
690 |
|
|
Reading symbols
|
691 |
|
|
---------------
|
692 |
|
|
|
693 |
|
|
There are two stages to reading a symbol table from a BFD:
|
694 |
|
|
allocating storage, and the actual reading process. This is an excerpt
|
695 |
|
|
from an application which reads the symbol table:
|
696 |
|
|
|
697 |
|
|
long storage_needed;
|
698 |
|
|
asymbol **symbol_table;
|
699 |
|
|
long number_of_symbols;
|
700 |
|
|
long i;
|
701 |
|
|
|
702 |
|
|
storage_needed = bfd_get_symtab_upper_bound (abfd);
|
703 |
|
|
|
704 |
|
|
if (storage_needed < 0)
|
705 |
|
|
FAIL
|
706 |
|
|
|
707 |
|
|
if (storage_needed == 0) {
|
708 |
|
|
return ;
|
709 |
|
|
}
|
710 |
|
|
symbol_table = (asymbol **) xmalloc (storage_needed);
|
711 |
|
|
...
|
712 |
|
|
number_of_symbols =
|
713 |
|
|
bfd_canonicalize_symtab (abfd, symbol_table);
|
714 |
|
|
|
715 |
|
|
if (number_of_symbols < 0)
|
716 |
|
|
FAIL
|
717 |
|
|
|
718 |
|
|
for (i = 0; i < number_of_symbols; i++) {
|
719 |
|
|
process_symbol (symbol_table[i]);
|
720 |
|
|
}
|
721 |
|
|
|
722 |
|
|
All storage for the symbols themselves is in an objalloc connected
|
723 |
|
|
to the BFD; it is freed when the BFD is closed.
|
724 |
|
|
|
725 |
|
|
|
726 |
|
|
File: bfd.info, Node: Writing Symbols, Next: Mini Symbols, Prev: Reading Symbols, Up: Symbols
|
727 |
|
|
|
728 |
|
|
Writing symbols
|
729 |
|
|
---------------
|
730 |
|
|
|
731 |
|
|
Writing of a symbol table is automatic when a BFD open for writing
|
732 |
|
|
is closed. The application attaches a vector of pointers to pointers to
|
733 |
|
|
symbols to the BFD being written, and fills in the symbol count. The
|
734 |
|
|
close and cleanup code reads through the table provided and performs
|
735 |
|
|
all the necessary operations. The BFD output code must always be
|
736 |
|
|
provided with an "owned" symbol: one which has come from another BFD,
|
737 |
|
|
or one which has been created using `bfd_make_empty_symbol'. Here is an
|
738 |
|
|
example showing the creation of a symbol table with only one element:
|
739 |
|
|
|
740 |
|
|
#include "bfd.h"
|
741 |
|
|
main()
|
742 |
|
|
{
|
743 |
|
|
bfd *abfd;
|
744 |
|
|
asymbol *ptrs[2];
|
745 |
|
|
asymbol *new;
|
746 |
|
|
|
747 |
|
|
abfd = bfd_openw("foo","a.out-sunos-big");
|
748 |
|
|
bfd_set_format(abfd, bfd_object);
|
749 |
|
|
new = bfd_make_empty_symbol(abfd);
|
750 |
|
|
new->name = "dummy_symbol";
|
751 |
|
|
new->section = bfd_make_section_old_way(abfd, ".text");
|
752 |
|
|
new->flags = BSF_GLOBAL;
|
753 |
|
|
new->value = 0x12345;
|
754 |
|
|
|
755 |
|
|
ptrs[0] = new;
|
756 |
|
|
ptrs[1] = (asymbol *)0;
|
757 |
|
|
|
758 |
|
|
bfd_set_symtab(abfd, ptrs, 1);
|
759 |
|
|
bfd_close(abfd);
|
760 |
|
|
}
|
761 |
|
|
|
762 |
|
|
./makesym
|
763 |
|
|
nm foo
|
764 |
|
|
00012345 A dummy_symbol
|
765 |
|
|
|
766 |
|
|
Many formats cannot represent arbitary symbol information; for
|
767 |
|
|
instance, the `a.out' object format does not allow an arbitary number
|
768 |
|
|
of sections. A symbol pointing to a section which is not one of
|
769 |
|
|
`.text', `.data' or `.bss' cannot be described.
|
770 |
|
|
|
771 |
|
|
|
772 |
|
|
File: bfd.info, Node: Mini Symbols, Next: typedef asymbol, Prev: Writing Symbols, Up: Symbols
|
773 |
|
|
|
774 |
|
|
Mini Symbols
|
775 |
|
|
------------
|
776 |
|
|
|
777 |
|
|
Mini symbols provide read-only access to the symbol table. They use
|
778 |
|
|
less memory space, but require more time to access. They can be useful
|
779 |
|
|
for tools like nm or objdump, which may have to handle symbol tables of
|
780 |
|
|
extremely large executables.
|
781 |
|
|
|
782 |
|
|
The `bfd_read_minisymbols' function will read the symbols into
|
783 |
|
|
memory in an internal form. It will return a `void *' pointer to a
|
784 |
|
|
block of memory, a symbol count, and the size of each symbol. The
|
785 |
|
|
pointer is allocated using `malloc', and should be freed by the caller
|
786 |
|
|
when it is no longer needed.
|
787 |
|
|
|
788 |
|
|
The function `bfd_minisymbol_to_symbol' will take a pointer to a
|
789 |
|
|
minisymbol, and a pointer to a structure returned by
|
790 |
|
|
`bfd_make_empty_symbol', and return a `asymbol' structure. The return
|
791 |
|
|
value may or may not be the same as the value from
|
792 |
|
|
`bfd_make_empty_symbol' which was passed in.
|
793 |
|
|
|
794 |
|
|
|
795 |
|
|
File: bfd.info, Node: typedef asymbol, Next: symbol handling functions, Prev: Mini Symbols, Up: Symbols
|
796 |
|
|
|
797 |
|
|
typedef asymbol
|
798 |
|
|
---------------
|
799 |
|
|
|
800 |
|
|
An `asymbol' has the form:
|
801 |
|
|
|
802 |
|
|
|
803 |
|
|
typedef struct symbol_cache_entry
|
804 |
|
|
{
|
805 |
|
|
/* A pointer to the BFD which owns the symbol. This information
|
806 |
|
|
is necessary so that a back end can work out what additional
|
807 |
|
|
information (invisible to the application writer) is carried
|
808 |
|
|
with the symbol.
|
809 |
|
|
|
810 |
|
|
This field is *almost* redundant, since you can use section->owner
|
811 |
|
|
instead, except that some symbols point to the global sections
|
812 |
|
|
bfd_{abs,com,und}_section. This could be fixed by making
|
813 |
|
|
these globals be per-bfd (or per-target-flavor). FIXME. */
|
814 |
|
|
struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */
|
815 |
|
|
|
816 |
|
|
/* The text of the symbol. The name is left alone, and not copied; the
|
817 |
|
|
application may not alter it. */
|
818 |
|
|
const char *name;
|
819 |
|
|
|
820 |
|
|
/* The value of the symbol. This really should be a union of a
|
821 |
|
|
numeric value with a pointer, since some flags indicate that
|
822 |
|
|
a pointer to another symbol is stored here. */
|
823 |
|
|
symvalue value;
|
824 |
|
|
|
825 |
|
|
/* Attributes of a symbol. */
|
826 |
|
|
#define BSF_NO_FLAGS 0x00
|
827 |
|
|
|
828 |
|
|
/* The symbol has local scope; `static' in `C'. The value
|
829 |
|
|
is the offset into the section of the data. */
|
830 |
|
|
#define BSF_LOCAL 0x01
|
831 |
|
|
|
832 |
|
|
/* The symbol has global scope; initialized data in `C'. The
|
833 |
|
|
value is the offset into the section of the data. */
|
834 |
|
|
#define BSF_GLOBAL 0x02
|
835 |
|
|
|
836 |
|
|
/* The symbol has global scope and is exported. The value is
|
837 |
|
|
the offset into the section of the data. */
|
838 |
|
|
#define BSF_EXPORT BSF_GLOBAL /* No real difference. */
|
839 |
|
|
|
840 |
|
|
/* A normal C symbol would be one of:
|
841 |
|
|
`BSF_LOCAL', `BSF_FORT_COMM', `BSF_UNDEFINED' or
|
842 |
|
|
`BSF_GLOBAL'. */
|
843 |
|
|
|
844 |
|
|
/* The symbol is a debugging record. The value has an arbitary
|
845 |
|
|
meaning, unless BSF_DEBUGGING_RELOC is also set. */
|
846 |
|
|
#define BSF_DEBUGGING 0x08
|
847 |
|
|
|
848 |
|
|
/* The symbol denotes a function entry point. Used in ELF,
|
849 |
|
|
perhaps others someday. */
|
850 |
|
|
#define BSF_FUNCTION 0x10
|
851 |
|
|
|
852 |
|
|
/* Used by the linker. */
|
853 |
|
|
#define BSF_KEEP 0x20
|
854 |
|
|
#define BSF_KEEP_G 0x40
|
855 |
|
|
|
856 |
|
|
/* A weak global symbol, overridable without warnings by
|
857 |
|
|
a regular global symbol of the same name. */
|
858 |
|
|
#define BSF_WEAK 0x80
|
859 |
|
|
|
860 |
|
|
/* This symbol was created to point to a section, e.g. ELF's
|
861 |
|
|
STT_SECTION symbols. */
|
862 |
|
|
#define BSF_SECTION_SYM 0x100
|
863 |
|
|
|
864 |
|
|
/* The symbol used to be a common symbol, but now it is
|
865 |
|
|
allocated. */
|
866 |
|
|
#define BSF_OLD_COMMON 0x200
|
867 |
|
|
|
868 |
|
|
/* The default value for common data. */
|
869 |
|
|
#define BFD_FORT_COMM_DEFAULT_VALUE 0
|
870 |
|
|
|
871 |
|
|
/* In some files the type of a symbol sometimes alters its
|
872 |
|
|
location in an output file - ie in coff a `ISFCN' symbol
|
873 |
|
|
which is also `C_EXT' symbol appears where it was
|
874 |
|
|
declared and not at the end of a section. This bit is set
|
875 |
|
|
by the target BFD part to convey this information. */
|
876 |
|
|
#define BSF_NOT_AT_END 0x400
|
877 |
|
|
|
878 |
|
|
/* Signal that the symbol is the label of constructor section. */
|
879 |
|
|
#define BSF_CONSTRUCTOR 0x800
|
880 |
|
|
|
881 |
|
|
/* Signal that the symbol is a warning symbol. The name is a
|
882 |
|
|
warning. The name of the next symbol is the one to warn about;
|
883 |
|
|
if a reference is made to a symbol with the same name as the next
|
884 |
|
|
symbol, a warning is issued by the linker. */
|
885 |
|
|
#define BSF_WARNING 0x1000
|
886 |
|
|
|
887 |
|
|
/* Signal that the symbol is indirect. This symbol is an indirect
|
888 |
|
|
pointer to the symbol with the same name as the next symbol. */
|
889 |
|
|
#define BSF_INDIRECT 0x2000
|
890 |
|
|
|
891 |
|
|
/* BSF_FILE marks symbols that contain a file name. This is used
|
892 |
|
|
for ELF STT_FILE symbols. */
|
893 |
|
|
#define BSF_FILE 0x4000
|
894 |
|
|
|
895 |
|
|
/* Symbol is from dynamic linking information. */
|
896 |
|
|
#define BSF_DYNAMIC 0x8000
|
897 |
|
|
|
898 |
|
|
/* The symbol denotes a data object. Used in ELF, and perhaps
|
899 |
|
|
others someday. */
|
900 |
|
|
#define BSF_OBJECT 0x10000
|
901 |
|
|
|
902 |
|
|
/* This symbol is a debugging symbol. The value is the offset
|
903 |
|
|
into the section of the data. BSF_DEBUGGING should be set
|
904 |
|
|
as well. */
|
905 |
|
|
#define BSF_DEBUGGING_RELOC 0x20000
|
906 |
|
|
|
907 |
|
|
/* This symbol is thread local. Used in ELF. */
|
908 |
|
|
#define BSF_THREAD_LOCAL 0x40000
|
909 |
|
|
|
910 |
|
|
flagword flags;
|
911 |
|
|
|
912 |
|
|
/* A pointer to the section to which this symbol is
|
913 |
|
|
relative. This will always be non NULL, there are special
|
914 |
|
|
sections for undefined and absolute symbols. */
|
915 |
|
|
struct sec *section;
|
916 |
|
|
|
917 |
|
|
/* Back end special data. */
|
918 |
|
|
union
|
919 |
|
|
{
|
920 |
|
|
PTR p;
|
921 |
|
|
bfd_vma i;
|
922 |
|
|
}
|
923 |
|
|
udata;
|
924 |
|
|
}
|
925 |
|
|
asymbol;
|
926 |
|
|
|
927 |
|
|
|
928 |
|
|
File: bfd.info, Node: symbol handling functions, Prev: typedef asymbol, Up: Symbols
|
929 |
|
|
|
930 |
|
|
Symbol handling functions
|
931 |
|
|
-------------------------
|
932 |
|
|
|
933 |
|
|
`bfd_get_symtab_upper_bound'
|
934 |
|
|
............................
|
935 |
|
|
|
936 |
|
|
*Description*
|
937 |
|
|
Return the number of bytes required to store a vector of pointers to
|
938 |
|
|
`asymbols' for all the symbols in the BFD ABFD, including a terminal
|
939 |
|
|
NULL pointer. If there are no symbols in the BFD, then return 0. If an
|
940 |
|
|
error occurs, return -1.
|
941 |
|
|
#define bfd_get_symtab_upper_bound(abfd) \
|
942 |
|
|
BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
|
943 |
|
|
|
944 |
|
|
`bfd_is_local_label'
|
945 |
|
|
....................
|
946 |
|
|
|
947 |
|
|
*Synopsis*
|
948 |
|
|
boolean bfd_is_local_label(bfd *abfd, asymbol *sym);
|
949 |
|
|
*Description*
|
950 |
|
|
Return true if the given symbol SYM in the BFD ABFD is a compiler
|
951 |
|
|
generated local label, else return false.
|
952 |
|
|
|
953 |
|
|
`bfd_is_local_label_name'
|
954 |
|
|
.........................
|
955 |
|
|
|
956 |
|
|
*Synopsis*
|
957 |
|
|
boolean bfd_is_local_label_name(bfd *abfd, const char *name);
|
958 |
|
|
*Description*
|
959 |
|
|
Return true if a symbol with the name NAME in the BFD ABFD is a
|
960 |
|
|
compiler generated local label, else return false. This just checks
|
961 |
|
|
whether the name has the form of a local label.
|
962 |
|
|
#define bfd_is_local_label_name(abfd, name) \
|
963 |
|
|
BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
|
964 |
|
|
|
965 |
|
|
`bfd_canonicalize_symtab'
|
966 |
|
|
.........................
|
967 |
|
|
|
968 |
|
|
*Description*
|
969 |
|
|
Read the symbols from the BFD ABFD, and fills in the vector LOCATION
|
970 |
|
|
with pointers to the symbols and a trailing NULL. Return the actual
|
971 |
|
|
number of symbol pointers, not including the NULL.
|
972 |
|
|
#define bfd_canonicalize_symtab(abfd, location) \
|
973 |
|
|
BFD_SEND (abfd, _bfd_canonicalize_symtab,\
|
974 |
|
|
(abfd, location))
|
975 |
|
|
|
976 |
|
|
`bfd_set_symtab'
|
977 |
|
|
................
|
978 |
|
|
|
979 |
|
|
*Synopsis*
|
980 |
|
|
boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
|
981 |
|
|
*Description*
|
982 |
|
|
Arrange that when the output BFD ABFD is closed, the table LOCATION of
|
983 |
|
|
COUNT pointers to symbols will be written.
|
984 |
|
|
|
985 |
|
|
`bfd_print_symbol_vandf'
|
986 |
|
|
........................
|
987 |
|
|
|
988 |
|
|
*Synopsis*
|
989 |
|
|
void bfd_print_symbol_vandf(bfd *abfd, PTR file, asymbol *symbol);
|
990 |
|
|
*Description*
|
991 |
|
|
Print the value and flags of the SYMBOL supplied to the stream FILE.
|
992 |
|
|
|
993 |
|
|
`bfd_make_empty_symbol'
|
994 |
|
|
.......................
|
995 |
|
|
|
996 |
|
|
*Description*
|
997 |
|
|
Create a new `asymbol' structure for the BFD ABFD and return a pointer
|
998 |
|
|
to it.
|
999 |
|
|
|
1000 |
|
|
This routine is necessary because each back end has private
|
1001 |
|
|
information surrounding the `asymbol'. Building your own `asymbol' and
|
1002 |
|
|
pointing to it will not create the private information, and will cause
|
1003 |
|
|
problems later on.
|
1004 |
|
|
#define bfd_make_empty_symbol(abfd) \
|
1005 |
|
|
BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
|
1006 |
|
|
|
1007 |
|
|
`_bfd_generic_make_empty_symbol'
|
1008 |
|
|
................................
|
1009 |
|
|
|
1010 |
|
|
*Synopsis*
|
1011 |
|
|
asymbol *_bfd_generic_make_empty_symbol (bfd *);
|
1012 |
|
|
*Description*
|
1013 |
|
|
Create a new `asymbol' structure for the BFD ABFD and return a pointer
|
1014 |
|
|
to it. Used by core file routines, binary back-end and anywhere else
|
1015 |
|
|
where no private info is needed.
|
1016 |
|
|
|
1017 |
|
|
`bfd_make_debug_symbol'
|
1018 |
|
|
.......................
|
1019 |
|
|
|
1020 |
|
|
*Description*
|
1021 |
|
|
Create a new `asymbol' structure for the BFD ABFD, to be used as a
|
1022 |
|
|
debugging symbol. Further details of its use have yet to be worked out.
|
1023 |
|
|
#define bfd_make_debug_symbol(abfd,ptr,size) \
|
1024 |
|
|
BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
|
1025 |
|
|
|
1026 |
|
|
`bfd_decode_symclass'
|
1027 |
|
|
.....................
|
1028 |
|
|
|
1029 |
|
|
*Description*
|
1030 |
|
|
Return a character corresponding to the symbol class of SYMBOL, or '?'
|
1031 |
|
|
for an unknown class.
|
1032 |
|
|
|
1033 |
|
|
*Synopsis*
|
1034 |
|
|
int bfd_decode_symclass(asymbol *symbol);
|
1035 |
|
|
|
1036 |
|
|
`bfd_is_undefined_symclass'
|
1037 |
|
|
...........................
|
1038 |
|
|
|
1039 |
|
|
*Description*
|
1040 |
|
|
Returns non-zero if the class symbol returned by bfd_decode_symclass
|
1041 |
|
|
represents an undefined symbol. Returns zero otherwise.
|
1042 |
|
|
|
1043 |
|
|
*Synopsis*
|
1044 |
|
|
boolean bfd_is_undefined_symclass (int symclass);
|
1045 |
|
|
|
1046 |
|
|
`bfd_symbol_info'
|
1047 |
|
|
.................
|
1048 |
|
|
|
1049 |
|
|
*Description*
|
1050 |
|
|
Fill in the basic info about symbol that nm needs. Additional info may
|
1051 |
|
|
be added by the back-ends after calling this function.
|
1052 |
|
|
|
1053 |
|
|
*Synopsis*
|
1054 |
|
|
void bfd_symbol_info(asymbol *symbol, symbol_info *ret);
|
1055 |
|
|
|
1056 |
|
|
`bfd_copy_private_symbol_data'
|
1057 |
|
|
..............................
|
1058 |
|
|
|
1059 |
|
|
*Synopsis*
|
1060 |
|
|
boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
|
1061 |
|
|
*Description*
|
1062 |
|
|
Copy private symbol information from ISYM in the BFD IBFD to the symbol
|
1063 |
|
|
OSYM in the BFD OBFD. Return `true' on success, `false' on error.
|
1064 |
|
|
Possible error returns are:
|
1065 |
|
|
|
1066 |
|
|
* `bfd_error_no_memory' - Not enough memory exists to create private
|
1067 |
|
|
data for OSEC.
|
1068 |
|
|
|
1069 |
|
|
#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
|
1070 |
|
|
BFD_SEND (obfd, _bfd_copy_private_symbol_data, \
|
1071 |
|
|
(ibfd, isymbol, obfd, osymbol))
|
1072 |
|
|
|
1073 |
|
|
|
1074 |
|
|
File: bfd.info, Node: Archives, Next: Formats, Prev: Symbols, Up: BFD front end
|
1075 |
|
|
|
1076 |
|
|
Archives
|
1077 |
|
|
========
|
1078 |
|
|
|
1079 |
|
|
*Description*
|
1080 |
|
|
An archive (or library) is just another BFD. It has a symbol table,
|
1081 |
|
|
although there's not much a user program will do with it.
|
1082 |
|
|
|
1083 |
|
|
The big difference between an archive BFD and an ordinary BFD is
|
1084 |
|
|
that the archive doesn't have sections. Instead it has a chain of BFDs
|
1085 |
|
|
that are considered its contents. These BFDs can be manipulated like
|
1086 |
|
|
any other. The BFDs contained in an archive opened for reading will
|
1087 |
|
|
all be opened for reading. You may put either input or output BFDs
|
1088 |
|
|
into an archive opened for output; they will be handled correctly when
|
1089 |
|
|
the archive is closed.
|
1090 |
|
|
|
1091 |
|
|
Use `bfd_openr_next_archived_file' to step through the contents of
|
1092 |
|
|
an archive opened for input. You don't have to read the entire archive
|
1093 |
|
|
if you don't want to! Read it until you find what you want.
|
1094 |
|
|
|
1095 |
|
|
Archive contents of output BFDs are chained through the `next'
|
1096 |
|
|
pointer in a BFD. The first one is findable through the `archive_head'
|
1097 |
|
|
slot of the archive. Set it with `bfd_set_archive_head' (q.v.). A
|
1098 |
|
|
given BFD may be in only one open output archive at a time.
|
1099 |
|
|
|
1100 |
|
|
As expected, the BFD archive code is more general than the archive
|
1101 |
|
|
code of any given environment. BFD archives may contain files of
|
1102 |
|
|
different formats (e.g., a.out and coff) and even different
|
1103 |
|
|
architectures. You may even place archives recursively into archives!
|
1104 |
|
|
|
1105 |
|
|
This can cause unexpected confusion, since some archive formats are
|
1106 |
|
|
more expressive than others. For instance, Intel COFF archives can
|
1107 |
|
|
preserve long filenames; SunOS a.out archives cannot. If you move a
|
1108 |
|
|
file from the first to the second format and back again, the filename
|
1109 |
|
|
may be truncated. Likewise, different a.out environments have different
|
1110 |
|
|
conventions as to how they truncate filenames, whether they preserve
|
1111 |
|
|
directory names in filenames, etc. When interoperating with native
|
1112 |
|
|
tools, be sure your files are homogeneous.
|
1113 |
|
|
|
1114 |
|
|
Beware: most of these formats do not react well to the presence of
|
1115 |
|
|
spaces in filenames. We do the best we can, but can't always handle
|
1116 |
|
|
this case due to restrictions in the format of archives. Many Unix
|
1117 |
|
|
utilities are braindead in regards to spaces and such in filenames
|
1118 |
|
|
anyway, so this shouldn't be much of a restriction.
|
1119 |
|
|
|
1120 |
|
|
Archives are supported in BFD in `archive.c'.
|
1121 |
|
|
|
1122 |
|
|
`bfd_get_next_mapent'
|
1123 |
|
|
.....................
|
1124 |
|
|
|
1125 |
|
|
*Synopsis*
|
1126 |
|
|
symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym);
|
1127 |
|
|
*Description*
|
1128 |
|
|
Step through archive ABFD's symbol table (if it has one). Successively
|
1129 |
|
|
update SYM with the next symbol's information, returning that symbol's
|
1130 |
|
|
(internal) index into the symbol table.
|
1131 |
|
|
|
1132 |
|
|
Supply `BFD_NO_MORE_SYMBOLS' as the PREVIOUS entry to get the first
|
1133 |
|
|
one; returns `BFD_NO_MORE_SYMBOLS' when you've already got the last one.
|
1134 |
|
|
|
1135 |
|
|
A `carsym' is a canonical archive symbol. The only user-visible
|
1136 |
|
|
element is its name, a null-terminated string.
|
1137 |
|
|
|
1138 |
|
|
`bfd_set_archive_head'
|
1139 |
|
|
......................
|
1140 |
|
|
|
1141 |
|
|
*Synopsis*
|
1142 |
|
|
boolean bfd_set_archive_head(bfd *output, bfd *new_head);
|
1143 |
|
|
*Description*
|
1144 |
|
|
Set the head of the chain of BFDs contained in the archive OUTPUT to
|
1145 |
|
|
NEW_HEAD.
|
1146 |
|
|
|
1147 |
|
|
`bfd_openr_next_archived_file'
|
1148 |
|
|
..............................
|
1149 |
|
|
|
1150 |
|
|
*Synopsis*
|
1151 |
|
|
bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous);
|
1152 |
|
|
*Description*
|
1153 |
|
|
Provided a BFD, ARCHIVE, containing an archive and NULL, open an input
|
1154 |
|
|
BFD on the first contained element and returns that. Subsequent calls
|
1155 |
|
|
should pass the archive and the previous return value to return a
|
1156 |
|
|
created BFD to the next contained element. NULL is returned when there
|
1157 |
|
|
are no more.
|
1158 |
|
|
|
1159 |
|
|
|
1160 |
|
|
File: bfd.info, Node: Formats, Next: Relocations, Prev: Archives, Up: BFD front end
|
1161 |
|
|
|
1162 |
|
|
File formats
|
1163 |
|
|
============
|
1164 |
|
|
|
1165 |
|
|
A format is a BFD concept of high level file contents type. The
|
1166 |
|
|
formats supported by BFD are:
|
1167 |
|
|
|
1168 |
|
|
* `bfd_object'
|
1169 |
|
|
The BFD may contain data, symbols, relocations and debug info.
|
1170 |
|
|
|
1171 |
|
|
* `bfd_archive'
|
1172 |
|
|
The BFD contains other BFDs and an optional index.
|
1173 |
|
|
|
1174 |
|
|
* `bfd_core'
|
1175 |
|
|
The BFD contains the result of an executable core dump.
|
1176 |
|
|
|
1177 |
|
|
`bfd_check_format'
|
1178 |
|
|
..................
|
1179 |
|
|
|
1180 |
|
|
*Synopsis*
|
1181 |
|
|
boolean bfd_check_format(bfd *abfd, bfd_format format);
|
1182 |
|
|
*Description*
|
1183 |
|
|
Verify if the file attached to the BFD ABFD is compatible with the
|
1184 |
|
|
format FORMAT (i.e., one of `bfd_object', `bfd_archive' or `bfd_core').
|
1185 |
|
|
|
1186 |
|
|
If the BFD has been set to a specific target before the call, only
|
1187 |
|
|
the named target and format combination is checked. If the target has
|
1188 |
|
|
not been set, or has been set to `default', then all the known target
|
1189 |
|
|
backends is interrogated to determine a match. If the default target
|
1190 |
|
|
matches, it is used. If not, exactly one target must recognize the
|
1191 |
|
|
file, or an error results.
|
1192 |
|
|
|
1193 |
|
|
The function returns `true' on success, otherwise `false' with one
|
1194 |
|
|
of the following error codes:
|
1195 |
|
|
|
1196 |
|
|
* `bfd_error_invalid_operation' - if `format' is not one of
|
1197 |
|
|
`bfd_object', `bfd_archive' or `bfd_core'.
|
1198 |
|
|
|
1199 |
|
|
* `bfd_error_system_call' - if an error occured during a read - even
|
1200 |
|
|
some file mismatches can cause bfd_error_system_calls.
|
1201 |
|
|
|
1202 |
|
|
* `file_not_recognised' - none of the backends recognised the file
|
1203 |
|
|
format.
|
1204 |
|
|
|
1205 |
|
|
* `bfd_error_file_ambiguously_recognized' - more than one backend
|
1206 |
|
|
recognised the file format.
|
1207 |
|
|
|
1208 |
|
|
`bfd_check_format_matches'
|
1209 |
|
|
..........................
|
1210 |
|
|
|
1211 |
|
|
*Synopsis*
|
1212 |
|
|
boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching);
|
1213 |
|
|
*Description*
|
1214 |
|
|
Like `bfd_check_format', except when it returns false with `bfd_errno'
|
1215 |
|
|
set to `bfd_error_file_ambiguously_recognized'. In that case, if
|
1216 |
|
|
MATCHING is not NULL, it will be filled in with a NULL-terminated list
|
1217 |
|
|
of the names of the formats that matched, allocated with `malloc'.
|
1218 |
|
|
Then the user may choose a format and try again.
|
1219 |
|
|
|
1220 |
|
|
When done with the list that MATCHING points to, the caller should
|
1221 |
|
|
free it.
|
1222 |
|
|
|
1223 |
|
|
`bfd_set_format'
|
1224 |
|
|
................
|
1225 |
|
|
|
1226 |
|
|
*Synopsis*
|
1227 |
|
|
boolean bfd_set_format(bfd *abfd, bfd_format format);
|
1228 |
|
|
*Description*
|
1229 |
|
|
This function sets the file format of the BFD ABFD to the format
|
1230 |
|
|
FORMAT. If the target set in the BFD does not support the format
|
1231 |
|
|
requested, the format is invalid, or the BFD is not open for writing,
|
1232 |
|
|
then an error occurs.
|
1233 |
|
|
|
1234 |
|
|
`bfd_format_string'
|
1235 |
|
|
...................
|
1236 |
|
|
|
1237 |
|
|
*Synopsis*
|
1238 |
|
|
const char *bfd_format_string(bfd_format format);
|
1239 |
|
|
*Description*
|
1240 |
|
|
Return a pointer to a const string `invalid', `object', `archive',
|
1241 |
|
|
`core', or `unknown', depending upon the value of FORMAT.
|
1242 |
|
|
|
1243 |
|
|
|
1244 |
|
|
File: bfd.info, Node: Relocations, Next: Core Files, Prev: Formats, Up: BFD front end
|
1245 |
|
|
|
1246 |
|
|
Relocations
|
1247 |
|
|
===========
|
1248 |
|
|
|
1249 |
|
|
BFD maintains relocations in much the same way it maintains symbols:
|
1250 |
|
|
they are left alone until required, then read in en-masse and
|
1251 |
|
|
translated into an internal form. A common routine
|
1252 |
|
|
`bfd_perform_relocation' acts upon the canonical form to do the fixup.
|
1253 |
|
|
|
1254 |
|
|
Relocations are maintained on a per section basis, while symbols are
|
1255 |
|
|
maintained on a per BFD basis.
|
1256 |
|
|
|
1257 |
|
|
All that a back end has to do to fit the BFD interface is to create
|
1258 |
|
|
a `struct reloc_cache_entry' for each relocation in a particular
|
1259 |
|
|
section, and fill in the right bits of the structures.
|
1260 |
|
|
|
1261 |
|
|
* Menu:
|
1262 |
|
|
|
1263 |
|
|
* typedef arelent::
|
1264 |
|
|
* howto manager::
|
1265 |
|
|
|