OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [bfd/] [doc/] [section.texi] - Blame information for rev 357

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

Line No. Rev Author Line
1 330 jeremybenn
@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
  /* Indicate that section has the no read flag set. This happens
304
     when memory read flag isn't set. */
305
#define SEC_COFF_NOREAD 0x40000000
306
 
307
  /*  End of section flags.  */
308
 
309
  /* Some internal packed boolean fields.  */
310
 
311
  /* See the vma field.  */
312
  unsigned int user_set_vma : 1;
313
 
314
  /* A mark flag used by some of the linker backends.  */
315
  unsigned int linker_mark : 1;
316
 
317
  /* Another mark flag used by some of the linker backends.  Set for
318
     output sections that have an input section.  */
319
  unsigned int linker_has_input : 1;
320
 
321
  /* Mark flag used by some linker backends for garbage collection.  */
322
  unsigned int gc_mark : 1;
323
 
324
  /* The following flags are used by the ELF linker. */
325
 
326
  /* Mark sections which have been allocated to segments.  */
327
  unsigned int segment_mark : 1;
328
 
329
  /* Type of sec_info information.  */
330
  unsigned int sec_info_type:3;
331
#define ELF_INFO_TYPE_NONE      0
332
#define ELF_INFO_TYPE_STABS     1
333
#define ELF_INFO_TYPE_MERGE     2
334
#define ELF_INFO_TYPE_EH_FRAME  3
335
#define ELF_INFO_TYPE_JUST_SYMS 4
336
 
337
  /* Nonzero if this section uses RELA relocations, rather than REL.  */
338
  unsigned int use_rela_p:1;
339
 
340
  /* Bits used by various backends.  The generic code doesn't touch
341
     these fields.  */
342
 
343
  unsigned int sec_flg0:1;
344
  unsigned int sec_flg1:1;
345
  unsigned int sec_flg2:1;
346
  unsigned int sec_flg3:1;
347
  unsigned int sec_flg4:1;
348
  unsigned int sec_flg5:1;
349
 
350
  /* End of internal packed boolean fields.  */
351
 
352
  /*  The virtual memory address of the section - where it will be
353
      at run time.  The symbols are relocated against this.  The
354
      user_set_vma flag is maintained by bfd; if it's not set, the
355
      backend can assign addresses (for example, in @code{a.out}, where
356
      the default address for @code{.data} is dependent on the specific
357
      target and various flags).  */
358
  bfd_vma vma;
359
 
360
  /*  The load address of the section - where it would be in a
361
      rom image; really only used for writing section header
362
      information.  */
363
  bfd_vma lma;
364
 
365
  /* The size of the section in octets, as it will be output.
366
     Contains a value even if the section has no contents (e.g., the
367
     size of @code{.bss}).  */
368
  bfd_size_type size;
369
 
370
  /* For input sections, the original size on disk of the section, in
371
     octets.  This field should be set for any section whose size is
372
     changed by linker relaxation.  It is required for sections where
373
     the linker relaxation scheme doesn't cache altered section and
374
     reloc contents (stabs, eh_frame, SEC_MERGE, some coff relaxing
375
     targets), and thus the original size needs to be kept to read the
376
     section multiple times.  For output sections, rawsize holds the
377
     section size calculated on a previous linker relaxation pass.  */
378
  bfd_size_type rawsize;
379
 
380
  /* Relaxation table. */
381
  struct relax_table *relax;
382
 
383
  /* Count of used relaxation table entries. */
384
  int relax_count;
385
 
386
 
387
  /* If this section is going to be output, then this value is the
388
     offset in *bytes* into the output section of the first byte in the
389
     input section (byte ==> smallest addressable unit on the
390
     target).  In most cases, if this was going to start at the
391
     100th octet (8-bit quantity) in the output section, this value
392
     would be 100.  However, if the target byte size is 16 bits
393
     (bfd_octets_per_byte is "2"), this value would be 50.  */
394
  bfd_vma output_offset;
395
 
396
  /* The output section through which to map on output.  */
397
  struct bfd_section *output_section;
398
 
399
  /* The alignment requirement of the section, as an exponent of 2 -
400
     e.g., 3 aligns to 2^3 (or 8).  */
401
  unsigned int alignment_power;
402
 
403
  /* If an input section, a pointer to a vector of relocation
404
     records for the data in this section.  */
405
  struct reloc_cache_entry *relocation;
406
 
