OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [bfd/] [elflink.c] - Diff between revs 161 and 163

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 161 Rev 163
Line 34... Line 34...
   elf_link_hash_traverse which must return failure.  */
   elf_link_hash_traverse which must return failure.  */
 
 
struct elf_info_failed
struct elf_info_failed
{
{
  struct bfd_link_info *info;
  struct bfd_link_info *info;
  struct bfd_elf_version_tree *verdefs;
 
  bfd_boolean failed;
  bfd_boolean failed;
};
};
 
 
/* This structure is used to pass information to
/* This structure is used to pass information to
   _bfd_elf_link_find_version_dependencies.  */
   _bfd_elf_link_find_version_dependencies.  */
Line 1237... Line 1236...
 
 
      if (h->def_dynamic)
      if (h->def_dynamic)
        {
        {
          h->def_dynamic = 0;
          h->def_dynamic = 0;
          h->ref_dynamic = 1;
          h->ref_dynamic = 1;
          h->dynamic_def = 1;
 
        }
        }
      /* FIXME: Should we check type and size for protected symbol?  */
      /* FIXME: Should we check type and size for protected symbol?  */
      h->size = 0;
      h->size = 0;
      h->type = 0;
      h->type = 0;
      return TRUE;
      return TRUE;
Line 1818... Line 1816...
  /* Ignore this if we won't export it.  */
  /* Ignore this if we won't export it.  */
  if (!eif->info->export_dynamic && !h->dynamic)
  if (!eif->info->export_dynamic && !h->dynamic)
    return TRUE;
    return TRUE;
 
 
  if (h->dynindx == -1
  if (h->dynindx == -1
      && (h->def_regular
      && (h->def_regular || h->ref_regular)
          || h->ref_regular))
      && ! bfd_hide_sym_by_version (eif->info->version_info,
    {
                                    h->root.root.string))
      bfd_boolean hide;
 
 
 
      if (eif->verdefs == NULL
 
          || (bfd_find_version_for_sym (eif->verdefs, h->root.root.string, &hide)
 
              && !hide))
 
        {
        {
          if (! bfd_elf_link_record_dynamic_symbol (eif->info, h))
          if (! bfd_elf_link_record_dynamic_symbol (eif->info, h))
            {
            {
              eif->failed = TRUE;
              eif->failed = TRUE;
              return FALSE;
              return FALSE;
            }
            }
        }
        }
    }
 
 
 
  return TRUE;
  return TRUE;
}
}


