Merge from vendor branch HEIMDAL:
[dragonfly.git] / contrib / binutils / bfd / doc / section.texi
1 @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 /* 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
115 struct 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
127 typedef struct sec
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 sec *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 is a constructor, and should be placed at the
192      end of the text, data, or bss section(?).  */
193 #define SEC_CONSTRUCTOR_TEXT 0x1100
194 #define SEC_CONSTRUCTOR_DATA 0x2100
195 #define SEC_CONSTRUCTOR_BSS  0x3100
196
197   /* The section has contents - a data section could be
198      @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}; a debug section could be
199      @code{SEC_HAS_CONTENTS}  */
200 #define SEC_HAS_CONTENTS 0x200
201
202   /* An instruction to the linker to not output the section
203      even if it has information which would normally be written.  */
204 #define SEC_NEVER_LOAD 0x400
205
206   /* The section is a COFF shared library section.  This flag is
207      only for the linker.  If this type of section appears in
208      the input file, the linker must copy it to the output file
209      without changing the vma or size.  FIXME: Although this
210      was originally intended to be general, it really is COFF
211      specific (and the flag was renamed to indicate this).  It
212      might be cleaner to have some more general mechanism to
213      allow the back end to control what the linker does with
214      sections.  */
215 #define SEC_COFF_SHARED_LIBRARY 0x800
216
217   /* The section has GOT references.  This flag is only for the
218      linker, and is currently only used by the elf32-hppa back end.
219      It will be set if global offset table references were detected
220      in this section, which indicate to the linker that the section
221      contains PIC code, and must be handled specially when doing a
222      static link.  */
223 #define SEC_HAS_GOT_REF 0x4000
224
225   /* The section contains common symbols (symbols may be defined
226      multiple times, the value of a symbol is the amount of
227      space it requires, and the largest symbol value is the one
228      used).  Most targets have exactly one of these (which we
229      translate to bfd_com_section_ptr), but ECOFF has two.  */
230 #define SEC_IS_COMMON 0x8000
231
232   /* The section contains only debugging information.  For
233      example, this is set for ELF .debug and .stab sections.
234      strip tests this flag to see if a section can be
235      discarded.  */
236 #define SEC_DEBUGGING 0x10000
237
238   /* The contents of this section are held in memory pointed to
239      by the contents field.  This is checked by bfd_get_section_contents,
240      and the data is retrieved from memory if appropriate.  */
241 #define SEC_IN_MEMORY 0x20000
242
243   /* The contents of this section are to be excluded by the
244      linker for executable and shared objects unless those
245      objects are to be further relocated.  */
246 #define SEC_EXCLUDE 0x40000
247
248   /* The contents of this section are to be sorted based on the sum of
249      the symbol and addend values specified by the associated relocation
250      entries.  Entries without associated relocation entries will be
251      appended to the end of the section in an unspecified order.  */
252 #define SEC_SORT_ENTRIES 0x80000
253
254   /* When linking, duplicate sections of the same name should be
255      discarded, rather than being combined into a single section as
256      is usually done.  This is similar to how common symbols are
257      handled.  See SEC_LINK_DUPLICATES below.  */
258 #define SEC_LINK_ONCE 0x100000
259
260   /* If SEC_LINK_ONCE is set, this bitfield describes how the linker
261      should handle duplicate sections.  */
262 #define SEC_LINK_DUPLICATES 0x600000
263
264   /* This value for SEC_LINK_DUPLICATES means that duplicate
265      sections with the same name should simply be discarded.  */
266 #define SEC_LINK_DUPLICATES_DISCARD 0x0
267
268   /* This value for SEC_LINK_DUPLICATES means that the linker
269      should warn if there are any duplicate sections, although
270      it should still only link one copy.  */
271 #define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000
272
273   /* This value for SEC_LINK_DUPLICATES means that the linker
274      should warn if any duplicate sections are a different size.  */
275 #define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000
276
277   /* This value for SEC_LINK_DUPLICATES means that the linker
278      should warn if any duplicate sections contain different
279      contents.  */
280 #define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000
281
282   /* This section was created by the linker as part of dynamic
283      relocation or other arcane processing.  It is skipped when
284      going through the first-pass output, trusting that someone
285      else up the line will take care of it later.  */
286 #define SEC_LINKER_CREATED 0x800000
287
288   /* This section should not be subject to garbage collection.  */
289 #define SEC_KEEP 0x1000000
290
291   /* This section contains "short" data, and should be placed
292      "near" the GP.  */
293 #define SEC_SMALL_DATA 0x2000000
294
295   /* This section contains data which may be shared with other
296      executables or shared objects.  */
297 #define SEC_SHARED 0x4000000
298
299   /* When a section with this flag is being linked, then if the size of
300      the input section is less than a page, it should not cross a page
301      boundary.  If the size of the input section is one page or more, it
302      should be aligned on a page boundary.  */
303 #define SEC_BLOCK 0x8000000
304
305   /* Conditionally link this section; do not link if there are no
306      references found to any symbol in the section.  */
307 #define SEC_CLINK 0x10000000
308
309   /* Attempt to merge identical entities in the section.
310      Entity size is given in the entsize field.  */
311 #define SEC_MERGE 0x20000000
312
313   /* If given with SEC_MERGE, entities to merge are zero terminated
314      strings where entsize specifies character size instead of fixed
315      size entries.  */
316 #define SEC_STRINGS 0x40000000
317
318   /* This section contains data about section groups.  */
319 #define SEC_GROUP 0x80000000
320
321   /*  End of section flags.  */
322
323   /* Some internal packed boolean fields.  */
324
325   /* See the vma field.  */
326   unsigned int user_set_vma : 1;
327
328   /* Whether relocations have been processed.  */
329   unsigned int reloc_done : 1;
330
331   /* A mark flag used by some of the linker backends.  */
332   unsigned int linker_mark : 1;
333
334   /* Another mark flag used by some of the linker backends.  Set for
335      output sections that have an input section.  */
336   unsigned int linker_has_input : 1;
337
338   /* A mark flag used by some linker backends for garbage collection.  */
339   unsigned int gc_mark : 1;
340
341   /* Used by the ELF code to mark sections which have been allocated
342      to segments.  */
343   unsigned int segment_mark : 1;
344
345   /* End of internal packed boolean fields.  */
346
347   /*  The virtual memory address of the section - where it will be
348       at run time.  The symbols are relocated against this.  The
349       user_set_vma flag is maintained by bfd; if it's not set, the
350       backend can assign addresses (for example, in @code{a.out}, where
351       the default address for @code{.data} is dependent on the specific
352       target and various flags).  */
353   bfd_vma vma;
354
355   /*  The load address of the section - where it would be in a
356       rom image; really only used for writing section header
357       information.  */
358   bfd_vma lma;
359
360   /* The size of the section in octets, as it will be output.
361      Contains a value even if the section has no contents (e.g., the
362      size of @code{.bss}).  This will be filled in after relocation.  */
363   bfd_size_type _cooked_size;
364
365   /* The original size on disk of the section, in octets.  Normally this
366      value is the same as the size, but if some relaxing has
367      been done, then this value will be bigger.  */
368   bfd_size_type _raw_size;
369
370   /* If this section is going to be output, then this value is the
371      offset in *bytes* into the output section of the first byte in the
372      input section (byte ==> smallest addressable unit on the
373      target).  In most cases, if this was going to start at the
374      100th octet (8-bit quantity) in the output section, this value
375      would be 100.  However, if the target byte size is 16 bits
376      (bfd_octets_per_byte is "2"), this value would be 50.  */
377   bfd_vma output_offset;
378
379   /* The output section through which to map on output.  */
380   struct sec *output_section;
381
382   /* The alignment requirement of the section, as an exponent of 2 -
383      e.g., 3 aligns to 2^3 (or 8).  */
384   unsigned int alignment_power;
385
386   /* If an input section, a pointer to a vector of relocation
387      records for the data in this section.  */
388   struct reloc_cache_entry *relocation;
389
390   /* If an output section, a pointer to a vector of pointers to
391      relocation records for the data in this section.  */
392   struct reloc_cache_entry **orelocation;
393
394   /* The number of relocation records in one of the above.  */
395   unsigned reloc_count;
396
397   /* Information below is back end specific - and not always used
398      or updated.  */
399
400   /* File position of section data.  */
401   file_ptr filepos;
402
403   /* File position of relocation info.  */
404   file_ptr rel_filepos;
405
406   /* File position of line data.  */
407   file_ptr line_filepos;
408
409   /* Pointer to data for applications.  */
410   PTR userdata;
411
412   /* If the SEC_IN_MEMORY flag is set, this points to the actual
413      contents.  */
414   unsigned char *contents;
415
416   /* Attached line number information.  */
417   alent *lineno;
418
419   /* Number of line number records.  */
420   unsigned int lineno_count;
421
422   /* Entity size for merging purposes.  */
423   unsigned int entsize;
424
425   /* Optional information about a COMDAT entry; NULL if not COMDAT.  */
426   struct bfd_comdat_info *comdat;
427
428   /* When a section is being output, this value changes as more
429      linenumbers are written out.  */
430   file_ptr moving_line_filepos;
431
432   /* What the section number is in the target world.  */
433   int target_index;
434
435   PTR used_by_bfd;
436
437   /* If this is a constructor section then here is a list of the
438      relocations created to relocate items within it.  */
439   struct relent_chain *constructor_chain;
440
441   /* The BFD which owns the section.  */
442   bfd *owner;
443
444   /* A symbol which points at this section only.  */
445   struct symbol_cache_entry *symbol;
446   struct symbol_cache_entry **symbol_ptr_ptr;
447
448   struct bfd_link_order *link_order_head;
449   struct bfd_link_order *link_order_tail;
450 @} asection;
451
452 /* These sections are global, and are managed by BFD.  The application
453    and target back end are not permitted to change the values in
454    these sections.  New code should use the section_ptr macros rather
455    than referring directly to the const sections.  The const sections
456    may eventually vanish.  */
457 #define BFD_ABS_SECTION_NAME "*ABS*"
458 #define BFD_UND_SECTION_NAME "*UND*"
459 #define BFD_COM_SECTION_NAME "*COM*"
460 #define BFD_IND_SECTION_NAME "*IND*"
461
462 /* The absolute section.  */
463 extern const asection bfd_abs_section;
464 #define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
465 #define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
466 /* Pointer to the undefined section.  */
467 extern const asection bfd_und_section;
468 #define bfd_und_section_ptr ((asection *) &bfd_und_section)
469 #define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
470 /* Pointer to the common section.  */
471 extern const asection bfd_com_section;
472 #define bfd_com_section_ptr ((asection *) &bfd_com_section)
473 /* Pointer to the indirect section.  */
474 extern const asection bfd_ind_section;
475 #define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
476 #define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
477
478 #define bfd_is_const_section(SEC)              \
479  (   ((SEC) == bfd_abs_section_ptr)            \
480   || ((SEC) == bfd_und_section_ptr)            \
481   || ((SEC) == bfd_com_section_ptr)            \
482   || ((SEC) == bfd_ind_section_ptr))
483
484 extern const struct symbol_cache_entry * const bfd_abs_symbol;
485 extern const struct symbol_cache_entry * const bfd_com_symbol;
486 extern const struct symbol_cache_entry * const bfd_und_symbol;
487 extern const struct symbol_cache_entry * const bfd_ind_symbol;
488 #define bfd_get_section_size_before_reloc(section) \
489      ((section)->reloc_done ? (abort (), (bfd_size_type) 1) \
490                             : (section)->_raw_size)
491 #define bfd_get_section_size_after_reloc(section) \
492      ((section)->reloc_done ? (section)->_cooked_size \
493                             : (abort (), (bfd_size_type) 1))
494
495 /* Macros to handle insertion and deletion of a bfd's sections.  These
496    only handle the list pointers, ie. do not adjust section_count,
497    target_index etc.  */
498 #define bfd_section_list_remove(ABFD, PS) \
499   do                                                   \
500     @{                                                  \
501       asection **_ps = PS;                             \
502       asection *_s = *_ps;                             \
503       *_ps = _s->next;                                 \
504       if (_s->next == NULL)                            \
505         (ABFD)->section_tail = _ps;                    \
506     @}                                                  \
507   while (0)
508 #define bfd_section_list_insert(ABFD, PS, S) \
509   do                                                   \
510     @{                                                  \
511       asection **_ps = PS;                             \
512       asection *_s = S;                                \
513       _s->next = *_ps;                                 \
514       *_ps = _s;                                       \
515       if (_s->next == NULL)                            \
516         (ABFD)->section_tail = &_s->next;              \
517     @}                                                  \
518   while (0)
519
520 @end example
521
522 @node section prototypes,  , typedef asection, Sections
523 @subsection Section prototypes
524 These are the functions exported by the section handling part of BFD.
525
526 @findex bfd_section_list_clear
527 @subsubsection @code{bfd_section_list_clear}
528 @strong{Synopsis}
529 @example
530 void bfd_section_list_clear (bfd *);
531 @end example
532 @strong{Description}@*
533 Clears the section list, and also resets the section count and
534 hash table entries.
535
536 @findex bfd_get_section_by_name
537 @subsubsection @code{bfd_get_section_by_name}
538 @strong{Synopsis}
539 @example
540 asection *bfd_get_section_by_name(bfd *abfd, const char *name);
541 @end example
542 @strong{Description}@*
543 Run through @var{abfd} and return the one of the
544 @code{asection}s whose name matches @var{name}, otherwise @code{NULL}.
545 @xref{Sections}, for more information.
546
547 This should only be used in special cases; the normal way to process
548 all sections of a given name is to use @code{bfd_map_over_sections} and
549 @code{strcmp} on the name (or better yet, base it on the section flags
550 or something else) for each section.
551
552 @findex bfd_get_unique_section_name
553 @subsubsection @code{bfd_get_unique_section_name}
554 @strong{Synopsis}
555 @example
556 char *bfd_get_unique_section_name(bfd *abfd,
557     const char *templat,
558     int *count);
559 @end example
560 @strong{Description}@*
561 Invent a section name that is unique in @var{abfd} by tacking
562 a dot and a digit suffix onto the original @var{templat}.  If
563 @var{count} is non-NULL, then it specifies the first number
564 tried as a suffix to generate a unique name.  The value
565 pointed to by @var{count} will be incremented in this case.
566
567 @findex bfd_make_section_old_way
568 @subsubsection @code{bfd_make_section_old_way}
569 @strong{Synopsis}
570 @example
571 asection *bfd_make_section_old_way(bfd *abfd, const char *name);
572 @end example
573 @strong{Description}@*
574 Create a new empty section called @var{name}
575 and attach it to the end of the chain of sections for the
576 BFD @var{abfd}. An attempt to create a section with a name which
577 is already in use returns its pointer without changing the
578 section chain.
579
580 It has the funny name since this is the way it used to be
581 before it was rewritten....
582
583 Possible errors are:
584 @itemize @bullet
585
586 @item
587 @code{bfd_error_invalid_operation} -
588 If output has already started for this BFD.
589 @item
590 @code{bfd_error_no_memory} -
591 If memory allocation fails.
592 @end itemize
593
594 @findex bfd_make_section_anyway
595 @subsubsection @code{bfd_make_section_anyway}
596 @strong{Synopsis}
597 @example
598 asection *bfd_make_section_anyway(bfd *abfd, const char *name);
599 @end example
600 @strong{Description}@*
601 Create a new empty section called @var{name} and attach it to the end of
602 the chain of sections for @var{abfd}.  Create a new section even if there
603 is already a section with that name.
604
605 Return @code{NULL} and set @code{bfd_error} on error; possible errors are:
606 @itemize @bullet
607
608 @item
609 @code{bfd_error_invalid_operation} - If output has already started for @var{abfd}.
610 @item
611 @code{bfd_error_no_memory} - If memory allocation fails.
612 @end itemize
613
614 @findex bfd_make_section
615 @subsubsection @code{bfd_make_section}
616 @strong{Synopsis}
617 @example
618 asection *bfd_make_section(bfd *, const char *name);
619 @end example
620 @strong{Description}@*
621 Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling
622 bfd_set_error ()) without changing the section chain if there is already a
623 section named @var{name}.  If there is an error, return @code{NULL} and set
624 @code{bfd_error}.
625
626 @findex bfd_set_section_flags
627 @subsubsection @code{bfd_set_section_flags}
628 @strong{Synopsis}
629 @example
630 boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);
631 @end example
632 @strong{Description}@*
633 Set the attributes of the section @var{sec} in the BFD
634 @var{abfd} to the value @var{flags}. Return @code{true} on success,
635 @code{false} on error. Possible error returns are:
636
637 @itemize @bullet
638
639 @item
640 @code{bfd_error_invalid_operation} -
641 The section cannot have one or more of the attributes
642 requested. For example, a .bss section in @code{a.out} may not
643 have the @code{SEC_HAS_CONTENTS} field set.
644 @end itemize
645
646 @findex bfd_map_over_sections
647 @subsubsection @code{bfd_map_over_sections}
648 @strong{Synopsis}
649 @example
650 void bfd_map_over_sections(bfd *abfd,
651     void (*func) (bfd *abfd,
652     asection *sect,
653     PTR obj),
654     PTR obj);
655 @end example
656 @strong{Description}@*
657 Call the provided function @var{func} for each section
658 attached to the BFD @var{abfd}, passing @var{obj} as an
659 argument. The function will be called as if by
660
661 @example
662        func(abfd, the_section, obj);
663 @end example
664
665 This is the prefered method for iterating over sections; an
666 alternative would be to use a loop:
667
668 @example
669           section *p;
670           for (p = abfd->sections; p != NULL; p = p->next)
671              func(abfd, p, ...)
672 @end example
673
674 @findex bfd_set_section_size
675 @subsubsection @code{bfd_set_section_size}
676 @strong{Synopsis}
677 @example
678 boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);
679 @end example
680 @strong{Description}@*
681 Set @var{sec} to the size @var{val}. If the operation is
682 ok, then @code{true} is returned, else @code{false}.
683
684 Possible error returns:
685 @itemize @bullet
686
687 @item
688 @code{bfd_error_invalid_operation} -
689 Writing has started to the BFD, so setting the size is invalid.
690 @end itemize
691
692 @findex bfd_set_section_contents
693 @subsubsection @code{bfd_set_section_contents}
694 @strong{Synopsis}
695 @example
696 boolean bfd_set_section_contents (bfd *abfd, asection *section,
697     PTR data, file_ptr offset,
698     bfd_size_type count);
699 @end example
700 @strong{Description}@*
701 Sets the contents of the section @var{section} in BFD
702 @var{abfd} to the data starting in memory at @var{data}. The
703 data is written to the output section starting at offset
704 @var{offset} for @var{count} octets.
705
706 Normally @code{true} is returned, else @code{false}. Possible error
707 returns are:
708 @itemize @bullet
709
710 @item
711 @code{bfd_error_no_contents} -
712 The output section does not have the @code{SEC_HAS_CONTENTS}
713 attribute, so nothing can be written to it.
714 @item
715 and some more too
716 @end itemize
717 This routine is front end to the back end function
718 @code{_bfd_set_section_contents}.
719
720 @findex bfd_get_section_contents
721 @subsubsection @code{bfd_get_section_contents}
722 @strong{Synopsis}
723 @example
724 boolean bfd_get_section_contents (bfd *abfd, asection *section,
725     PTR location, file_ptr offset,
726     bfd_size_type count);
727 @end example
728 @strong{Description}@*
729 Read data from @var{section} in BFD @var{abfd}
730 into memory starting at @var{location}. The data is read at an
731 offset of @var{offset} from the start of the input section,
732 and is read for @var{count} bytes.
733
734 If the contents of a constructor with the @code{SEC_CONSTRUCTOR}
735 flag set are requested or if the section does not have the
736 @code{SEC_HAS_CONTENTS} flag set, then the @var{location} is filled
737 with zeroes. If no errors occur, @code{true} is returned, else
738 @code{false}.
739
740 @findex bfd_copy_private_section_data
741 @subsubsection @code{bfd_copy_private_section_data}
742 @strong{Synopsis}
743 @example
744 boolean bfd_copy_private_section_data (bfd *ibfd, asection *isec,
745     bfd *obfd, asection *osec);
746 @end example
747 @strong{Description}@*
748 Copy private section information from @var{isec} in the BFD
749 @var{ibfd} to the section @var{osec} in the BFD @var{obfd}.
750 Return @code{true} on success, @code{false} on error.  Possible error
751 returns are:
752
753 @itemize @bullet
754
755 @item
756 @code{bfd_error_no_memory} -
757 Not enough memory exists to create private data for @var{osec}.
758 @end itemize
759 @example
760 #define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
761      BFD_SEND (obfd, _bfd_copy_private_section_data, \
762                (ibfd, isection, obfd, osection))
763 @end example
764
765 @findex _bfd_strip_section_from_output
766 @subsubsection @code{_bfd_strip_section_from_output}
767 @strong{Synopsis}
768 @example
769 void _bfd_strip_section_from_output
770    (struct bfd_link_info *info, asection *section);
771 @end example
772 @strong{Description}@*
773 Remove @var{section} from the output.  If the output section
774 becomes empty, remove it from the output bfd.  @var{info} may
775 be NULL; if it is not, it is used to decide whether the output
776 section is empty.
777