407
  /* If an output section, a pointer to a vector of pointers to
408
     relocation records for the data in this section.  */
409
  struct reloc_cache_entry **orelocation;
410
 
411
  /* The number of relocation records in one of the above.  */
412
  unsigned reloc_count;
413
 
414
  /* Information below is back end specific - and not always used
415
     or updated.  */
416
 
417
  /* File position of section data.  */
418
  file_ptr filepos;
419
 
420
  /* File position of relocation info.  */
421
  file_ptr rel_filepos;
422
 
423
  /* File position of line data.  */
424
  file_ptr line_filepos;
425
 
426
  /* Pointer to data for applications.  */
427
  void *userdata;
428
 
429
  /* If the SEC_IN_MEMORY flag is set, this points to the actual
430
     contents.  */
431
  unsigned char *contents;
432
 
433
  /* Attached line number information.  */
434
  alent *lineno;
435
 
436
  /* Number of line number records.  */
437
  unsigned int lineno_count;
438
 
439
  /* Entity size for merging purposes.  */
440
  unsigned int entsize;
441
 
442
  /* Points to the kept section if this section is a link-once section,
443
     and is discarded.  */
444
  struct bfd_section *kept_section;
445
 
446
  /* When a section is being output, this value changes as more
447
     linenumbers are written out.  */
448
  file_ptr moving_line_filepos;
449
 
450
  /* What the section number is in the target world.  */
451
  int target_index;
452
 
453
  void *used_by_bfd;
454
 
455
  /* If this is a constructor section then here is a list of the
456
     relocations created to relocate items within it.  */
457
  struct relent_chain *constructor_chain;
458
 
459
  /* The BFD which owns the section.  */
460
  bfd *owner;
461
 
462
  /* A symbol which points at this section only.  */
463
  struct bfd_symbol *symbol;
464
  struct bfd_symbol **symbol_ptr_ptr;
465
 
466
  /* Early in the link process, map_head and map_tail are used to build
467
     a list of input sections attached to an output section.  Later,
468
     output sections use these fields for a list of bfd_link_order
469
     structs.  */
470
  union @{
471
    struct bfd_link_order *link_order;
472
    struct bfd_section *s;
473
  @} map_head, map_tail;
474
@} asection;
475
 
476
/* Relax table contains information about instructions which can
477
   be removed by relaxation -- replacing a long address with a
478
   short address.  */
479
struct relax_table @{
480
  /* Address where bytes may be deleted. */
481
  bfd_vma addr;
482
 
483
  /* Number of bytes to be deleted.  */
484
  int size;
485
@};
486
 
487
/* These sections are global, and are managed by BFD.  The application
488
   and target back end are not permitted to change the values in
489
   these sections.  New code should use the section_ptr macros rather
490
   than referring directly to the const sections.  The const sections
491
   may eventually vanish.  */
492
#define BFD_ABS_SECTION_NAME "*ABS*"
493
#define BFD_UND_SECTION_NAME "*UND*"
494
#define BFD_COM_SECTION_NAME "*COM*"
495
#define BFD_IND_SECTION_NAME "*IND*"
496
 
497
/* The absolute section.  */
498
extern asection bfd_abs_section;
499
#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
500
#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
501
/* Pointer to the undefined section.  */
502
extern asection bfd_und_section;
503
#define bfd_und_section_ptr ((asection *) &bfd_und_section)
504
#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
505
/* Pointer to the common section.  */
506
extern asection bfd_com_section;
507
#define bfd_com_section_ptr ((asection *) &bfd_com_section)
508
/* Pointer to the indirect section.  */
509
extern asection bfd_ind_section;
510
#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
511
#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
512
 
513
#define bfd_is_const_section(SEC)              \
514
 (   ((SEC) == bfd_abs_section_ptr)            \
515
  || ((SEC) == bfd_und_section_ptr)            \
516
  || ((SEC) == bfd_com_section_ptr)            \
517
  || ((SEC) == bfd_ind_section_ptr))
518
 
519
/* Macros to handle insertion and deletion of a bfd's sections.  These
520
   only handle the list pointers, ie. do not adjust section_count,
521
   target_index etc.  */
522
#define bfd_section_list_remove(ABFD, S) \
523
  do                                                   \
