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/] [section.texi] - Blame information for rev 156

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
@section Sections
2
The raw data contained within a BFD is maintained through the
3
section abstraction.  A single BFD may have any number of
4
sections.  It keeps hold of them by pointing to the first;
5
each one points to the next in the list.
6
 
7
Sections are supported in BFD in @code{section.c}.
8
 
9
@menu
10
* Section Input::
11
* Section Output::
12
* typedef asection::
13
* section prototypes::
14
@end menu
15
 
16
@node Section Input, Section Output, Sections, Sections
17
@subsection Section input
18
When a BFD is opened for reading, the section structures are
19
created and attached to the BFD.
20
 
21
Each section has a name which describes the section in the
22
outside world---for example, @code{a.out} would contain at least
23
three sections, called @code{.text}, @code{.data} and @code{.bss}.
24
 
25
Names need not be unique; for example a COFF file may have several
26
sections named @code{.data}.
27
 
28
Sometimes a BFD will contain more than the ``natural'' number of
29
sections. A back end may attach other sections containing
30
constructor data, or an application may add a section (using
31
@code{bfd_make_section}) to the sections attached to an already open
32
BFD. For example, the linker creates an extra section
33
@code{COMMON} for each input file's BFD to hold information about
34
common storage.
35
 
36
The raw data is not necessarily read in when
37
the section descriptor is created. Some targets may leave the
38
data in place until a @code{bfd_get_section_contents} call is
39
made. Other back ends may read in all the data at once.  For
40
example, an S-record file has to be read once to determine the
41
size of the data. An IEEE-695 file doesn't contain raw data in
42
sections, but data and relocation expressions intermixed, so
43
the data area has to be parsed to get out the data and
44
relocations.
45
 
46
@node Section Output, typedef asection, Section Input, Sections
47
@subsection Section output
48
To write a new object style BFD, the various sections to be
49
written have to be created. They are attached to the BFD in
50
the same way as input sections; data is written to the
51
sections using @code{bfd_set_section_contents}.
52
 
53
Any program that creates or combines sections (e.g., the assembler
54
and linker) must use the @code{asection} fields @code{output_section} and
55
@code{output_offset} to indicate the file sections to which each
56
section must be written.  (If the section is being created from
57
scratch, @code{output_section} should probably point to the section
58
itself and @code{output_offset} should probably be zero.)
59
 
60
The data to be written comes from input sections attached
61
(via @code{output_section} pointers) to
62
the output sections.  The output section structure can be
63
considered a filter for the input section: the output section
64
determines the vma of the output data and the name, but the
65
input section determines the offset into the output section of
66
the data to be written.
67
 
