GNU Info

Info Node: (bfd.info)section prototypes

(bfd.info)section prototypes


Prev: typedef asection Up: Sections
Enter node , (file) or (file)node

Section prototypes
------------------

   These are the functions exported by the section handling part of BFD.

`bfd_section_list_clear'
........................

   *Synopsis*
     void bfd_section_list_clear (bfd *);
   *Description*
Clears the section list, and also resets the section count and hash
table entries.

`bfd_get_section_by_name'
.........................

   *Synopsis*
     asection *bfd_get_section_by_name(bfd *abfd, const char *name);
   *Description*
Run through ABFD and return the one of the `asection's whose name
matches NAME, otherwise `NULL'.  Note: Sections, for more information.

   This should only be used in special cases; the normal way to process
all sections of a given name is to use `bfd_map_over_sections' and
`strcmp' on the name (or better yet, base it on the section flags or
something else) for each section.

`bfd_get_unique_section_name'
.............................

   *Synopsis*
     char *bfd_get_unique_section_name(bfd *abfd,
         const char *templat,
         int *count);
   *Description*
Invent a section name that is unique in ABFD by tacking a dot and a
digit suffix onto the original TEMPLAT.  If COUNT is non-NULL, then it
specifies the first number tried as a suffix to generate a unique name.
The value pointed to by COUNT will be incremented in this case.

`bfd_make_section_old_way'
..........................

   *Synopsis*
     asection *bfd_make_section_old_way(bfd *abfd, const char *name);
   *Description*
Create a new empty section called NAME and attach it to the end of the
chain of sections for the BFD ABFD. An attempt to create a section with
a name which is already in use returns its pointer without changing the
section chain.

   It has the funny name since this is the way it used to be before it
was rewritten....

   Possible errors are:
   * `bfd_error_invalid_operation' - If output has already started for
     this BFD.

   * `bfd_error_no_memory' - If memory allocation fails.

`bfd_make_section_anyway'
.........................

   *Synopsis*
     asection *bfd_make_section_anyway(bfd *abfd, const char *name);
   *Description*
Create a new empty section called NAME and attach it to the end of the
chain of sections for ABFD.  Create a new section even if there is
already a section with that name.

   Return `NULL' and set `bfd_error' on error; possible errors are:
   * `bfd_error_invalid_operation' - If output has already started for
     ABFD.

   * `bfd_error_no_memory' - If memory allocation fails.

`bfd_make_section'
..................

   *Synopsis*
     asection *bfd_make_section(bfd *, const char *name);
   *Description*
Like `bfd_make_section_anyway', but return `NULL' (without calling
bfd_set_error ()) without changing the section chain if there is
already a section named NAME.  If there is an error, return `NULL' and
set `bfd_error'.

`bfd_set_section_flags'
.......................

   *Synopsis*
     boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);
   *Description*
Set the attributes of the section SEC in the BFD ABFD to the value
FLAGS. Return `true' on success, `false' on error. Possible error
returns are:

   * `bfd_error_invalid_operation' - The section cannot have one or
     more of the attributes requested. For example, a .bss section in
     `a.out' may not have the `SEC_HAS_CONTENTS' field set.

`bfd_map_over_sections'
.......................

   *Synopsis*
     void bfd_map_over_sections(bfd *abfd,
         void (*func) (bfd *abfd,
         asection *sect,
         PTR obj),
         PTR obj);
   *Description*
Call the provided function FUNC for each section attached to the BFD
ABFD, passing OBJ as an argument. The function will be called as if by

            func(abfd, the_section, obj);

   This is the prefered method for iterating over sections; an
alternative would be to use a loop:

               section *p;
               for (p = abfd->sections; p != NULL; p = p->next)
                  func(abfd, p, ...)

`bfd_set_section_size'
......................

   *Synopsis*
     boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);
   *Description*
Set SEC to the size VAL. If the operation is ok, then `true' is
returned, else `false'.

   Possible error returns:
   * `bfd_error_invalid_operation' - Writing has started to the BFD, so
     setting the size is invalid.

`bfd_set_section_contents'
..........................

   *Synopsis*
     boolean bfd_set_section_contents (bfd *abfd, asection *section,
         PTR data, file_ptr offset,
         bfd_size_type count);
   *Description*
Sets the contents of the section SECTION in BFD ABFD to the data
starting in memory at DATA. The data is written to the output section
starting at offset OFFSET for COUNT octets.

   Normally `true' is returned, else `false'. Possible error returns
are:
   * `bfd_error_no_contents' - The output section does not have the
     `SEC_HAS_CONTENTS' attribute, so nothing can be written to it.

   * and some more too
   This routine is front end to the back end function
`_bfd_set_section_contents'.

`bfd_get_section_contents'
..........................

   *Synopsis*
     boolean bfd_get_section_contents (bfd *abfd, asection *section,
         PTR location, file_ptr offset,
         bfd_size_type count);
   *Description*
Read data from SECTION in BFD ABFD into memory starting at LOCATION.
The data is read at an offset of OFFSET from the start of the input
section, and is read for COUNT bytes.

   If the contents of a constructor with the `SEC_CONSTRUCTOR' flag set
are requested or if the section does not have the `SEC_HAS_CONTENTS'
flag set, then the LOCATION is filled with zeroes. If no errors occur,
`true' is returned, else `false'.

`bfd_copy_private_section_data'
...............................

   *Synopsis*
     boolean bfd_copy_private_section_data (bfd *ibfd, asection *isec,
         bfd *obfd, asection *osec);
   *Description*
Copy private section information from ISEC in the BFD IBFD to the
section OSEC in the BFD OBFD.  Return `true' on success, `false' on
error.  Possible error returns are:

   * `bfd_error_no_memory' - Not enough memory exists to create private
     data for OSEC.

     #define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
          BFD_SEND (obfd, _bfd_copy_private_section_data, \
                    (ibfd, isection, obfd, osection))

`_bfd_strip_section_from_output'
................................

   *Synopsis*
     void _bfd_strip_section_from_output
        (struct bfd_link_info *info, asection *section);
   *Description*
Remove SECTION from the output.  If the output section becomes empty,
remove it from the output bfd.  INFO may be NULL; if it is not, it is
used to decide whether the output section is empty.


automatically generated by info2www version 1.2.2.9