* elf-bfd.h (struct elf_link_hash_table): Add copy_indirect and
authorRichard Henderson <rth@redhat.com>
Sun, 13 Feb 2000 23:11:32 +0000 (23:11 +0000)
committerRichard Henderson <rth@redhat.com>
Sun, 13 Feb 2000 23:11:32 +0000 (23:11 +0000)
        hide_symbol members.
        (elf_link_hash_copy_indirect): New.
        (elf_link_hash_hide_symbol): New.
        * elflink.h (elf_link_add_object_symbols): Break out copy from
        indirect new new symbol to elf.c.
        (elf_link_assign_sym_version): Break out privatization of
        non-exported symbol to elf.c.
        * elf.c (_bfd_elf_link_hash_copy_indirect): New.
        (_bfd_elf_link_hash_hide_symbol): New.
        (_bfd_elf_link_hash_table_init): Init copy_indirect and hide_symbol.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf.c
bfd/elflink.h

index 1b629ea518d677029fc6a734743ac9893494f522..c3425dbcdf21bef96e72fa9411888dc8b7e6abda 100644 (file)
@@ -1,3 +1,17 @@
+2000-02-13  Richard Henderson  <rth@cygnus.com>
+
+       * elf-bfd.h (struct elf_link_hash_table): Add copy_indirect and
+       hide_symbol members.
+       (elf_link_hash_copy_indirect): New.
+       (elf_link_hash_hide_symbol): New.
+       * elflink.h (elf_link_add_object_symbols): Break out copy from 
+       indirect new new symbol to elf.c.
+       (elf_link_assign_sym_version): Break out privatization of
+       non-exported symbol to elf.c.
+       * elf.c (_bfd_elf_link_hash_copy_indirect): New.
+       (_bfd_elf_link_hash_hide_symbol): New.
+       (_bfd_elf_link_hash_table_init): Init copy_indirect and hide_symbol.
+
 2000-02-13  Ian Lance Taylor  <ian@zembu.com>
 
        * section.c (_bfd_strip_section_from_output): Add info parameter.
index 302ca7ae976aba94c319761bb97b397df68320bf..6f0624e2435cd255237da51439389fab26bd28eb 100644 (file)
@@ -243,6 +243,12 @@ struct elf_link_hash_table
   PTR stab_info;
   /* A linked list of local symbols to be added to .dynsym.  */
   struct elf_link_local_dynamic_entry *dynlocal;
+
+  void (*copy_indirect) PARAMS ((struct elf_link_hash_table *,
+                                struct elf_link_hash_entry *,
+                                struct elf_link_hash_entry *));
+  void (*hide_symbol) PARAMS ((struct elf_link_hash_table *,
+                              struct elf_link_hash_entry *));
 };
 
 /* Look up an entry in an ELF linker hash table.  */
@@ -263,6 +269,16 @@ struct elf_link_hash_table
 /* Get the ELF linker hash table from a link_info structure.  */
 
 #define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
+
+/* Call the copy_indirect method.  */
+
+#define elf_link_hash_copy_indirect(TABLE,DIR,IND) \
+  ((*(TABLE)->copy_indirect) ((TABLE), (DIR), (IND)))
+
+/* Call the hide_symbol method.  */
+
+#define elf_link_hash_hide_symbol(TABLE,SYM) \
+  ((*(TABLE)->hide_symbol) ((TABLE), (SYM)))
 \f
 /* Constant information held for an ELF backend.  */
 
index 436f8db9337d32d373864fc80ebfa29ff7e0777b..654d651710f92edc959b1001e59ddb090a08e676 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -906,6 +906,60 @@ _bfd_elf_link_hash_newfunc (entry, table, string)
   return (struct bfd_hash_entry *) ret;
 }
 