68
E.g., to create a section "O", starting at 0x100, 0x123 long,
69
containing two subsections, "A" at offset 0x0 (i.e., at vma
70
0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the @code{asection}
71
structures would look like:
72
 
73
@example
74
   section name          "A"
75
     output_offset   0x00
76
     size            0x20
77
     output_section ----------->  section name    "O"
78
                             |    vma             0x100
79
   section name          "B" |    size            0x123
80
     output_offset   0x20    |
81
     size            0x103   |
82
     output_section  --------|
83
@end example
84
 
85
@subsection Link orders
86
The data within a section is stored in a @dfn{link_order}.
87
These are much like the fixups in @code{gas}.  The link_order
88
abstraction allows a section to grow and shrink within itself.
89
 
90
A link_order knows how big it is, and which is the next
91
link_order and where the raw data for it is; it also points to
92
a list of relocations which apply to it.
93
 
94
The link_order is used by the linker to perform relaxing on
95
final code.  The compiler creates code which is as big as
96
necessary to make it work without relaxing, and the user can
97
select whether to relax.  Sometimes relaxing takes a lot of
98
time.  The linker runs around the relocations to see if any
99
are attached to data which can be shrunk, if so it does it on
100
a link_order by link_order basis.
101
 
102
 
103
@node typedef asection, section prototypes, Section Output, Sections
104
@subsection typedef asection
105
Here is the section structure:
106
 
107
 
108
@example
109
 
110
typedef struct bfd_section
111
@{
112
  /* The name of the section; the name isn't a copy, the pointer is
113
     the same as that passed to bfd_make_section.  */
114
  const char *name;
115
 
116
  /* A unique sequence number.  */
117
  int id;
118
 
119
  /* Which section in the bfd; 0..n-1 as sections are created in a bfd.  */
120
  int index;
121
 
122
  /* The next section in the list belonging to the BFD, or NULL.  */
123
  struct bfd_section *next;
124
 
125
  /* The previous section in the list belonging to the BFD, or NULL.  */
126
  struct bfd_section *prev;
127
 
128
  /* The field flags contains attributes of the section. Some
129
     flags are read in from the object file, and some are
130
     synthesized from other information.  */
131
  flagword flags;
132
 
133
#define SEC_NO_FLAGS   0x000
134
 
135
  /* Tells the OS to allocate space for this section when loading.
136
     This is clear for a section containing debug information only.  */
137
#define SEC_ALLOC      0x001
138
 
139
  /* Tells the OS to load the section from the file when loading.
140
     This is clear for a .bss section.  */
141
#define SEC_LOAD       0x002
142
 
143
  /* The section contains data still to be relocated, so there is
144
     some relocation information too.  */
145
#define SEC_RELOC      0x004
146
 
147
  /* A signal to the OS that the section contains read only data.  */
148
#define SEC_READONLY   0x008
149
 
150
  /* The section contains code only.  */
151
#define SEC_CODE       0x010
152
 
153
  /* The section contains data only.  */
154
#define SEC_DATA       0x020
155
 
156
  /* The section will reside in ROM.  */
157
#define SEC_ROM        0x040
158
 
159
  /* The section contains constructor information. This section
160
     type is used by the linker to create lists of constructors and
161
     destructors used by @code{g++}. When a back end sees a symbol
162
     which should be used in a constructor list, it creates a new
163
     section for the type of name (e.g., @code{__CTOR_LIST__}), attaches
164
     the symbol to it, and builds a relocation. To build the lists
165
     of constructors, all the linker has to do is catenate all the
166
     sections called @code{__CTOR_LIST__} and relocate the data
167
     contained within - exactly the operations it would peform on
168
     standard data.  */
169
#define SEC_CONSTRUCTOR 0x080
170
 
171
  /* The section has contents - a data section could be
172
     @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}; a debug section could be
173
     @code{SEC_HAS_CONTENTS}  */
174
#define SEC_HAS_CONTENTS 0x100
175
 
176
  /* An instruction to the linker to not output the section
177
     even if it has information which would normally be written.  */
178
#define SEC_NEVER_LOAD 0x200
179
 
180
  /* The section contains thread local data.  */
181
#define SEC_THREAD_LOCAL 0x400
182
 
183
  /* The section has GOT references.  This flag is only for the
184
     linker, and is currently only used by the elf32-hppa back end.
185
     It will be set if global offset table references were detected
186
     in this section, which indicate to the linker that the section
187
     contains PIC code, and must be handled specially when doing a
188
     static link.  */
189
#define SEC_HAS_GOT_REF 0x800
190
 
191
  /* The section contains common symbols (symbols may be defined
192
     multiple times, the value of a symbol is the amount of
193
     space it requires, and the largest symbol value is the one
194
     used).  Most targets have exactly one of these (which we
195
     translate to bfd_com_section_ptr), but ECOFF has two.  */
196
#define SEC_IS_COMMON 0x1000
197
 
198
  /* The section contains only debugging information.  For
199
     example, this is set for ELF .debug and .stab sections.
200
     strip tests this flag to see if a section can be
201
     discarded.  */
202
#define SEC_DEBUGGING 0x2000
203
 
204
  /* The contents of this section are held in memory pointed to
205
     by the contents field.  This is checked by bfd_get_section_contents,
206
     and the data is retrieved from memory if appropriate.  */
207
#define SEC_IN_MEMORY 0x4000
208
 
209
  /* The contents of this section are to be excluded by the
210
     linker for executable and shared objects unless those
211
     objects are to be further relocated.  */
212
#define SEC_EXCLUDE 0x8000
213
 
214
  /* The contents of this section are to be sorted based on the sum of
215
     the symbol and addend values specified by the associated relocation
216
     entries.  Entries without associated relocation entries will be
217
     appended to the end of the section in an unspecified order.  */
218
#define SEC_SORT_ENTRIES 0x10000
219
 
220
  /* When linking, duplicate sections of the same name should be
221
     discarded, rather than being combined into a single section as
222
     is usually done.  This is similar to how common symbols are
223
     handled.  See SEC_LINK_DUPLICATES below.  */
224
#define SEC_LINK_ONCE 0x20000
225
 
226
  /* If SEC_LINK_ONCE is set, this bitfield describes how the linker
227
     should handle duplicate sections.  */
228
#define SEC_LINK_DUPLICATES 0xc0000
229
 
230
  /* This value for SEC_LINK_DUPLICATES means that duplicate
231
     sections with the same name should simply be discarded.  */
232
#define SEC_LINK_DUPLICATES_DISCARD 0x0
233
 
234
  /* This value for SEC_LINK_DUPLICATES means that the linker
235
     should warn if there are any duplicate sections, although
236
     it should still only link one copy.  */
237
#define SEC_LINK_DUPLICATES_ONE_ONLY 0x40000
238
 
239
  /* This value for SEC_LINK_DUPLICATES means that the linker
240
     should warn if any duplicate sections are a different size.  */
241
#define SEC_LINK_DUPLICATES_SAME_SIZE 0x80000
242
 
243
  /* This value for SEC_LINK_DUPLICATES means that the linker
244
     should warn if any duplicate sections contain different
245
     contents.  */
246
#define SEC_LINK_DUPLICATES_SAME_CONTENTS \
247
  (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE)
248
 
249
  /* This section was created by the linker as part of dynamic
250
     relocation or other arcane processing.  It is skipped when
251
     going through the first-pass output, trusting that someone
252
     else up the line will take care of it later.  */
253
#define SEC_LINKER_CREATED 0x100000
254
 
255
  /* This section should not be subject to garbage collection.
256
     Also set to inform the linker that this section should not be
257
     listed in the link map as discarded.  */
258
#define SEC_KEEP 0x200000
259
 
260
  /* This section contains "short" data, and should be placed
261
     "near" the GP.  */
262
#define SEC_SMALL_DATA 0x400000
263
 
264
  /* Attempt to merge identical entities in the section.
265
     Entity size is given in the entsize field.  */
266
#define SEC_MERGE 0x800000
267
 
268
  /* If given with SEC_MERGE, entities to merge are zero terminated
269
     strings where entsize specifies character size instead of fixed
270
     size entries.  */
271
#define SEC_STRINGS 0x1000000
272
 
273
  /* This section contains data about section groups.  */
274
#define SEC_GROUP 0x2000000
275
 
276
  /* The section is a COFF shared library section.  This flag is
277
     only for the linker.  If this type of section appears in
278
     the input file, the linker must copy it to the output file
279
     without changing the vma or size.  FIXME: Although this
280
     was originally intended to be general, it really is COFF
281
     specific (and the flag was renamed to indicate this).  It
282
     might be cleaner to have some more general mechanism to
283
     allow the back end to control what the linker does with
284
     sections.  */
285
#define SEC_COFF_SHARED_LIBRARY 0x4000000
286
 
287
  /* This section contains data which may be shared with other
288
     executables or shared objects. This is for COFF only.  */
289
#define SEC_COFF_SHARED 0x8000000
290
 
291
  /* When a section with this flag is being linked, then if the size of
292
     the input section is less than a page, it should not cross a page
293
     boundary.  If the size of the input section is one page or more,
294
     it should be aligned on a page boundary.  This is for TI
295
     TMS320C54X only.  */
296
#define SEC_TIC54X_BLOCK 0x10000000
297
 
298
  /* Conditionally link this section; do not link if there are no
299
     references found to any symbol in the section.  This is for TI
300
     TMS320C54X only.  */
301
#define SEC_TIC54X_CLINK 0x20000000
302
 
303
  /*  End of section flags.  */
304
 
305
  /* Some internal packed boolean fields.  */
306
 
307
  /* See the vma field.  */
308
  unsigned int user_set_vma : 1;
309
 
310
  /* A mark flag used by some of the linker backends.  */
311
  unsigned int linker_mark : 1;
312
 
313
  /* Another mark flag used by some of the linker backends.  Set for
314
     output sections that have an input section.  */
315
  unsigned int linker_has_input : 1;
316
 
317
  /* Mark flag used by some linker backends for garbage collection.  */
318
  unsigned int gc_mark : 1;
319
 
320
  /* The following flags are used by the ELF linker. */
321
 
322
  /* Mark sections which have been allocated to segments.  */
323
  unsigned int segment_mark : 1;
324
 
325
  /* Type of sec_info information.  */
326
  unsigned int sec_info_type:3;
327
#define ELF_INFO_TYPE_NONE      0
328
#define ELF_INFO_TYPE_STABS     1
329
#define ELF_INFO_TYPE_MERGE     2
330
#define ELF_INFO_TYPE_EH_FRAME  3
331
#define ELF_INFO_TYPE_JUST_SYMS 4
332
 
333
  /* Nonzero if this section uses RELA relocations, rather than REL.  */
334
  unsigned int use_rela_p:1;
335
 
336
  /* Bits used by various backends.  The generic code doesn't touch
337
     these fields.  */
338
 
339
  /* Nonzero if this section has TLS related relocations.  */
340
  unsigned int has_tls_reloc:1;
341
 
342
  /* Nonzero if this section has a gp reloc.  */
343
  unsigned int has_gp_reloc:1;
344
 
345
  /* Nonzero if this section needs the relax finalize pass.  */
346
  unsigned int need_finalize_relax:1;
347
 
348
  /* Whether relocations have been processed.  */
349
  unsigned int reloc_done : 1;
350
 
351
  /* End of internal packed boolean fields.  */
352
 
353
  /*  The virtual memory address of the section - where it will be
354
      at run time.  The symbols are relocated against this.  The
355
      user_set_vma flag is maintained by bfd; if it's not set, the
356
      backend can assign addresses (for example, in @code{a.out}, where
357
      the default address for @code{.data} is dependent on the specific
358
      target and various flags).  */
359
  bfd_vma vma;
360
 
361
  /*  The load address of the section - where it would be in a
362
      rom image; really only used for writing section header
363
      information.  */
364
  bfd_vma lma;
365
 
366
  /* The size of the section in octets, as it will be output.
367
     Contains a value even if the section has no contents (e.g., the
368
     size of @code{.bss}).  */
369
  bfd_size_type size;
370
 
371
  /* For input sections, the original size on disk of the section, in
372
     octets.  This field should be set for any section whose size is
373
     changed by linker relaxation.  It is required for sections where
374
     the linker relaxation scheme doesn't cache altered section and
375
     reloc contents (stabs, eh_frame, SEC_MERGE, some coff relaxing
376
     targets), and thus the original size needs to be kept to read the
377
     section multiple times.  For output sections, rawsize holds the
378
     section size calculated on a previous linker relaxation pass.  */
379
  bfd_size_type rawsize;
380
 
381
  /* If this section is going to be output, then this value is the
382
     offset in *bytes* into the output section of the first byte in the
383
     input section (byte ==> smallest addressable unit on the
384
     target).  In most cases, if this was going to start at the
385
     100th octet (8-bit quantity) in the output section, this value
386
     would be 100.  However, if the target byte size is 16 bits
387
     (bfd_octets_per_byte is "2"), this value would be 50.  */
388
  bfd_vma output_offset;
389
 
390
  /* The output section through which to map on output.  */
391
  struct bfd_section *output_section;
392
 
393
  /* The alignment requirement of the section, as an exponent of 2 -
394
     e.g., 3 aligns to 2^3 (or 8).  */
395
  unsigned int alignment_power;
396
 
397
  /* If an input section, a pointer to a vector of relocation
398
     records for the data in this section.  */
399
  struct reloc_cache_entry *relocation;
400
 
401
  /* If an output section, a pointer to a vector of pointers to
402
     relocation records for the data in this section.  */
403
  struct reloc_cache_entry **orelocation;
404
 
405
  /* The number of relocation records in one of the above.  */
406
  unsigned reloc_count;
407
 
408
  /* Information below is back end specific - and not always used
409
     or updated.  */
410
 
411
  /* File position of section data.  */
412
  file_ptr filepos;
413
 
414
  /* File position of relocation info.  */
415
  file_ptr rel_filepos;
416
 
417
  /* File position of line data.  */
418
  file_ptr line_filepos;
419
 
420
  /* Pointer to data for applications.  */
421
  void *userdata;
422
 
423
  /* If the SEC_IN_MEMORY flag is set, this points to the actual
424
     contents.  */
425
  unsigned char *contents;
426
 
427
  /* Attached line number information.  */
428
  alent *lineno;
429
 
430
  /* Number of line number records.  */
431
  unsigned int lineno_count;
432
 
433
  /* Entity size for merging purposes.  */
434
  unsigned int entsize;
435
 
436
  /* Points to the kept section if this section is a link-once section,
437
     and is discarded.  */
438
  struct bfd_section *kept_section;
439
 
440
  /* When a section is being output, this value changes as more
441
     linenumbers are written out.  */
442
  file_ptr moving_line_filepos;
443
 
444
  /* What the section number is in the target world.  */
445
  int target_index;
446
 
447
  void *used_by_bfd;
448
 
449
  /* If this is a constructor section then here is a list of the
450
     relocations created to relocate items within it.  */
451
  struct relent_chain *constructor_chain;
452
 
453
  /* The BFD which owns the section.  */
454
  bfd *owner;
455
 
456
  /* A symbol which points at this section only.  */
457
  struct bfd_symbol *symbol;
458
  struct bfd_symbol **symbol_ptr_ptr;
459
 
460
  /* Early in the link process, map_head and map_tail are used to build
461
     a list of input sections attached to an output section.  Later,
462
     output sections use these fields for a list of bfd_link_order
463
     structs.  */
464
  union @{
465
    struct bfd_link_order *link_order;
466
    struct bfd_section *s;
467
  @} map_head, map_tail;
468
@} asection;
469
 
470
/* These sections are global, and are managed by BFD.  The application
471
   and target back end are not permitted to change the values in
472
   these sections.  New code should use the section_ptr macros rather
473
   than referring directly to the const sections.  The const sections
474
   may eventually vanish.  */
475
#define BFD_ABS_SECTION_NAME "*ABS*"
476
#define BFD_UND_SECTION_NAME "*UND*"
477
#define BFD_COM_SECTION_NAME "*COM*"
478
#define BFD_IND_SECTION_NAME "*IND*"
479
 
480
/* The absolute section.  */
481
extern asection bfd_abs_section;
482
#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
483
#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
484
/* Pointer to the undefined section.  */
485
extern asection bfd_und_section;
486
#define bfd_und_section_ptr ((asection *) &bfd_und_section)
487
#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
488
/* Pointer to the common section.  */
489
extern asection bfd_com_section;
490
#define bfd_com_section_ptr ((asection *) &bfd_com_section)
491
/* Pointer to the indirect section.  */
492
extern asection bfd_ind_section;
493
#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
494
#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
495
 
496
#define bfd_is_const_section(SEC)              \
497
 (   ((SEC) == bfd_abs_section_ptr)            \
498
  || ((SEC) == bfd_und_section_ptr)            \
499
  || ((SEC) == bfd_com_section_ptr)            \
500
  || ((SEC) == bfd_ind_section_ptr))
501
 
502
/* Macros to handle insertion and deletion of a bfd's sections.  These
503
   only handle the list pointers, ie. do not adjust section_count,
504
   target_index etc.  */
505
#define bfd_section_list_remove(ABFD, S) \
506
  do                                                   \
507
    @{                                                  \
508
      asection *_s = S;                                \
509
      asection *_next = _s->next;                      \
510
      asection *_prev = _s->prev;                      \
511
      if (_prev)                                       \
512
        _prev->next = _next;                           \
513
      else                                             \
514
        (ABFD)->sections = _next;                      \
515
      if (_next)                                       \
516
        _next->prev = _prev;                           \
517
      else                                             \
518
        (ABFD)->section_last = _prev;                  \
519
    @}                                                  \
520
  while (0)
521
#define bfd_section_list_append(ABFD, S) \
522
  do                                                   \
523
    @{                                                  \
524
      asection *_s = S;                                \
525
      bfd *_abfd = ABFD;                               \
526
      _s->next = NULL;                                 \
527
      if (_abfd->section_last)                         \
528
        @{                                              \
529
          _s->prev = _abfd->section_last;              \
530
          _abfd->section_last->next = _s;              \
531
        @}                                              \
532
      else                                             \
533
        @{                                              \
534
          _s->prev = NULL;                             \
535
          _abfd->sections = _s;                        \
536
        @}                                              \
537
      _abfd->section_last = _s;                        \
538
    @}                                                  \
539
  while (0)
540
#define bfd_section_list_prepend(ABFD, S) \
541
  do                                                   \
542
    @{                                                  \
543
      asection *_s = S;                                \
544
      bfd *_abfd = ABFD;                               \
545
      _s->prev = NULL;                                 \
546
      if (_abfd->sections)                             \
547
        @{                                              \
548
          _s->next = _abfd->sections;                  \
549
          _abfd->sections->prev = _s;                  \
550
        @}                                              \
551
      else                                             \
552
        @{                                              \
553
          _s->next = NULL;                             \
554
          _abfd->section_last = _s;                    \
555
        @}                                              \
556
      _abfd->sections = _s;                            \
557
    @}                                                  \
558
  while (0)
559
#define bfd_section_list_insert_after(ABFD, A, S) \
560
  do                                                   \
561
    @{                                                  \
562
      asection *_a = A;                                \
563
      asection *_s = S;                                \
564
      asection *_next = _a->next;                      \
565
      _s->next = _next;                                \
566
      _s->prev = _a;                                   \
567
      _a->next = _s;                                   \
568
      if (_next)                                       \
569
        _next->prev = _s;                              \
570
      else                                             \
571
        (ABFD)->section_last = _s;                     \
572
    @}                                                  \
573
  while (0)
574
#define bfd_section_list_insert_before(ABFD, B, S) \
575
  do                                                   \
576
    @{                                                  \
577
      asection *_b = B;                                \
578
      asection *_s = S;                                \
579
      asection *_prev = _b->prev;                      \
580
      _s->prev = _prev;                                \
581
      _s->next = _b;                                   \
582
      _b->prev = _s;                                   \
583
      if (_prev)                                       \
584
        _prev->next = _s;                              \
585
      else                                             \
586
        (ABFD)->sections = _s;                         \
587
    @}                                                  \
588
  while (0)
589
#define bfd_section_removed_from_list(ABFD, S) \
590
  ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S))
