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