/* Look through the symbols which are defined in other shared
/* Look through the symbols which are defined in other shared
Line 1979... Line 1971...
            h->hidden = 1;
            h->hidden = 1;
          return TRUE;
          return TRUE;
        }
        }
 
 
      /* Look for the version.  If we find it, it is no longer weak.  */
      /* Look for the version.  If we find it, it is no longer weak.  */
      for (t = sinfo->verdefs; t != NULL; t = t->next)
      for (t = sinfo->info->version_info; t != NULL; t = t->next)
        {
        {
          if (strcmp (t->name, p) == 0)
          if (strcmp (t->name, p) == 0)
            {
            {
              size_t len;
              size_t len;
              char *alc;
              char *alc;
Line 2048... Line 2040...
          t->name_indx = (unsigned int) -1;
          t->name_indx = (unsigned int) -1;
          t->used = TRUE;
          t->used = TRUE;
 
 
          version_index = 1;
          version_index = 1;
          /* Don't count anonymous version tag.  */
          /* Don't count anonymous version tag.  */
          if (sinfo->verdefs != NULL && sinfo->verdefs->vernum == 0)
          if (sinfo->info->version_info != NULL
 
              && sinfo->info->version_info->vernum == 0)
            version_index = 0;
            version_index = 0;
          for (pp = &sinfo->verdefs; *pp != NULL; pp = &(*pp)->next)
          for (pp = &sinfo->info->version_info;
 
               *pp != NULL;
 
               pp = &(*pp)->next)
            ++version_index;
            ++version_index;
          t->vernum = version_index;
          t->vernum = version_index;
 
 
          *pp = t;
          *pp = t;
 
 
Line 2076... Line 2071...
        h->hidden = 1;
        h->hidden = 1;
    }
    }
 
 
  /* If we don't have a version for this symbol, see if we can find
  /* If we don't have a version for this symbol, see if we can find
     something.  */
     something.  */
  if (h->verinfo.vertree == NULL && sinfo->verdefs != NULL)
  if (h->verinfo.vertree == NULL && sinfo->info->version_info != NULL)
    {
    {
      bfd_boolean hide;
      bfd_boolean hide;
 
 
      h->verinfo.vertree = bfd_find_version_for_sym (sinfo->verdefs,
      h->verinfo.vertree
 
        = bfd_find_version_for_sym (sinfo->info->version_info,
                                                 h->root.root.string, &hide);
                                                 h->root.root.string, &hide);
      if (h->verinfo.vertree != NULL && hide)
      if (h->verinfo.vertree != NULL && hide)
        (*bed->elf_backend_hide_symbol) (info, h, TRUE);
        (*bed->elf_backend_hide_symbol) (info, h, TRUE);
    }
    }
 
 
Line 4354... Line 4350...
                  h->def_regular = 1;
                  h->def_regular = 1;
                  if (h->def_dynamic)
                  if (h->def_dynamic)
                    {
                    {
                      h->def_dynamic = 0;
                      h->def_dynamic = 0;
                      h->ref_dynamic = 1;
                      h->ref_dynamic = 1;
                      h->dynamic_def = 1;
 
                    }
                    }
                }
                }
              if (! info->executable
              if (! info->executable
                  || h->def_dynamic
                  || h->def_dynamic
                  || h->ref_dynamic)
                  || h->ref_dynamic)