591
 
592
#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX)                   \
593
  /* name, id,  index, next, prev, flags, user_set_vma,            */  \
594
  @{ NAME,  IDX, 0,     NULL, NULL, FLAGS, 0,                           \
595
                                                                       \
596
  /* linker_mark, linker_has_input, gc_mark,                       */  \
597
     0,           0,                1,                                 \
598
                                                                       \
599
  /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc,       */  \
600
     0,            0,             0,          0,                       \
601
                                                                       \
602
  /* has_gp_reloc, need_finalize_relax, reloc_done,                */  \
603
     0,            0,                   0,                             \
604
                                                                       \
605
  /* vma, lma, size, rawsize                                       */  \
606
     0,   0,   0,    0,                                                \
607
                                                                       \
608
  /* output_offset, output_section,              alignment_power,  */  \
609
     0,             (struct bfd_section *) &SEC, 0,                    \
610
                                                                       \
611
  /* relocation, orelocation, reloc_count, filepos, rel_filepos,   */  \
612
     NULL,       NULL,        0,           0,       0,                 \
613
                                                                       \
614
  /* line_filepos, userdata, contents, lineno, lineno_count,       */  \
615
     0,            NULL,     NULL,     NULL,   0,                      \
616
                                                                       \
617
  /* entsize, kept_section, moving_line_filepos,                    */ \
618
     0,       NULL,          0,                                        \
619
                                                                       \
620
  /* target_index, used_by_bfd, constructor_chain, owner,          */  \
621
     0,            NULL,        NULL,              NULL,               \
622
                                                                       \
623
  /* symbol,                    symbol_ptr_ptr,                    */  \
624
     (struct bfd_symbol *) SYM, &SEC.symbol,                           \
625
                                                                       \
626
  /* map_head, map_tail                                            */  \
627
     @{ NULL @}, @{ NULL @}                                                \
628
    @}
