FreeBSD/contrib/binutils/bfd/elf.c
/* Initialize REL_HDR, the section-header for new section, containing
   relocations against ASECT.  If USE_RELA_P is TRUE, we use RELA
   relocations; otherwise, we use REL relocations.  */
Initialize REL_HDR, the section-header for new section, containing
relocations against ASECT.  If USE_RELA_P is TRUE, we use RELA
relocations; otherwise, we use REL relocations.
Initialize REL_HDR the section - header for new section containing relocations against ASECT . If USE_RELA_P is TRUE we use RELA relocations ; otherwise we use REL relocations .
bfd_boolean
_bfd_elf_init_reloc_shdr (bfd *abfd,
			  Elf_Internal_Shdr *rel_hdr,
			  asection *asect,
			  bfd_boolean use_rela_p)
{
  char *name;
  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
  bfd_size_type amt = sizeof ".rela" + strlen (asect->name);
  name = bfd_alloc (abfd, amt);
  if (name == NULL)
    return FALSE;
  sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name);
  rel_hdr->sh_name =
    (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), name,
					FALSE);
  if (rel_hdr->sh_name == (unsigned int) -1)
    return FALSE;
  rel_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL;
  rel_hdr->sh_entsize = (use_rela_p
			 ? bed->s->sizeof_rela
			 : bed->s->sizeof_rel);
  rel_hdr->sh_addralign = 1 << bed->s->log_file_align;
  rel_hdr->sh_flags = 0;
  rel_hdr->sh_addr = 0;
  rel_hdr->sh_size = 0;
  rel_hdr->sh_offset = 0;
  return TRUE;
}
bfd_boolean _bfd_elf_init_reloc_shdr ( bfd * abfd , Elf_Internal_Shdr * rel_hdr , asection * asect , bfd_boolean use_rela_p ) { char * name ; const struct elf_backend_data * bed = get_elf_backend_data ( abfd ) ; bfd_size_type amt = sizeof " " + strlen ( asect -> name ) ; name = bfd_alloc ( abfd , amt ) ; if ( name == NULL ) return FALSE ; sprintf ( name , " " , use_rela_p ? " " : " " , asect -> name ) ; rel_hdr -> sh_name = ( unsigned int ) _bfd_elf_strtab_add ( elf_shstrtab ( abfd ) , name , FALSE ) ; if ( rel_hdr -> sh_name == ( unsigned int ) -1 ) return FALSE ; rel_hdr -> sh_type = use_rela_p ? SHT_RELA : SHT_REL ; rel_hdr -> sh_entsize = ( use_rela_p ? bed -> s -> sizeof_rela : bed -> s -> sizeof_rel ) ; rel_hdr -> sh_addralign = 1 << bed -> s -> log_file_align ; rel_hdr -> sh_flags = 0 ; rel_hdr -> sh_addr = 0 ; rel_hdr -> sh_size = 0 ; rel_hdr -> sh_offset = 0 ; return TRUE ; }
Initialize REL_HDR, the section-header for new section, containing
relocations against ASECT.
Initialize REL_HDR the section - header for new section containing relocations against ASECT .