524
    @{                                                  \
525
      asection *_s = S;                                \
526
      asection *_next = _s->next;                      \
527
      asection *_prev = _s->prev;                      \
528
      if (_prev)                                       \
529
        _prev->next = _next;                           \
530
      else                                             \
531
        (ABFD)->sections = _next;                      \
532
      if (_next)                                       \
533
        _next->prev = _prev;                           \
534
      else                                             \
535
        (ABFD)->section_last = _prev;                  \
536
    @}                                                  \
537
  while (0)
538
#define bfd_section_list_append(ABFD, S) \
539
  do                                                   \
540
    @{                                                  \
541
      asection *_s = S;                                \
542
      bfd *_abfd = ABFD;                               \
543
      _s->next = NULL;                                 \
544
      if (_abfd->section_last)                         \
545
        @{                                              \
546
          _s->prev = _abfd->section_last;              \
547
          _abfd->section_last->next = _s;              \
548
        @}                                              \
549
      else                                             \
550
        @{                                              \
551
          _s->prev = NULL;                             \
552
          _abfd->sections = _s;                        \
553
        @}                                              \
554
      _abfd->section_last = _s;                        \
555
    @}                                                  \
556
  while (0)
557
#define bfd_section_list_prepend(ABFD, S) \
558
  do                                                   \
559
    @{                                                  \
560
      asection *_s = S;                                \
561
      bfd *_abfd = ABFD;                               \
562
      _s->prev = NULL;                                 \
563
      if (_abfd->sections)                             \
564
        @{                                              \
565
          _s->next = _abfd->sections;                  \
566
          _abfd->sections->prev = _s;                  \
567
        @}                                              \
568
      else                                             \
569
        @{                                              \
570
          _s->next = NULL;                             \
571
          _abfd->section_last = _s;                    \
572
        @}                                              \
573
      _abfd->sections = _s;                            \
574
    @}                                                  \
575
  while (0)
576
#define bfd_section_list_insert_after(ABFD, A, S) \
577
  do                                                   \
578
    @{                                                  \
579
      asection *_a = A;                                \
580
      asection *_s = S;                                \
581
      asection *_next = _a->next;                      \
582
      _s->next = _next;                                \
583
      _s->prev = _a;                                   \
584
      _a->next = _s;                                   \
585
      if (_next)                                       \
586
        _next->prev = _s;                              \
587
      else                                             \
588
        (ABFD)->section_last = _s;                     \
589
    @}                                                  \
590
  while (0)
591
#define bfd_section_list_insert_before(ABFD, B, S) \
592
  do                                                   \
593
    @{                                                  \
594
      asection *_b = B;                                \
595
      asection *_s = S;                                \
596
      asection *_prev = _b->prev;                      \
597
      _s->prev = _prev;                                \
598
      _s->next = _b;                                   \
599
      _b->prev = _s;                                   \
600
      if (_prev)                                       \
601
        _prev->next = _s;                              \
602
      else                                             \
603
        (ABFD)->sections = _s;                         \
604
    @}                                                  \
605
  while (0)
606
#define bfd_section_removed_from_list(ABFD, S) \
607
  ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S))
608
 
609
#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX)                   \
610
  /* name, id,  index, next, prev, flags, user_set_vma,            */  \
611
  @{ NAME,  IDX, 0,     NULL, NULL, FLAGS, 0,                           \
612
                                                                       \
613
  /* linker_mark, linker_has_input, gc_mark, segment_mark,         */  \
614
     0,           0,                1,       0,                        \
615
                                                                       \
616
  /* sec_info_type, use_rela_p,                                    */  \
617
     0,             0,                                                 \
618
                                                                       \
619
  /* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5,   */  \
620
     0,        0,        0,        0,        0,        0,              \
621
                                                                       \
622
  /* vma, lma, size, rawsize, relax, relax_count,                  */  \
623
     0,   0,   0,    0,       0,     0,                                \
624
                                                                       \
625
  /* output_offset, output_section,              alignment_power,  */  \
626
     0,             (struct bfd_section *) &SEC, 0,                    \
627
                                                                       \
628
  /* relocation, orelocation, reloc_count, filepos, rel_filepos,   */  \
629
     NULL,       NULL,        0,           0,       0,                 \
630
                                                                       \
631
  /* line_filepos, userdata, contents, lineno, lineno_count,       */  \
632
     0,            NULL,     NULL,     NULL,   0,                      \
633
                                                                       \
634
  /* entsize, kept_section, moving_line_filepos,                    */ \
635
     0,       NULL,          0,                                        \
636
                                                                       \
637
  /* target_index, used_by_bfd, constructor_chain, owner,          */  \
638
     0,            NULL,        NULL,              NULL,               \
639
                                                                       \
640
  /* symbol,                    symbol_ptr_ptr,                    */  \
641
     (struct bfd_symbol *) SYM, &SEC.symbol,                           \
642
                                                                       \
643
  /* map_head, map_tail                                            */  \
644
     @{ NULL @}, @{ NULL @}                                                \
645
    @}