629
 
630
@end example
631
 
632
@node section prototypes,  , typedef asection, Sections
633
@subsection Section prototypes
634
These are the functions exported by the section handling part of BFD.
635
 
636
@findex bfd_section_list_clear
637
@subsubsection @code{bfd_section_list_clear}
638
@strong{Synopsis}
639
@example
640
void bfd_section_list_clear (bfd *);
641
@end example
642
@strong{Description}@*
643
Clears the section list, and also resets the section count and
644
hash table entries.
645
 
646
@findex bfd_get_section_by_name
647
@subsubsection @code{bfd_get_section_by_name}
648
@strong{Synopsis}
649
@example
650
asection *bfd_get_section_by_name (bfd *abfd, const char *name);
651
@end example
652
@strong{Description}@*
653
Run through @var{abfd} and return the one of the
654
@code{asection}s whose name matches @var{name}, otherwise @code{NULL}.
655
@xref{Sections}, for more information.
656
 
657
This should only be used in special cases; the normal way to process
658
all sections of a given name is to use @code{bfd_map_over_sections} and
659
@code{strcmp} on the name (or better yet, base it on the section flags
660
or something else) for each section.
661
 
662
@findex bfd_get_section_by_name_if
663
@subsubsection @code{bfd_get_section_by_name_if}
664
@strong{Synopsis}
665
@example
666
asection *bfd_get_section_by_name_if
667
   (bfd *abfd,
668
    const char *name,
669
    bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj),