+/* Copy data from an indirect symbol to its direct symbol, hiding the
+   old indirect symbol.  */
+
+static void
+_bfd_elf_link_hash_copy_indirect (table, dir, ind)
+     struct elf_link_hash_table *table;
+     struct elf_link_hash_entry *dir, *ind;
+{
+  /* Copy down any references that we may have already seen to the
+     symbol which just became indirect.  */
+
+  dir->elf_link_hash_flags |=
+    (ind->elf_link_hash_flags
+     & (ELF_LINK_HASH_REF_DYNAMIC
+       | ELF_LINK_HASH_REF_REGULAR
+       | ELF_LINK_HASH_REF_REGULAR_NONWEAK
+       | ELF_LINK_NON_GOT_REF));
+
+  /* Copy over the global and procedure linkage table offset entries.
+     These may have been already set up by a check_relocs routine.  */
+  if (dir->got.offset == (bfd_vma) -1)
+    {
+      dir->got.offset = ind->got.offset;
+      ind->got.offset = (bfd_vma) -1;
+    }
+  BFD_ASSERT (ind->got.offset == (bfd_vma) -1);
+
+  if (dir->plt.offset == (bfd_vma) -1)
+    {
+      dir->plt.offset = ind->plt.offset;
+      ind->plt.offset = (bfd_vma) -1;
+    }
+  BFD_ASSERT (ind->plt.offset == (bfd_vma) -1);
+
+  if (dir->dynindx == -1)
+    {
+      dir->dynindx = ind->dynindx;
+      dir->dynstr_index = ind->dynstr_index;
+      ind->dynindx = -1;
+      ind->dynstr_index = 0;
+    }
+  BFD_ASSERT (ind->dynindx == -1);
+}
+
+static void
+_bfd_elf_link_hash_hide_symbol(table, h)
+     struct elf_link_hash_table *table;
+     struct elf_link_hash_entry *h;
+{
+  h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+  h->dynindx = -1;
+  h->plt.offset = (bfd_vma) -1;
+}
+
 /* Initialize an ELF linker hash table.  */
 
 boolean
@@ -925,6 +979,8 @@ _bfd_elf_link_hash_table_init (table, abfd, newfunc)
   table->needed = NULL;
   table->hgot = NULL;
   table->stab_info = NULL;
+  table->copy_indirect = _bfd_elf_link_hash_copy_indirect;
+  table->hide_symbol = _bfd_elf_link_hash_hide_symbol;
   return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
 }
 
index ce71d948c43f894a8357428221f3422d004899f4..5bce1356a8ab1452b8ac9b25d23fde61c7a4853f 100644 (file)
@@ -1734,45 +1734,8 @@ elf_link_add_object_symbols (abfd, info)
                                  == 0);
 
                      ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
-
-                     /* Copy down any references that we may have
-                        already seen to the symbol which just became
-                        indirect.  */
-                     ht->elf_link_hash_flags |=
-                       (hi->elf_link_hash_flags
-                        & (ELF_LINK_HASH_REF_DYNAMIC
-                           | ELF_LINK_HASH_REF_REGULAR
-                           | ELF_LINK_HASH_REF_REGULAR_NONWEAK
-                           | ELF_LINK_NON_GOT_REF));
-
-                     /* Copy over the global and procedure linkage table
-                        offset entries.  These may have been already set
-                        up by a check_relocs routine.  */
-                     if (ht->got.offset == (bfd_vma) -1)
-                       {
-                         ht->got.offset = hi->got.offset;
-                         hi->got.offset = (bfd_vma) -1;
-                       }
-                     BFD_ASSERT (hi->got.offset == (bfd_vma) -1);
-
-                     if (ht->plt.offset == (bfd_vma) -1)
-                       {
-                         ht->plt.offset = hi->plt.offset;
-                         hi->plt.offset = (bfd_vma) -1;
-                       }
-                     BFD_ASSERT (hi->plt.offset == (bfd_vma) -1);
-
-                     if (ht->dynindx == -1)
-                       {
-                         ht->dynindx = hi->dynindx;
-                         ht->dynstr_index = hi->dynstr_index;
-                         hi->dynindx = -1;
-                         hi->dynstr_index = 0;
-                       }
-                     BFD_ASSERT (hi->dynindx == -1);
-
-                     /* FIXME: There may be other information to copy
-                        over for particular targets.  */
+                     elf_link_hash_copy_indirect (elf_hash_table (info),
+                                                  ht, hi);
 
                      /* See if the new flags lead us to realize that
                         the symbol must be dynamic.  */
