FreeBSD/contrib/binutils/bfd/elf.c
/* Possibly add or remove segments from the segment map.  */
Possibly add or remove segments from the segment map.
Possibly add or remove segments from the segment map .
static bfd_boolean
elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
{
  struct elf_segment_map **m;
  const struct elf_backend_data *bed;
  m = &elf_tdata (abfd)->segment_map;
  while (*m)
    {
      unsigned int i, new_count;
      for (new_count = 0, i = 0; i < (*m)->count; i++)
	{
	  if (((*m)->sections[i]->flags & SEC_EXCLUDE) == 0
	      && (((*m)->sections[i]->flags & SEC_ALLOC) != 0
		  || (*m)->p_type != PT_LOAD))
	    {
	      (*m)->sections[new_count] = (*m)->sections[i];
	      new_count++;
	    }
	}
      (*m)->count = new_count;
      if ((*m)->p_type == PT_LOAD && (*m)->count == 0)
	*m = (*m)->next;
      else
	m = &(*m)->next;
    }
  bed = get_elf_backend_data (abfd);
  if (bed->elf_backend_modify_segment_map != NULL)
    {
      if (!(*bed->elf_backend_modify_segment_map) (abfd, info))
	return FALSE;
    }
  return TRUE;
}
static bfd_boolean elf_modify_segment_map ( bfd * abfd , struct bfd_link_info * info ) { struct elf_segment_map * * m ; const struct elf_backend_data * bed ; m = & elf_tdata ( abfd ) -> segment_map ; while ( * m ) { unsigned int i , new_count ; for ( new_count = 0 , i = 0 ; i < ( * m ) -> count ; i ++ ) { if ( ( ( * m ) -> sections [ i ] -> flags & SEC_EXCLUDE ) == 0 && ( ( ( * m ) -> sections [ i ] -> flags & SEC_ALLOC ) != 0 || ( * m ) -> p_type != PT_LOAD ) ) { ( * m ) -> sections [ new_count ] = ( * m ) -> sections [ i ] ; new_count ++ ; } } ( * m ) -> count = new_count ; if ( ( * m ) -> p_type == PT_LOAD && ( * m ) -> count == 0 ) * m = ( * m ) -> next ; else m = & ( * m ) -> next ; } bed = get_elf_backend_data ( abfd ) ; if ( bed -> elf_backend_modify_segment_map != NULL ) { if ( ! ( * bed -> elf_backend_modify_segment_map ) ( abfd , info ) ) return FALSE ; } return TRUE ; }
Possibly add or remove segments from the segment map.
Possibly add or remove segments from the segment map .
/* The placement algorithm assumes that non allocated sections are
     not in PT_LOAD segments.  We ensure this here by removing such
     sections from the segment map.  We also remove excluded
     sections.  Finally, any PT_LOAD segment without sections is
     removed.  */