670
    void *obj);
671
@end example
672
@strong{Description}@*
673
Call the provided function @var{func} for each section
674
attached to the BFD @var{abfd} whose name matches @var{name},
675
passing @var{obj} as an argument. The function will be called
676
as if by
677
 
678
@example
679
       func (abfd, the_section, obj);
680
@end example
681
 
682
It returns the first section for which @var{func} returns true,
683
otherwise @code{NULL}.
684
 
685
@findex bfd_get_unique_section_name
686
@subsubsection @code{bfd_get_unique_section_name}
687
@strong{Synopsis}
688
@example
689
char *bfd_get_unique_section_name
690
   (bfd *abfd, const char *templat, int *count);
691
@end example
692
@strong{Description}@*
693
Invent a section name that is unique in @var{abfd} by tacking
694
a dot and a digit suffix onto the original @var{templat}.  If
695
@var{count} is non-NULL, then it specifies the first number
696
tried as a suffix to generate a unique name.  The value
697
pointed to by @var{count} will be incremented in this case.
698
 
699
@findex bfd_make_section_old_way
700
@subsubsection @code{bfd_make_section_old_way}
701
@strong{Synopsis}
702
@example
703
asection *bfd_make_section_old_way (bfd *abfd, const char *name);
704
@end example
705
@strong{Description}@*
706
Create a new empty section called @var{name}
707
and attach it to the end of the chain of sections for the
708
BFD @var{abfd}. An attempt to create a section with a name which
709
is already in use returns its pointer without changing the
710
section chain.
711
 