Line 4367... Line 4362...
          else
          else
            {
            {
              if (! definition)
              if (! definition)
                h->ref_dynamic = 1;
                h->ref_dynamic = 1;
              else
              else
 
                {
                h->def_dynamic = 1;
                h->def_dynamic = 1;
 
                  h->dynamic_def = 1;
 
                }
              if (h->def_regular
              if (h->def_regular
                  || h->ref_regular
                  || h->ref_regular
                  || (h->u.weakdef != NULL
                  || (h->u.weakdef != NULL
                      && ! new_weakdef
                      && ! new_weakdef
                      && h->u.weakdef->dynindx != -1))
                      && h->u.weakdef->dynindx != -1))
                dynsym = TRUE;
                dynsym = TRUE;
            }
            }
 
 
          if (definition && (sec->flags & SEC_DEBUGGING) && !info->relocatable)
 
            {
 
              /* We don't want to make debug symbol dynamic.  */
              /* We don't want to make debug symbol dynamic.  */
 
          if (definition && (sec->flags & SEC_DEBUGGING) && !info->relocatable)
 
            dynsym = FALSE;
 
 
 
          /* Nor should we make plugin symbols dynamic.  */
 
          if ((abfd->flags & BFD_PLUGIN) != 0)
              dynsym = FALSE;
              dynsym = FALSE;
            }
 
 
 
          if (definition)
          if (definition)
            h->target_internal = isym->st_target_internal;
            h->target_internal = isym->st_target_internal;
 
 
          /* Check to see if we need to add an indirect symbol for
          /* Check to see if we need to add an indirect symbol for
Line 4513... Line 4513...
      htab->root.undefs_tail = old_undefs_tail;
      htab->root.undefs_tail = old_undefs_tail;
      for (i = 0; i < htab->root.table.size; i++)
      for (i = 0; i < htab->root.table.size; i++)
        {
        {
          struct bfd_hash_entry *p;
          struct bfd_hash_entry *p;
          struct elf_link_hash_entry *h;
          struct elf_link_hash_entry *h;
 
          bfd_size_type size;
 
          unsigned int alignment_power;
 
 
          for (p = htab->root.table.table[i]; p != NULL; p = p->next)
          for (p = htab->root.table.table[i]; p != NULL; p = p->next)
            {
            {
              h = (struct elf_link_hash_entry *) p;
              h = (struct elf_link_hash_entry *) p;
              if (h->root.type == bfd_link_hash_warning)
              if (h->root.type == bfd_link_hash_warning)
                h = (struct elf_link_hash_entry *) h->root.u.i.link;
                h = (struct elf_link_hash_entry *) h->root.u.i.link;
              if (h->dynindx >= old_dynsymcount)
              if (h->dynindx >= old_dynsymcount)
                _bfd_elf_strtab_delref (htab->dynstr, h->dynstr_index);
                _bfd_elf_strtab_delref (htab->dynstr, h->dynstr_index);
 
 
 
              /* Preserve the maximum alignment and size for common
 
                 symbols even if this dynamic lib isn't on DT_NEEDED
 
                 since it can still be loaded at the run-time by another
 
                 dynamic lib.  */
 
              if (h->root.type == bfd_link_hash_common)
 
                {
 
                  size = h->root.u.c.size;
 
                  alignment_power = h->root.u.c.p->alignment_power;
 
                }
 
              else
 
                {
 
                  size = 0;
 
                  alignment_power = 0;
 
                }
              memcpy (p, old_ent, htab->root.table.entsize);
              memcpy (p, old_ent, htab->root.table.entsize);
              old_ent = (char *) old_ent + htab->root.table.entsize;
              old_ent = (char *) old_ent + htab->root.table.entsize;
              h = (struct elf_link_hash_entry *) p;
              h = (struct elf_link_hash_entry *) p;
              if (h->root.type == bfd_link_hash_warning)
              if (h->root.type == bfd_link_hash_warning)
                {
                {
                  memcpy (h->root.u.i.link, old_ent, htab->root.table.entsize);
                  memcpy (h->root.u.i.link, old_ent, htab->root.table.entsize);
                  old_ent = (char *) old_ent + htab->root.table.entsize;
                  old_ent = (char *) old_ent + htab->root.table.entsize;
                }
                }
 
              else if (h->root.type == bfd_link_hash_common)
 
                {
 
                  if (size > h->root.u.c.size)
 
                    h->root.u.c.size = size;
 
                  if (alignment_power > h->root.u.c.p->alignment_power)
 
                    h->root.u.c.p->alignment_power = alignment_power;
 
                }
            }
            }
        }
        }
 
 
      /* Make a special call to the linker "notice" function to
      /* Make a special call to the linker "notice" function to
         tell it that symbols added for crefs may need to be removed.  */
         tell it that symbols added for crefs may need to be removed.  */
Line 5491... Line 5514...
                               const char *filter_shlib,
                               const char *filter_shlib,
                               const char *audit,
                               const char *audit,
                               const char *depaudit,
                               const char *depaudit,
                               const char * const *auxiliary_filters,
                               const char * const *auxiliary_filters,
                               struct bfd_link_info *info,
                               struct bfd_link_info *info,
                               asection **sinterpptr,
                               asection **sinterpptr)
                               struct bfd_elf_version_tree *verdefs)
 
