FreeBSD/contrib/binutils/bfd/elflink.c
/* Compute the size of, and allocate space for, REL_HDR which is the
   section header for a section containing relocations for O.  */
Compute the size of, and allocate space for, REL_HDR which is the
section header for a section containing relocations for O.
Compute the size of and allocate space for REL_HDR which is the section header for a section containing relocations for O .
bfd_boolean
_bfd_elf_link_size_reloc_section (bfd *abfd,
				  Elf_Internal_Shdr *rel_hdr,
				  asection *o)
{
  bfd_size_type reloc_count;
  bfd_size_type num_rel_hashes;
  if (rel_hdr == &elf_section_data (o)->rel_hdr)
    reloc_count = elf_section_data (o)->rel_count;
  else
    reloc_count = elf_section_data (o)->rel_count2;
  num_rel_hashes = o->reloc_count;
  if (num_rel_hashes < reloc_count)
    num_rel_hashes = reloc_count;
  rel_hdr->sh_size = rel_hdr->sh_entsize * reloc_count;
  rel_hdr->contents = bfd_zalloc (abfd, rel_hdr->sh_size);
  if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0)
    return FALSE;
  if (elf_section_data (o)->rel_hashes == NULL
      && num_rel_hashes)
    {
      struct elf_link_hash_entry **p;
      p = bfd_zmalloc (num_rel_hashes * sizeof (struct elf_link_hash_entry *));
      if (p == NULL)
	return FALSE;
      elf_section_data (o)->rel_hashes = p;
    }
  return TRUE;
}
bfd_boolean _bfd_elf_link_size_reloc_section ( bfd * abfd , Elf_Internal_Shdr * rel_hdr , asection * o ) { bfd_size_type reloc_count ; bfd_size_type num_rel_hashes ; if ( rel_hdr == & elf_section_data ( o ) -> rel_hdr ) reloc_count = elf_section_data ( o ) -> rel_count ; else reloc_count = elf_section_data ( o ) -> rel_count2 ; num_rel_hashes = o -> reloc_count ; if ( num_rel_hashes < reloc_count ) num_rel_hashes = reloc_count ; rel_hdr -> sh_size = rel_hdr -> sh_entsize * reloc_count ; rel_hdr -> contents = bfd_zalloc ( abfd , rel_hdr -> sh_size ) ; if ( rel_hdr -> contents == NULL && rel_hdr -> sh_size != 0 ) return FALSE ; if ( elf_section_data ( o ) -> rel_hashes == NULL && num_rel_hashes ) { struct elf_link_hash_entry * * p ; p = bfd_zmalloc ( num_rel_hashes * sizeof ( struct elf_link_hash_entry * ) ) ; if ( p == NULL ) return FALSE ; elf_section_data ( o ) -> rel_hashes = p ; } return TRUE ; }
Compute the size of, and allocate space for, REL_HDR which is the
section header for a section containing relocations for O.
Compute the size of and allocate space for REL_HDR which is the section header for a section containing relocations for O .
/* Figure out how many relocations there will be.  */ /* That allows us to calculate the size of the section.  */ /* The contents field must last into write_object_contents, so we
     allocate it with bfd_alloc rather than malloc.  Also since we
     cannot be sure that the contents will actually be filled in,
     we zero the allocated space.  */ /* We only allocate one set of hash entries, so we only do it the
     first time we are called.  */