712
It has the funny name since this is the way it used to be
713
before it was rewritten....
714
 
715
Possible errors are:
716
@itemize @bullet
717
 
718
@item
719
@code{bfd_error_invalid_operation} -
720
If output has already started for this BFD.
721
@item
722
@code{bfd_error_no_memory} -
723
If memory allocation fails.
724
@end itemize
725
 
726
@findex bfd_make_section_anyway_with_flags
727
@subsubsection @code{bfd_make_section_anyway_with_flags}
728
@strong{Synopsis}
729
@example
730
asection *bfd_make_section_anyway_with_flags
731
   (bfd *abfd, const char *name, flagword flags);
732
@end example
733
@strong{Description}@*
734
Create a new empty section called @var{name} and attach it to the end of
735
the chain of sections for @var{abfd}.  Create a new section even if there
736
is already a section with that name.  Also set the attributes of the
737
new section to the value @var{flags}.
738
 
739
Return @code{NULL} and set @code{bfd_error} on error; possible errors are:
740
@itemize @bullet
741
 
742
@item
743
@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}.
744
@item
745
@code{bfd_error_no_memory} - If memory allocation fails.
746
@end itemize
747
 
748
@findex bfd_make_section_anyway
749
@subsubsection @code{bfd_make_section_anyway}
750
@strong{Synopsis}
751
@example
752
asection *bfd_make_section_anyway (bfd *abfd, const char *name);
753
@end example
754
@strong{Description}@*
755
Create a new empty section called @var{name} and attach it to the end of
756
the chain of sections for @var{abfd}.  Create a new section even if there
757
is already a section with that name.
758
 