{
{
  bfd_size_type soname_indx;
  bfd_size_type soname_indx;
  bfd *dynobj;
  bfd *dynobj;
  const struct elf_backend_data *bed;
  const struct elf_backend_data *bed;
  struct elf_info_failed asvinfo;
  struct elf_info_failed asvinfo;
Line 5669... Line 5691...
              || !_bfd_elf_add_dynamic_entry (info, DT_DEPAUDIT, indx))
              || !_bfd_elf_add_dynamic_entry (info, DT_DEPAUDIT, indx))
            return FALSE;
            return FALSE;
        }
        }
 
 
      eif.info = info;
      eif.info = info;
      eif.verdefs = verdefs;
 
      eif.failed = FALSE;
      eif.failed = FALSE;
 
 
      /* If we are supposed to export all symbols into the dynamic symbol
      /* If we are supposed to export all symbols into the dynamic symbol
         table (this is not the normal case), then do so.  */
         table (this is not the normal case), then do so.  */
      if (info->export_dynamic
      if (info->export_dynamic
Line 5685... Line 5706...
          if (eif.failed)
          if (eif.failed)
            return FALSE;
            return FALSE;
        }
        }
 
 
      /* Make all global versions with definition.  */
      /* Make all global versions with definition.  */
      for (t = verdefs; t != NULL; t = t->next)
      for (t = info->version_info; t != NULL; t = t->next)
        for (d = t->globals.list; d != NULL; d = d->next)
        for (d = t->globals.list; d != NULL; d = d->next)
          if (!d->symver && d->literal)
          if (!d->symver && d->literal)
            {
            {
              const char *verstr, *name;
              const char *verstr, *name;
              size_t namelen, verlen, newlen;
              size_t namelen, verlen, newlen;
Line 5738... Line 5759...
                d->symver = 1;
                d->symver = 1;
            }
            }
 
 
      /* Attach all the symbols to their version information.  */
      /* Attach all the symbols to their version information.  */
      asvinfo.info = info;
      asvinfo.info = info;
      asvinfo.verdefs = verdefs;
 
      asvinfo.failed = FALSE;
      asvinfo.failed = FALSE;
 
 
      elf_link_hash_traverse (elf_hash_table (info),
      elf_link_hash_traverse (elf_hash_table (info),
                              _bfd_elf_link_assign_sym_version,
                              _bfd_elf_link_assign_sym_version,
                              &asvinfo);
                              &asvinfo);
