FreeBSD/contrib/binutils/bfd/elf.c
/* Fill in the contents of a SHT_GROUP section.  */
Fill in the contents of a SHT_GROUP section.
Fill in the contents of a SHT_GROUP section .
void
bfd_elf_set_group_contents (bfd *abfd, asection *sec, void *failedptrarg)
{
  bfd_boolean *failedptr = failedptrarg;
  unsigned long symindx;
  asection *elt, *first;
  unsigned char *loc;
  bfd_boolean gas;
  if (((sec->flags & (SEC_GROUP | SEC_LINKER_CREATED)) != SEC_GROUP)
      || *failedptr)
    return;
  symindx = 0;
  if (elf_group_id (sec) != NULL)
    symindx = elf_group_id (sec)->udata.i;
  if (symindx == 0)
    {
      if (elf_section_syms (abfd) != NULL)
	symindx = elf_section_syms (abfd)[sec->index]->udata.i;
      else
	symindx = sec->target_index;
    }
  elf_section_data (sec)->this_hdr.sh_info = symindx;
  gas = TRUE;
  if (sec->contents == NULL)
    {
      gas = FALSE;
      sec->contents = bfd_alloc (abfd, sec->size);
      elf_section_data (sec)->this_hdr.contents = sec->contents;
      if (sec->contents == NULL)
	{
	  *failedptr = TRUE;
	  return;
	}
    }
  loc = sec->contents + sec->size;
  first = elt = elf_next_in_group (sec);
  while (elt != NULL)
    {
      asection *s;
      unsigned int idx;
      loc -= 4;
      s = elt;
      if (!gas)
	s = s->output_section;
      idx = 0;
      if (s != NULL)
	idx = elf_section_data (s)->this_idx;
      H_PUT_32 (abfd, idx, loc);
      elt = elf_next_in_group (elt);
      if (elt == first)
	break;
    }
  if ((loc -= 4) != sec->contents)
    abort ();
  H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc);
}
void bfd_elf_set_group_contents ( bfd * abfd , asection * sec , void * failedptrarg ) { bfd_boolean * failedptr = failedptrarg ; unsigned long symindx ; asection * elt , * first ; unsigned char * loc ; bfd_boolean gas ; if ( ( ( sec -> flags & ( SEC_GROUP | SEC_LINKER_CREATED ) ) != SEC_GROUP ) || * failedptr ) return ; symindx = 0 ; if ( elf_group_id ( sec ) != NULL ) symindx = elf_group_id ( sec ) -> udata . i ; if ( symindx == 0 ) { if ( elf_section_syms ( abfd ) != NULL ) symindx = elf_section_syms ( abfd ) [ sec -> index ] -> udata . i ; else symindx = sec -> target_index ; } elf_section_data ( sec ) -> this_hdr . sh_info = symindx ; gas = TRUE ; if ( sec -> contents == NULL ) { gas = FALSE ; sec -> contents = bfd_alloc ( abfd , sec -> size ) ; elf_section_data ( sec ) -> this_hdr . contents = sec -> contents ; if ( sec -> contents == NULL ) { * failedptr = TRUE ; return ; } } loc = sec -> contents + sec -> size ; first = elt = elf_next_in_group ( sec ) ; while ( elt != NULL ) { asection * s ; unsigned int idx ; loc -= 4 ; s = elt ; if ( ! gas ) s = s -> output_section ; idx = 0 ; if ( s != NULL ) idx = elf_section_data ( s ) -> this_idx ; H_PUT_32 ( abfd , idx , loc ) ; elt = elf_next_in_group ( elt ) ; if ( elt == first ) break ; } if ( ( loc -= 4 ) != sec -> contents ) abort ( ) ; H_PUT_32 ( abfd , sec -> flags & SEC_LINK_ONCE ? GRP_COMDAT : 0 , loc ) ; }
Fill in the contents of a SHT_GROUP section.
Fill in the contents of a SHT_GROUP section .
/* Ignore linker created group section.  See elfNN_ia64_object_p in
     elfxx-ia64.c.  */ /* If called from the assembler, swap_out_syms will have set up
	 elf_section_syms;  If called for "ld -r", use target_index.  */ /* The contents won't be allocated for "ld -r" or objcopy.  */ /* Arrange for the section to be written out.  */ /* Get the pointer to the first section in the group that gas
     squirreled away here.  objcopy arranges for this to be set to the
     start of the input section group.  */ /* First element is a flag word.  Rest of section is elf section
     indices for all the sections of the group.  Write them backwards
     just to keep the group in the same order as given in .section
     directives, not that it matters.  */