759
Return @code{NULL} and set @code{bfd_error} on error; possible errors are:
760
@itemize @bullet
761
 
762
@item
763
@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}.
764
@item
765
@code{bfd_error_no_memory} - If memory allocation fails.
766
@end itemize
767
 
768
@findex bfd_make_section_with_flags
769
@subsubsection @code{bfd_make_section_with_flags}
770
@strong{Synopsis}
771
@example
772
asection *bfd_make_section_with_flags
773
   (bfd *, const char *name, flagword flags);
774
@end example
775
@strong{Description}@*
776
Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling
777
bfd_set_error ()) without changing the section chain if there is already a
778
section named @var{name}.  Also set the attributes of the new section to
779
the value @var{flags}.  If there is an error, return @code{NULL} and set
780
@code{bfd_error}.
781
 
782
@findex bfd_make_section
783
@subsubsection @code{bfd_make_section}
784
@strong{Synopsis}
785
@example
786
asection *bfd_make_section (bfd *, const char *name);
787
@end example
788
@strong{Description}@*
789
Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling
790
bfd_set_error ()) without changing the section chain if there is already a
791
section named @var{name}.  If there is an error, return @code{NULL} and set
792
@code{bfd_error}.
793
 
794
@findex bfd_set_section_flags
795
@subsubsection @code{bfd_set_section_flags}
796
@strong{Synopsis}
797
@example
798
bfd_boolean bfd_set_section_flags
799
   (bfd *abfd, asection *sec, flagword flags);
800
@end example
801
@strong{Description}@*
802
Set the attributes of the section @var{sec} in the BFD
803
@var{abfd} to the value @var{flags}. Return @code{TRUE} on success,
804
@code{FALSE} on error. Possible error returns are:
805
 
806
@itemize @bullet
807
 
808
@item
809
@code{bfd_error_invalid_operation} -
810
The section cannot have one or more of the attributes
811
requested. For example, a .bss section in @code{a.out} may not
812
have the @code{SEC_HAS_CONTENTS} field set.
813
@end itemize
814
 
815
@findex bfd_map_over_sections
816
@subsubsection @code{bfd_map_over_sections}
817
@strong{Synopsis}
818
@example
819
void bfd_map_over_sections
820
   (bfd *abfd,
821
    void (*func) (bfd *abfd, asection *sect, void *obj),
822
    void *obj);
823
@end example
824
@strong{Description}@*
825
Call the provided function @var{func} for each section
826
attached to the BFD @var{abfd}, passing @var{obj} as an
827
argument. The function will be called as if by
828
 
829
@example
830
       func (abfd, the_section, obj);
831
@end example
832
 
833
This is the preferred method for iterating over sections; an
834
alternative would be to use a loop:
835
 
836
@example
837
          section *p;
838
          for (p = abfd->sections; p != NULL; p = p->next)
839
             func (abfd, p, ...)
840
@end example
841
 
842
@findex bfd_sections_find_if
843
@subsubsection @code{bfd_sections_find_if}
844
@strong{Synopsis}
845
@example
846
asection *bfd_sections_find_if
847
   (bfd *abfd,
848
    bfd_boolean (*operation) (bfd *abfd, asection *sect, void *obj),
849
    void *obj);
850
@end example
851
@strong{Description}@*
852
Call the provided function @var{operation} for each section
853
attached to the BFD @var{abfd}, passing @var{obj} as an
854
argument. The function will be called as if by
855
 