Line 5751... Line 5771...
 
 
      if (!info->allow_undefined_version)
      if (!info->allow_undefined_version)
        {
        {
          /* Check if all global versions have a definition.  */
          /* Check if all global versions have a definition.  */
          all_defined = TRUE;
          all_defined = TRUE;
          for (t = verdefs; t != NULL; t = t->next)
          for (t = info->version_info; t != NULL; t = t->next)
            for (d = t->globals.list; d != NULL; d = d->next)
            for (d = t->globals.list; d != NULL; d = d->next)
              if (d->literal && !d->symver && !d->script)
              if (d->literal && !d->symver && !d->script)
                {
                {
                  (*_bfd_error_handler)
                  (*_bfd_error_handler)
                    (_("%s: undefined version: %s"),
                    (_("%s: undefined version: %s"),
Line 5884... Line 5904...
    return FALSE;
    return FALSE;
 
 
  if (elf_hash_table (info)->dynamic_sections_created)
  if (elf_hash_table (info)->dynamic_sections_created)
    {
    {
      unsigned long section_sym_count;
      unsigned long section_sym_count;
 
      struct bfd_elf_version_tree *verdefs;
      asection *s;
      asection *s;
 
 
      /* Set up the version definition section.  */
      /* Set up the version definition section.  */
      s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
      s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
      BFD_ASSERT (s != NULL);
      BFD_ASSERT (s != NULL);
 
 
      /* We may have created additional version definitions if we are
      /* We may have created additional version definitions if we are
         just linking a regular application.  */
         just linking a regular application.  */
      verdefs = asvinfo.verdefs;
      verdefs = info->version_info;
 
 
      /* Skip anonymous version tag.  */
      /* Skip anonymous version tag.  */
      if (verdefs != NULL && verdefs->vernum == 0)
      if (verdefs != NULL && verdefs->vernum == 0)
        verdefs = verdefs->next;
        verdefs = verdefs->next;
 
 
Line 8637... Line 8658...
    }
    }
 
 
  /* We should also warn if a forced local symbol is referenced from
  /* We should also warn if a forced local symbol is referenced from
     shared libraries.  */
     shared libraries.  */
  if (! finfo->info->relocatable
  if (! finfo->info->relocatable
      && (! finfo->info->shared)
      && finfo->info->executable
      && h->forced_local
      && h->forced_local
      && h->ref_dynamic
      && h->ref_dynamic
 
      && h->def_regular
      && !h->dynamic_def
      && !h->dynamic_def
      && !h->dynamic_weak
      && !h->dynamic_weak
      && ! elf_link_check_versioned_symbol (finfo->info, bed, h))
      && ! elf_link_check_versioned_symbol (finfo->info, bed, h))
    {
    {
      bfd *def_bfd;
      bfd *def_bfd;
Line 8681... Line 8703...
    strip = TRUE;
    strip = TRUE;
  else if (finfo->info->strip == strip_some
  else if (finfo->info->strip == strip_some
           && bfd_hash_lookup (finfo->info->keep_hash,
           && bfd_hash_lookup (finfo->info->keep_hash,
                               h->root.root.string, FALSE, FALSE) == NULL)
                               h->root.root.string, FALSE, FALSE) == NULL)
    strip = TRUE;
    strip = TRUE;
  else if (finfo->info->strip_discarded
  else if ((h->root.type == bfd_link_hash_defined
           && (h->root.type == bfd_link_hash_defined
 
               || h->root.type == bfd_link_hash_defweak)
               || h->root.type == bfd_link_hash_defweak)
 
           && ((finfo->info->strip_discarded
           && elf_discarded_section (h->root.u.def.section))
           && elf_discarded_section (h->root.u.def.section))
 
               || (h->root.u.def.section->owner != NULL
 
                   && (h->root.u.def.section->owner->flags & BFD_PLUGIN) != 0)))
    strip = TRUE;
    strip = TRUE;
  else if ((h->root.type == bfd_link_hash_undefined
  else if ((h->root.type == bfd_link_hash_undefined
            || h->root.type == bfd_link_hash_undefweak)
            || h->root.type == bfd_link_hash_undefweak)
           && h->root.u.undef.abfd != NULL
           && h->root.u.undef.abfd != NULL
           && (h->root.u.undef.abfd->flags & BFD_PLUGIN) != 0)
           && (h->root.u.undef.abfd->flags & BFD_PLUGIN) != 0)
Line 11162... Line 11186...
    {
    {
      if (! (*bed->elf_backend_finish_dynamic_sections) (abfd, info))
      if (! (*bed->elf_backend_finish_dynamic_sections) (abfd, info))
        goto error_return;
        goto error_return;
 
 
      /* Check for DT_TEXTREL (late, in case the backend removes it).  */
      /* Check for DT_TEXTREL (late, in case the backend removes it).  */
      if (info->warn_shared_textrel && info->shared)
      if ((info->warn_shared_textrel && info->shared)
 
          || info->error_textrel)
        {
        {
          bfd_byte *dyncon, *dynconend;
          bfd_byte *dyncon, *dynconend;
 
 
          /* Fix up .dynamic entries.  */
          /* Fix up .dynamic entries.  */
          o = bfd_get_section_by_name (dynobj, ".dynamic");
          o = bfd_get_section_by_name (dynobj, ".dynamic");
Line 11180... Line 11205...
 
 
              bed->s->swap_dyn_in (dynobj, dyncon, &dyn);
              bed->s->swap_dyn_in (dynobj, dyncon, &dyn);
 
 
              if (dyn.d_tag == DT_TEXTREL)
              if (dyn.d_tag == DT_TEXTREL)
                {
                {
 
                  if (info->error_textrel)
 
                    info->callbacks->einfo
 
                      (_("%P%X: read-only segment has dynamic relocations.\n"));
 
                  else
                 info->callbacks->einfo
                 info->callbacks->einfo
                    (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
                    (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
                  break;
                  break;
                }
                }
            }
            }
Line 11546... Line 11575...
    {
    {
      h = cookie->sym_hashes[r_symndx - cookie->extsymoff];
      h = cookie->sym_hashes[r_symndx - cookie->extsymoff];
      while (h->root.type == bfd_link_hash_indirect
      while (h->root.type == bfd_link_hash_indirect
             || h->root.type == bfd_link_hash_warning)
             || h->root.type == bfd_link_hash_warning)
        h = (struct elf_link_hash_entry *) h->root.u.i.link;
        h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
      h->mark = 1;
      return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);
      return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);
    }
    }
 
 
  return (*gc_mark_hook) (sec, info, cookie->rel, NULL,
  return (*gc_mark_hook) (sec, info, cookie->rel, NULL,
                          &cookie->locsyms[r_symndx]);
                          &cookie->locsyms[r_symndx]);
Line 11670... Line 11700...
         toss out debug sections.  */
         toss out debug sections.  */
      if (!some_kept)
      if (!some_kept)
        continue;
        continue;
 
 
      /* Keep debug and special sections like .comment when they are
      /* Keep debug and special sections like .comment when they are
         not part of a group.  */
         not part of a group, or when we have single-member groups.  */
      for (isec = ibfd->sections; isec != NULL; isec = isec->next)
      for (isec = ibfd->sections; isec != NULL; isec = isec->next)
        if (elf_next_in_group (isec) == NULL
        if ((elf_next_in_group (isec) == NULL
 
             || elf_next_in_group (isec) == isec)
            && ((isec->flags & SEC_DEBUGGING) != 0
            && ((isec->flags & SEC_DEBUGGING) != 0
                || (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0))
                || (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0))
          isec->gc_mark = 1;
          isec->gc_mark = 1;
    }
    }
  return TRUE;
  return TRUE;
Line 11692... Line 11723...
};
};
 
 
static bfd_boolean
static bfd_boolean
elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
{
{
  if ((h->root.type == bfd_link_hash_defined
  if (!h->mark
 
      && (((h->root.type == bfd_link_hash_defined
       || h->root.type == bfd_link_hash_defweak)
       || h->root.type == bfd_link_hash_defweak)
      && !h->root.u.def.section->gc_mark
           && !h->root.u.def.section->gc_mark)
      && !(h->root.u.def.section->owner->flags & DYNAMIC))
          || h->root.type == bfd_link_hash_undefined
 
          || h->root.type == bfd_link_hash_undefweak))
    {
    {
      struct elf_gc_sweep_symbol_info *inf =
      struct elf_gc_sweep_symbol_info *inf;
          (struct elf_gc_sweep_symbol_info *) data;
 
 
      inf = (struct elf_gc_sweep_symbol_info *) data;
      (*inf->hide_symbol) (inf->info, h, TRUE);
      (*inf->hide_symbol) (inf->info, h, TRUE);
 
      h->def_regular = 0;
 
      h->ref_regular = 0;
 
      h->ref_regular_nonweak = 0;
    }
    }
 
 
  return TRUE;
  return TRUE;
}
}
 
 
Line 11908... Line 11945...
  struct bfd_link_info *info = (struct bfd_link_info *) inf;
  struct bfd_link_info *info = (struct bfd_link_info *) inf;
 
 
  if ((h->root.type == bfd_link_hash_defined
  if ((h->root.type == bfd_link_hash_defined
       || h->root.type == bfd_link_hash_defweak)
       || h->root.type == bfd_link_hash_defweak)
      && (h->ref_dynamic
      && (h->ref_dynamic
          || (!info->executable
          || ((!info->executable || info->export_dynamic)
              && h->def_regular
              && h->def_regular
              && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
              && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
              && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN)))
              && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
 
              && (strchr (h->root.root.string, ELF_VER_CHR) != NULL
 
                  || !bfd_hide_sym_by_version (info->version_info,
 
                                               h->root.root.string)))))
    h->root.u.def.section->flags |= SEC_KEEP;
    h->root.u.def.section->flags |= SEC_KEEP;
 
 
  return TRUE;
  return TRUE;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.