646
 
647
@end example
648
 
649
@node section prototypes,  , typedef asection, Sections
650
@subsection Section prototypes
651
These are the functions exported by the section handling part of BFD.
652
 
653
@findex bfd_section_list_clear
654
@subsubsection @code{bfd_section_list_clear}
655
@strong{Synopsis}
656
@example
657
void bfd_section_list_clear (bfd *);
658
@end example
659
@strong{Description}@*
660
Clears the section list, and also resets the section count and
661
hash table entries.
662
 
663
@findex bfd_get_section_by_name
664
@subsubsection @code{bfd_get_section_by_name}
665
@strong{Synopsis}
666
@example
667
asection *bfd_get_section_by_name (bfd *abfd, const char *name);
668
@end example
669
@strong{Description}@*
670
Run through @var{abfd} and return the one of the
671
@code{asection}s whose name matches @var{name}, otherwise @code{NULL}.
672
@xref{Sections}, for more information.
673
 
674
This should only be used in special cases; the normal way to process
675
all sections of a given name is to use @code{bfd_map_over_sections} and
676
@code{strcmp} on the name (or better yet, base it on the section flags
677
or something else) for each section.
678
 
679
@findex bfd_get_section_by_name_if
680
@subsubsection @code{bfd_get_section_by_name_if}
681
@strong{Synopsis}
682
@example
683
asection *bfd_get_section_by_name_if
684
   (bfd *abfd,
685
    const char *name,
686
    bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj),
687
    void *obj);
688
@end example
689
@strong{Description}@*
690
Call the provided function @var{func} for each section
691
attached to the BFD @var{abfd} whose name matches @var{name},
692
passing @var{obj} as an argument. The function will be called
693
as if by
694
 
695
@example
696
       func (abfd, the_section, obj);
697
@end example
698
 
699
It returns the first section for which @var{func} returns true,
700
otherwise @code{NULL}.
701
 
702
@findex bfd_get_unique_section_name
703
@subsubsection @code{bfd_get_unique_section_name}
704
@strong{Synopsis}
705
@example
706
char *bfd_get_unique_section_name
707
   (bfd *abfd, const char *templat, int *count);
708
@end example
709
@strong{Description}@*
710
Invent a section name that is unique in @var{abfd} by tacking
711
a dot and a digit suffix onto the original @var{templat}.  If
712
@var{count} is non-NULL, then it specifies the first number
713
tried as a suffix to generate a unique name.  The value
714
pointed to by @var{count} will be incremented in this case.
715
 
716
@findex bfd_make_section_old_way
717
@subsubsection @code{bfd_make_section_old_way}
718
@strong{Synopsis}
719
@example
720
asection *bfd_make_section_old_way (bfd *abfd, const char *name);
721
@end example
722
@strong{Description}@*
723
Create a new empty section called @var{name}
724
and attach it to the end of the chain of sections for the
725
BFD @var{abfd}. An attempt to create a section with a name which
726
is already in use returns its pointer without changing the
727
section chain.
728
 
729
It has the funny name since this is the way it used to be
730
before it was rewritten....
731
 
732
Possible errors are:
733
@itemize @bullet
734
 
735
@item
736
@code{bfd_error_invalid_operation} -
737
If output has already started for this BFD.
738
@item
739
@code{bfd_error_no_memory} -
740
If memory allocation fails.
741
@end itemize
742
 
743
@findex bfd_make_section_anyway_with_flags
744
@subsubsection @code{bfd_make_section_anyway_with_flags}
745
@strong{Synopsis}
746
@example
747
asection *bfd_make_section_anyway_with_flags
748
   (bfd *abfd, const char *name, flagword flags);
749
@end example
750
@strong{Description}@*
751
Create a new empty section called @var{name} and attach it to the end of
752
the chain of sections for @var{abfd}.  Create a new section even if there
753
is already a section with that name.  Also set the attributes of the
754
new section to the value @var{flags}.
755
 