@@ -1845,44 +1808,8 @@ elf_link_add_object_symbols (abfd, info)
                                          | ELF_LINK_HASH_DEF_REGULAR))
                                      == 0);
 
-                         /* Copy down any references that we may have
-                             already seen to the symbol which just
-                             became indirect.  */
-                         h->elf_link_hash_flags |=
-                           (hi->elf_link_hash_flags
-                            & (ELF_LINK_HASH_REF_DYNAMIC
-                               | ELF_LINK_HASH_REF_REGULAR
-                               | ELF_LINK_HASH_REF_REGULAR_NONWEAK
-                               | ELF_LINK_NON_GOT_REF));
-
-                         /* Copy over the global and procedure linkage
-                             table offset entries.  These may have been
-                             already set up by a check_relocs routine.  */
-                         if (h->got.offset == (bfd_vma) -1)
-                           {
-                             h->got.offset = hi->got.offset;
-                             hi->got.offset = (bfd_vma) -1;
-                           }
-                         BFD_ASSERT (hi->got.offset == (bfd_vma) -1);
-
-                         if (h->plt.offset == (bfd_vma) -1)
-                           {
-                             h->plt.offset = hi->plt.offset;
-                             hi->plt.offset = (bfd_vma) -1;
-                           }
-                         BFD_ASSERT (hi->got.offset == (bfd_vma) -1);
-
-                         if (h->dynindx == -1)
-                           {
-                             h->dynindx = hi->dynindx;
-                             h->dynstr_index = hi->dynstr_index;
-                             hi->dynindx = -1;
-                             hi->dynstr_index = 0;
-                           }
-                         BFD_ASSERT (hi->dynindx == -1);
-
-                         /* FIXME: There may be other information to
-                             copy over for particular targets.  */
+                         elf_link_hash_copy_indirect (elf_hash_table (info),
+                                                      h, hi);
 
                          /* See if the new flags lead us to realize
                              that the symbol must be dynamic.  */
@@ -3758,10 +3685,8 @@ elf_link_assign_sym_version (h, data)
                              && ! sinfo->export_dynamic)
                            {
                              h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
-                             h->elf_link_hash_flags &=~
-                               ELF_LINK_HASH_NEEDS_PLT;
-                             h->dynindx = -1;
-                             h->plt.offset = (bfd_vma) -1;
+                             elf_link_hash_hide_symbol (elf_hash_table (info),
+                                                        h);
                              /* FIXME: The name of the symbol has
                                 already been recorded in the dynamic
                                 string table section.  */
@@ -3873,9 +3798,7 @@ elf_link_assign_sym_version (h, data)
                          && ! sinfo->export_dynamic)
                        {
                          h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
-                         h->elf_link_hash_flags &=~ ELF_LINK_HASH_NEEDS_PLT;
-                         h->dynindx = -1;
-                         h->plt.offset = (bfd_vma) -1;
+                         elf_link_hash_hide_symbol (elf_hash_table (info), h);
                          /* FIXME: The name of the symbol has already
                             been recorded in the dynamic string table
                             section.  */
@@ -3897,9 +3820,7 @@ elf_link_assign_sym_version (h, data)
              && ! sinfo->export_dynamic)
            {
              h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
-             h->elf_link_hash_flags &=~ ELF_LINK_HASH_NEEDS_PLT;
-             h->dynindx = -1;
-             h->plt.offset = (bfd_vma) -1;
+             elf_link_hash_hide_symbol (elf_hash_table (info), h);
              /* FIXME: The name of the symbol has already been
                 recorded in the dynamic string table section.  */
            }