FreeBSD/contrib/binutils/bfd/elflink.c
/* Add a DT_NEEDED entry for this dynamic object if DO_IT is true,
   otherwise just check whether one already exists.  Returns -1 on error,
   1 if a DT_NEEDED tag already exists, and 0 on success.  */
Add a DT_NEEDED entry for this dynamic object if DO_IT is true,
otherwise just check whether one already exists.  Returns -1 on error,
1 if a DT_NEEDED tag already exists, and 0 on success.
Add a DT_NEEDED entry for this dynamic object if DO_IT is true otherwise just check whether one already exists . Returns - 1 on error 1 if a DT_NEEDED tag already exists and 0 on success .
static int
elf_add_dt_needed_tag (bfd *abfd,
		       struct bfd_link_info *info,
		       const char *soname,
		       bfd_boolean do_it)
{
  struct elf_link_hash_table *hash_table;
  bfd_size_type oldsize;
  bfd_size_type strindex;
  if (!_bfd_elf_link_create_dynstrtab (abfd, info))
    return -1;
  hash_table = elf_hash_table (info);
  oldsize = _bfd_elf_strtab_size (hash_table->dynstr);
  strindex = _bfd_elf_strtab_add (hash_table->dynstr, soname, FALSE);
  if (strindex == (bfd_size_type) -1)
    return -1;
  if (oldsize == _bfd_elf_strtab_size (hash_table->dynstr))
    {
      asection *sdyn;
      const struct elf_backend_data *bed;
      bfd_byte *extdyn;
      bed = get_elf_backend_data (hash_table->dynobj);
      sdyn = bfd_get_section_by_name (hash_table->dynobj, ".dynamic");
      if (sdyn != NULL)
	for (extdyn = sdyn->contents;
	     extdyn < sdyn->contents + sdyn->size;
	     extdyn += bed->s->sizeof_dyn)
	  {
	    Elf_Internal_Dyn dyn;
	    bed->s->swap_dyn_in (hash_table->dynobj, extdyn, &dyn);
	    if (dyn.d_tag == DT_NEEDED
		&& dyn.d_un.d_val == strindex)
	      {
		_bfd_elf_strtab_delref (hash_table->dynstr, strindex);
		return 1;
	      }
	  }
    }
  if (do_it)
    {
      if (!_bfd_elf_link_create_dynamic_sections (hash_table->dynobj, info))
	return -1;
      if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex))
	return -1;
    }
  else
    _bfd_elf_strtab_delref (hash_table->dynstr, strindex);
  return 0;
}
static int elf_add_dt_needed_tag ( bfd * abfd , struct bfd_link_info * info , const char * soname , bfd_boolean do_it ) { struct elf_link_hash_table * hash_table ; bfd_size_type oldsize ; bfd_size_type strindex ; if ( ! _bfd_elf_link_create_dynstrtab ( abfd , info ) ) return -1 ; hash_table = elf_hash_table ( info ) ; oldsize = _bfd_elf_strtab_size ( hash_table -> dynstr ) ; strindex = _bfd_elf_strtab_add ( hash_table -> dynstr , soname , FALSE ) ; if ( strindex == ( bfd_size_type ) - 1 ) return -1 ; if ( oldsize == _bfd_elf_strtab_size ( hash_table -> dynstr ) ) { asection * sdyn ; const struct elf_backend_data * bed ; bfd_byte * extdyn ; bed = get_elf_backend_data ( hash_table -> dynobj ) ; sdyn = bfd_get_section_by_name ( hash_table -> dynobj , " " ) ; if ( sdyn != NULL ) for ( extdyn = sdyn -> contents ; extdyn < sdyn -> contents + sdyn -> size ; extdyn += bed -> s -> sizeof_dyn ) { Elf_Internal_Dyn dyn ; bed -> s -> swap_dyn_in ( hash_table -> dynobj , extdyn , & dyn ) ; if ( dyn . d_tag == DT_NEEDED && dyn . d_un . d_val == strindex ) { _bfd_elf_strtab_delref ( hash_table -> dynstr , strindex ) ; return 1 ; } } } if ( do_it ) { if ( ! _bfd_elf_link_create_dynamic_sections ( hash_table -> dynobj , info ) ) return -1 ; if ( ! _bfd_elf_add_dynamic_entry ( info , DT_NEEDED , strindex ) ) return -1 ; } else _bfd_elf_strtab_delref ( hash_table -> dynstr , strindex ) ; return 0 ; }
Add a DT_NEEDED entry for this dynamic object if DO_IT is true,
otherwise just check whether one already exists.
Add a DT_NEEDED entry for this dynamic object if DO_IT is true otherwise just check whether one already exists .
/* We were just checking for existence of the tag.  */