756
Return @code{NULL} and set @code{bfd_error} on error; possible errors are:
757
@itemize @bullet
758
 
759
@item
760
@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}.
761
@item
762
@code{bfd_error_no_memory} - If memory allocation fails.
763
@end itemize
764
 
765
@findex bfd_make_section_anyway
766
@subsubsection @code{bfd_make_section_anyway}
767
@strong{Synopsis}
768
@example
769
asection *bfd_make_section_anyway (bfd *abfd, const char *name);
770
@end example
771
@strong{Description}@*
772
Create a new empty section called @var{name} and attach it to the end of
773
the chain of sections for @var{abfd}.  Create a new section even if there
774
is already a section with that name.
775
 
776
Return @code{NULL} and set @code{bfd_error} on error; possible errors are:
777
@itemize @bullet
778
 
779
@item
780
@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}.
781
@item
782
@code{bfd_error_no_memory} - If memory allocation fails.
783
@end itemize
784
 
785
@findex bfd_make_section_with_flags
786
@subsubsection @code{bfd_make_section_with_flags}
787
@strong{Synopsis}
788
@example
789
asection *bfd_make_section_with_flags
790
   (bfd *, const char *name, flagword flags);
791
@end example
792
@strong{Description}@*
793
Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling
794
bfd_set_error ()) without changing the section chain if there is already a
795
section named @var{name}.  Also set the attributes of the new section to
796
the value @var{flags}.  If there is an error, return @code{NULL} and set
797
@code{bfd_error}.
798
 
799
@findex bfd_make_section
800
@subsubsection @code{bfd_make_section}
801
@strong{Synopsis}
802
@example
803
asection *bfd_make_section (bfd *, const char *name);
804
@end example
805
@strong{Description}@*
806
Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling
807
bfd_set_error ()) without changing the section chain if there is already a
808
section named @var{name}.  If there is an error, return @code{NULL} and set
809
@code{bfd_error}.
810
 
811
@findex bfd_set_section_flags
812
@subsubsection @code{bfd_set_section_flags}
813
@strong{Synopsis}
814
@example
815
bfd_boolean bfd_set_section_flags
816
   (bfd *abfd, asection *sec, flagword flags);
817
@end example
818
@strong{Description}@*
819
Set the attributes of the section @var{sec} in the BFD
820
@var{abfd} to the value @var{flags}. Return @code{TRUE} on success,
821
@code{FALSE} on error. Possible error returns are:
822
 
823
@itemize @bullet
824
 
825
@item
826
@code{bfd_error_invalid_operation} -
827
The section cannot have one or more of the attributes
828
requested. For example, a .bss section in @code{a.out} may not
829
have the @code{SEC_HAS_CONTENTS} field set.
830
@end itemize
831
 
832
@findex bfd_map_over_sections
833
@subsubsection @code{bfd_map_over_sections}
834
@strong{Synopsis}
835
@example
836
void bfd_map_over_sections
837
   (bfd *abfd,
838
    void (*func) (bfd *abfd, asection *sect, void *obj),
839
    void *obj);
840
@end example
841
@strong{Description}@*
842
Call the provided function @var{func} for each section
843
attached to the BFD @var{abfd}, passing @var{obj} as an
844
argument. The function will be called as if by
845
 
846
@example
847
       func (abfd, the_section, obj);
848
@end example
849
 
850
This is the preferred method for iterating over sections; an
851
alternative would be to use a loop:
852
 
853
@example
854
          section *p;
855
          for (p = abfd->sections; p != NULL; p = p->next)
856
             func (abfd, p, ...)
857
@end example
858
 
859
@findex bfd_sections_find_if
860
@subsubsection @code{bfd_sections_find_if}
861
@strong{Synopsis}
862
@example
863
asection *bfd_sections_find_if
864
   (bfd *abfd,
865
    bfd_boolean (*operation) (bfd *abfd, asection *sect, void *obj),
866
    void *obj);
867
@end example
868
@strong{Description}@*
869
Call the provided function @var{operation} for each section
870
attached to the BFD @var{abfd}, passing @var{obj} as an
871
argument. The function will be called as if by
872
 
873
@example
874
       operation (abfd, the_section, obj);
875
@end example
876
 
877
It returns the first section for which @var{operation} returns true.
878
 