856
@example
857
       operation (abfd, the_section, obj);
858
@end example
859
 
860
It returns the first section for which @var{operation} returns true.
861
 
862
@findex bfd_set_section_size
863
@subsubsection @code{bfd_set_section_size}
864
@strong{Synopsis}
865
@example
866
bfd_boolean bfd_set_section_size
867
   (bfd *abfd, asection *sec, bfd_size_type val);
868
@end example
869
@strong{Description}@*
870
Set @var{sec} to the size @var{val}. If the operation is
871
ok, then @code{TRUE} is returned, else @code{FALSE}.
872
 
873
Possible error returns:
874
@itemize @bullet
875
 
876
@item
877
@code{bfd_error_invalid_operation} -
878
Writing has started to the BFD, so setting the size is invalid.
879
@end itemize
880
 
881
@findex bfd_set_section_contents
882
@subsubsection @code{bfd_set_section_contents}
883
@strong{Synopsis}
884
@example
885
bfd_boolean bfd_set_section_contents
886
   (bfd *abfd, asection *section, const void *data,
887
    file_ptr offset, bfd_size_type count);
888
@end example
889
@strong{Description}@*
890
Sets the contents of the section @var{section} in BFD
891
@var{abfd} to the data starting in memory at @var{data}. The
892
data is written to the output section starting at offset
893
@var{offset} for @var{count} octets.
894
 
895
Normally @code{TRUE} is returned, else @code{FALSE}. Possible error
896
returns are:
897
@itemize @bullet
898
 
899
@item
900
@code{bfd_error_no_contents} -
901
The output section does not have the @code{SEC_HAS_CONTENTS}
902
attribute, so nothing can be written to it.
903
@item
904
and some more too
905
@end itemize
906
This routine is front end to the back end function
907
@code{_bfd_set_section_contents}.
908
 
909
@findex bfd_get_section_contents
910
@subsubsection @code{bfd_get_section_contents}
911
@strong{Synopsis}
912
@example
913
bfd_boolean bfd_get_section_contents
914
   (bfd *abfd, asection *section, void *location, file_ptr offset,
915
    bfd_size_type count);
916
@end example
917
@strong{Description}@*
918
Read data from @var{section} in BFD @var{abfd}
919
into memory starting at @var{location}. The data is read at an
920
offset of @var{offset} from the start of the input section,
921
and is read for @var{count} bytes.
922
 
923
If the contents of a constructor with the @code{SEC_CONSTRUCTOR}
924
flag set are requested or if the section does not have the
925
@code{SEC_HAS_CONTENTS} flag set, then the @var{location} is filled
926
with zeroes. If no errors occur, @code{TRUE} is returned, else
927
@code{FALSE}.
928
 
929
@findex bfd_malloc_and_get_section
930
@subsubsection @code{bfd_malloc_and_get_section}
931
@strong{Synopsis}
932
@example
933
bfd_boolean bfd_malloc_and_get_section
934
   (bfd *abfd, asection *section, bfd_byte **buf);
935
@end example
936
@strong{Description}@*
937
Read all data from @var{section} in BFD @var{abfd}
938
into a buffer, *@var{buf}, malloc'd by this function.
939
 
940
@findex bfd_copy_private_section_data
941
@subsubsection @code{bfd_copy_private_section_data}
942
@strong{Synopsis}
943
@example
944
bfd_boolean bfd_copy_private_section_data
945
   (bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
946
@end example
947
@strong{Description}@*
948
Copy private section information from @var{isec} in the BFD
949
@var{ibfd} to the section @var{osec} in the BFD @var{obfd}.
950
Return @code{TRUE} on success, @code{FALSE} on error.  Possible error
951
returns are:
952
 
953
@itemize @bullet
954
 
955
@item
956
@code{bfd_error_no_memory} -
957
Not enough memory exists to create private data for @var{osec}.
958
@end itemize
959
@example
960
#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
961
     BFD_SEND (obfd, _bfd_copy_private_section_data, \
962
               (ibfd, isection, obfd, osection))
963
@end example
964
 
965
@findex bfd_generic_is_group_section
966
@subsubsection @code{bfd_generic_is_group_section}
967
@strong{Synopsis}
968
@example
969
bfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec);
970
@end example
971
@strong{Description}@*
972
Returns TRUE if @var{sec} is a member of a group.
973
 
974
@findex bfd_generic_discard_group
975
@subsubsection @code{bfd_generic_discard_group}
976
@strong{Synopsis}
977
@example
978
bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group);
979
@end example
980
@strong{Description}@*
981
Remove all members of @var{group} from the output.
982
 

powered by: WebSVN 2.1.0

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