FreeBSD/contrib/binutils/bfd/elf.c
/* Given a section, search the header to find them.  */
Given a section, search the header to find them.
Given a section search the header to find them .
int
_bfd_elf_section_from_bfd_section (bfd *abfd, struct bfd_section *asect)
{
  const struct elf_backend_data *bed;
  int index;
  if (elf_section_data (asect) != NULL
      && elf_section_data (asect)->this_idx != 0)
    return elf_section_data (asect)->this_idx;
  if (bfd_is_abs_section (asect))
    index = SHN_ABS;
  else if (bfd_is_com_section (asect))
    index = SHN_COMMON;
  else if (bfd_is_und_section (asect))
    index = SHN_UNDEF;
  else
    index = -1;
  bed = get_elf_backend_data (abfd);
  if (bed->elf_backend_section_from_bfd_section)
    {
      int retval = index;
      if ((*bed->elf_backend_section_from_bfd_section) (abfd, asect, &retval))
	return retval;
    }
  if (index == -1)
    bfd_set_error (bfd_error_nonrepresentable_section);
  return index;
}
int _bfd_elf_section_from_bfd_section ( bfd * abfd , struct bfd_section * asect ) { const struct elf_backend_data * bed ; int index ; if ( elf_section_data ( asect ) != NULL && elf_section_data ( asect ) -> this_idx != 0 ) return elf_section_data ( asect ) -> this_idx ; if ( bfd_is_abs_section ( asect ) ) index = SHN_ABS ; else if ( bfd_is_com_section ( asect ) ) index = SHN_COMMON ; else if ( bfd_is_und_section ( asect ) ) index = SHN_UNDEF ; else index = -1 ; bed = get_elf_backend_data ( abfd ) ; if ( bed -> elf_backend_section_from_bfd_section ) { int retval = index ; if ( ( * bed -> elf_backend_section_from_bfd_section ) ( abfd , asect , & retval ) ) return retval ; } if ( index == -1 ) bfd_set_error ( bfd_error_nonrepresentable_section ) ; return index ; }
Given a section, search the header to find them.
Given a section search the header to find them .