879
@findex bfd_set_section_size
880
@subsubsection @code{bfd_set_section_size}
881
@strong{Synopsis}
882
@example
883
bfd_boolean bfd_set_section_size
884
   (bfd *abfd, asection *sec, bfd_size_type val);
885
@end example
886
@strong{Description}@*
887
Set @var{sec} to the size @var{val}. If the operation is
888
ok, then @code{TRUE} is returned, else @code{FALSE}.
889
 
890
Possible error returns:
891
@itemize @bullet
892
 
893
@item
894
@code{bfd_error_invalid_operation} -
895
Writing has started to the BFD, so setting the size is invalid.
896
@end itemize
897
 
898
@findex bfd_set_section_contents
899
@subsubsection @code{bfd_set_section_contents}
900
@strong{Synopsis}
901
@example
902
bfd_boolean bfd_set_section_contents
903
   (bfd *abfd, asection *section, const void *data,
904
    file_ptr offset, bfd_size_type count);
905
@end example
906
@strong{Description}@*
907
Sets the contents of the section @var{section} in BFD
908
@var{abfd} to the data starting in memory at @var{data}. The
909
data is written to the output section starting at offset
910
@var{offset} for @var{count} octets.
911
 
912
Normally @code{TRUE} is returned, else @code{FALSE}. Possible error
913
returns are:
914
@itemize @bullet
915
 
916
@item
917
@code{bfd_error_no_contents} -
918
The output section does not have the @code{SEC_HAS_CONTENTS}
919
attribute, so nothing can be written to it.
920
@item
921
and some more too
922
@end itemize
923
This routine is front end to the back end function
924
@code{_bfd_set_section_contents}.
925
 
926
@findex bfd_get_section_contents
927
@subsubsection @code{bfd_get_section_contents}
928
@strong{Synopsis}
929
@example
930
bfd_boolean bfd_get_section_contents
931
   (bfd *abfd, asection *section, void *location, file_ptr offset,
932
    bfd_size_type count);
933
@end example
934
@strong{Description}@*
935
Read data from @var{section} in BFD @var{abfd}
936
into memory starting at @var{location}. The data is read at an
937
offset of @var{offset} from the start of the input section,
938
and is read for @var{count} bytes.
939
 
940
If the contents of a constructor with the @code{SEC_CONSTRUCTOR}
941
flag set are requested or if the section does not have the
942
@code{SEC_HAS_CONTENTS} flag set, then the @var{location} is filled
943
with zeroes. If no errors occur, @code{TRUE} is returned, else
944
@code{FALSE}.
945
 
946
@findex bfd_malloc_and_get_section
947
@subsubsection @code{bfd_malloc_and_get_section}
948
@strong{Synopsis}
949
@example
950
bfd_boolean bfd_malloc_and_get_section
951
   (bfd *abfd, asection *section, bfd_byte **buf);
952
@end example
953
@strong{Description}@*
954
Read all data from @var{section} in BFD @var{abfd}
955
into a buffer, *@var{buf}, malloc'd by this function.
956
 
957
@findex bfd_copy_private_section_data
958
@subsubsection @code{bfd_copy_private_section_data}
959
@strong{Synopsis}
960
@example
961
bfd_boolean bfd_copy_private_section_data
962
   (bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
963
@end example
964
@strong{Description}@*
965
Copy private section information from @var{isec} in the BFD
966
@var{ibfd} to the section @var{osec} in the BFD @var{obfd}.
967
Return @code{TRUE} on success, @code{FALSE} on error.  Possible error
968
returns are:
969
 
970
@itemize @bullet
971
 
972
@item
973
@code{bfd_error_no_memory} -
974
Not enough memory exists to create private data for @var{osec}.
975
@end itemize
976
@example
977
#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
978
     BFD_SEND (obfd, _bfd_copy_private_section_data, \
979
               (ibfd, isection, obfd, osection))
980
@end example
981
 
982
@findex bfd_generic_is_group_section
983
@subsubsection @code{bfd_generic_is_group_section}
984
@strong{Synopsis}
985
@example
986
bfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec);
987
@end example
988
@strong{Description}@*
989
Returns TRUE if @var{sec} is a member of a group.
990
 
991
@findex bfd_generic_discard_group
992
@subsubsection @code{bfd_generic_discard_group}
993
@strong{Synopsis}
994
@example
995
bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group);
996
@end example
997
@strong{Description}@*
998
Remove all members of @var{group} from the output.
999
 

powered by: WebSVN 2.1.0

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