elflink.h -Bsymbolic change

Alan Modra alan@linuxcare.com.au
Sun Apr 8 18:31:00 GMT 2001


On 8 Apr 2001, Ulrich Drepper wrote:

> "H . J . Lu" <hjl@lucon.org> writes:
> 
> > Agreed. Alan, did you run "make check" on Linux/ia32 with glibc 2.2?

HJ, I ran "make check" on an older system with glibc-2.1.3, so missed
seing the failures.  Sorry.

> > Your change will cause ELF visibility failures :-). I knew it would
> > be broken by some changes. That is why I added those tests. But the ELF
> > protected visibility only works with glibc 2.2. Can we fix it please?
> 
> I assume this is directed to Alan, right?  The patch Hans-Peter
> proposed seems to be correct so in fact it is already fixed once he
> gets the OK to apply it.

Actually, I don't think it is correct.  Certainly, I shouldn't have forced
the protected symbols local, but on the other hand they do need to lose
their .plt entry, don't they?  Otherwise they won't be "protected" from
the dynamic linker binding against some other symbol.  See attached patch
for another fix, which moves the symbol hiding out of
elf_backend_hide_symbol back into elflink.h

> > > some processor-specific meaning.  But since I'm not aware of any which
> > > differs from STV_HIDDEN in this respect I think it's fine.
> > 
> > I think it is ok: [...]
> 
> I basically agreed to this but you must be aware that psABIs could
> potentially define extra semantics.  These would not be handled.  I
> don't see this anywhere near so I'm OK with the change.

In that case, the backend can provide a remove_plt_entry routine that does
whatever is required.  Hmm, perhaps remove_plt_entry should return true to
control clearing of dynindx.  I'll modify the following to do that as
well.

	* elf-bfd.h (elf_backend_data): Rename elf_backend_hide_symbol to
	elf_backend_remove_plt_entry.
	(_bfd_elf_link_hash_hide_symbol): Rename to
	_bfd_elf_link_hash_remove_plt_entry.
	* elf.c (_bfd_elf_link_hash_hide_symbol): Likewise.  Don't clear
	dynindx here.
	* elflink.h (elf_link_add_object_symbols): Instead do it here.
	(elf_link_assign_sym_version): And here.
	* elfxx-target.h (elf_backend_hide_symbol): Rename to
	elf_backend_remove_plt_entry.
	* elf32-cris.c (elf_cris_hide_symbol): Rename to
	elf_cris_remove_plt_entry.
	* elf32-hppa.c (elf32_hppa_hide_symbol): Rename to
	elf32_hppa_remove_plt_entry, and don't clear dynindx.
	(clobber_millicode_symbols): Set dynindx -1 here.
	* elf32-mips.c (_bfd_mips_elf_hide_symbol): Rename to
	_bfd_mips_elf_remove_plt_entry, and don't clear dynindx.
	*elfxx-ia64.c (elfNN_ia64_hash_hide_symbol): Rename to
	elfNN_ia64_hash_remove_plt_entry, and don't clear dynindx.

-- 
Alan Modra

Index: elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.31
diff -u -p -r1.31 elf-bfd.h
--- elf-bfd.h	2001/03/08 21:03:58	1.31
+++ elf-bfd.h	2001/04/09 00:59:48
@@ -606,9 +606,9 @@ struct elf_backend_data
   void (*elf_backend_copy_indirect_symbol)
     PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
 
-  /* Modify any information related to dynamic linking such that the
-     symbol is not exported.  */
-  void (*elf_backend_hide_symbol)
+  /* Modify any information related to the procedure linkage table
+     entry for this symbol such that the symbol is not exported.  */
+  void (*elf_backend_remove_plt_entry)
     PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
 
   /* The swapping table to use when dealing with ECOFF information.
@@ -993,7 +993,7 @@ extern struct bfd_link_hash_table *_bfd_
   PARAMS ((bfd *));
 extern void _bfd_elf_link_hash_copy_indirect
   PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
-extern void _bfd_elf_link_hash_hide_symbol
+extern void _bfd_elf_link_hash_remove_plt_entry
   PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
 extern boolean _bfd_elf_link_hash_table_init
   PARAMS ((struct elf_link_hash_table *, bfd *,
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.64
diff -u -p -r1.64 elf.c
--- elf.c	2001/03/08 21:03:58	1.64
+++ elf.c	2001/04/09 01:00:16
@@ -1002,12 +1002,11 @@ _bfd_elf_link_hash_copy_indirect (dir, i
 }
 
 void
-_bfd_elf_link_hash_hide_symbol (info, h)
+_bfd_elf_link_hash_remove_plt_entry (info, h)
      struct bfd_link_info *info ATTRIBUTE_UNUSED;
      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;
 }
 
Index: elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.83
diff -u -p -r1.83 elflink.h
--- elflink.h	2001/04/04 00:31:37	1.83
+++ elflink.h	2001/04/09 01:01:43
@@ -1947,7 +1947,8 @@ elf_link_add_object_symbols (abfd, info)
 	      case STV_INTERNAL:
 	      case STV_HIDDEN:
 		h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
-		(*bed->elf_backend_hide_symbol) (info, h);
+		h->dynindx = -1;
+		(*bed->elf_backend_remove_plt_entry) (info, h);
 		break;
 	      }
 
@@ -3525,7 +3526,7 @@ elf_fix_symbol_flags (h, eif)
     {
       struct elf_backend_data *bed;
       bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
-      (*bed->elf_backend_hide_symbol) (eif->info, h);
+      (*bed->elf_backend_remove_plt_entry) (eif->info, h);
     }
 
   /* If this is a weak defined symbol in a dynamic object, and we know
@@ -3870,7 +3871,8 @@ elf_link_assign_sym_version (h, data)
 			      && ! sinfo->export_dynamic)
 			    {
 			      h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
-			      (*bed->elf_backend_hide_symbol) (info, h);
+			      h->dynindx = -1;
+			      (*bed->elf_backend_remove_plt_entry) (info, h);
 			      /* FIXME: The name of the symbol has
 				 already been recorded in the dynamic
 				 string table section.  */
@@ -3982,7 +3984,8 @@ elf_link_assign_sym_version (h, data)
 			  && ! sinfo->export_dynamic)
 			{
 			  h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
-			  (*bed->elf_backend_hide_symbol) (info, h);
+			  h->dynindx = -1;
+			  (*bed->elf_backend_remove_plt_entry) (info, h);
 			  /* FIXME: The name of the symbol has already
 			     been recorded in the dynamic string table
 			     section.  */
@@ -4004,7 +4007,8 @@ elf_link_assign_sym_version (h, data)
 	      && ! sinfo->export_dynamic)
 	    {
 	      h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
-	      (*bed->elf_backend_hide_symbol) (info, h);
+	      h->dynindx = -1;
+	      (*bed->elf_backend_remove_plt_entry) (info, h);
 	      /* FIXME: The name of the symbol has already been
 		 recorded in the dynamic string table section.  */
 	    }
Index: elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.19
diff -u -p -r1.19 elfxx-target.h
--- elfxx-target.h	2001/03/08 21:04:01	1.19
+++ elfxx-target.h	2001/04/09 01:01:58
@@ -313,8 +313,8 @@ Foundation, Inc., 59 Temple Place - Suit
 #ifndef elf_backend_copy_indirect_symbol
 #define elf_backend_copy_indirect_symbol  _bfd_elf_link_hash_copy_indirect
 #endif
-#ifndef elf_backend_hide_symbol
-#define elf_backend_hide_symbol		_bfd_elf_link_hash_hide_symbol
+#ifndef elf_backend_remove_plt_entry
+#define elf_backend_remove_plt_entry	_bfd_elf_link_hash_remove_plt_entry
 #endif
 
 /* Previously, backends could only use SHT_REL or SHT_RELA relocation
@@ -396,7 +396,7 @@ static CONST struct elf_backend_data elf
   elf_backend_print_symbol_all,
   elf_backend_output_arch_syms,
   elf_backend_copy_indirect_symbol,
-  elf_backend_hide_symbol,
+  elf_backend_remove_plt_entry,
   elf_backend_ecoff_debug_swap,
   ELF_MACHINE_ALT1,
   ELF_MACHINE_ALT2,
Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.5
diff -u -p -r1.5 elf32-cris.c
--- elf32-cris.c	2001/03/22 14:56:06	1.5
+++ elf32-cris.c	2001/04/09 01:00:25
@@ -77,7 +77,7 @@ static boolean elf_cris_finish_dynamic_s
 	   Elf_Internal_Sym *));
 static boolean elf_cris_finish_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
-static void elf_cris_hide_symbol
+static void elf_cris_remove_plt_entry
   PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
 
 static reloc_howto_type cris_elf_howto_table [] =
@@ -1925,7 +1925,7 @@ elf_cris_adjust_gotplt_to_got (h, p)
 
    Note that this function is called before symbols are forced local by
    version scripts.  The differing cases are handled by
-   elf_cris_hide_symbol.  */
+   elf_cris_remove_plt_entry.  */
 
 static boolean
 elf_cris_try_fold_plt_to_got (h, p)
@@ -1957,18 +1957,18 @@ elf_cris_try_fold_plt_to_got (h, p)
   return true;
 }
 
-/* Our own version of hide_symbol, so that we can adjust a GOTPLT reloc
-   to use a GOT entry (and create one) rather than requiring a GOTPLT
-   entry.  */
+/* Our own version of remove_plt_entry, so that we can adjust a GOTPLT
+   reloc to use a GOT entry (and create one) rather than requiring a
+   GOTPLT entry.  */
 
 static void
-elf_cris_hide_symbol (info, h)
+elf_cris_remove_plt_entry (info, h)
      struct bfd_link_info *info;
      struct elf_link_hash_entry *h;
 {
   elf_cris_adjust_gotplt_to_got ((struct elf_cris_link_hash_entry *) h, info);
 
-  _bfd_elf_link_hash_hide_symbol (info, h);
+  _bfd_elf_link_hash_remove_plt_entry (info, h);
 }
 
 /* Adjust a symbol defined by a dynamic object and referenced by a
@@ -2985,7 +2985,7 @@ cris_elf_merge_private_bfd_data (ibfd, o
 	_bfd_elf_create_dynamic_sections
 #define bfd_elf32_bfd_final_link \
 	_bfd_elf32_gc_common_final_link
-#define elf_backend_hide_symbol			elf_cris_hide_symbol
+#define elf_backend_remove_plt_entry		elf_cris_remove_plt_entry
 
 #define elf_backend_want_got_plt	1
 #define elf_backend_plt_readonly	1
Index: elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.30
diff -u -p -r1.30 elf32-hppa.c
--- elf32-hppa.c	2001/03/21 08:09:25	1.30
+++ elf32-hppa.c	2001/04/09 01:00:39
@@ -357,7 +357,7 @@ static boolean elf32_hppa_gc_sweep_hook
   PARAMS ((bfd *, struct bfd_link_info *,
 	   asection *, const Elf_Internal_Rela *));
 
-static void elf32_hppa_hide_symbol
+static void elf32_hppa_remove_plt_entry
   PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
 
 static boolean elf32_hppa_adjust_dynamic_symbol
@@ -1855,15 +1855,14 @@ elf32_hppa_gc_sweep_hook (abfd, info, se
   return true;
 }
 
-/* Our own version of hide_symbol, so that we can keep plt entries for
-   plabels.  */
+/* Our own version of remove_plt_entry, so that we can keep plt
+   entries for plabels.  */
 
 static void
-elf32_hppa_hide_symbol (info, h)
+elf32_hppa_remove_plt_entry (info, h)
      struct bfd_link_info *info ATTRIBUTE_UNUSED;
      struct elf_link_hash_entry *h;
 {
-  h->dynindx = -1;
   if (! ((struct elf32_hppa_link_hash_entry *) h)->plabel)
     {
       h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
@@ -2146,7 +2145,10 @@ clobber_millicode_symbols (h, info)
   /* Note!  We only want to remove these from the dynamic symbol
      table.  Therefore we do not set ELF_LINK_FORCED_LOCAL.  */
   if (h->type == STT_PARISC_MILLI)
-    elf32_hppa_hide_symbol (info, h);
+    {
+      elf32_hppa_remove_plt_entry (info, h);
+      h->dynindx = -1;
+    }
   return true;
 }
 
@@ -4306,7 +4308,7 @@ elf32_hppa_elf_get_symbol_type (elf_sym,
 #define elf_backend_create_dynamic_sections  elf32_hppa_create_dynamic_sections
 #define elf_backend_fake_sections	     elf_hppa_fake_sections
 #define elf_backend_relocate_section	     elf32_hppa_relocate_section
-#define elf_backend_hide_symbol		     elf32_hppa_hide_symbol
+#define elf_backend_remove_plt_entry	     elf32_hppa_remove_plt_entry
 #define elf_backend_finish_dynamic_symbol    elf32_hppa_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections  elf32_hppa_finish_dynamic_sections
 #define elf_backend_size_dynamic_sections    elf32_hppa_size_dynamic_sections
Index: elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.91
diff -u -p -r1.91 elf32-mips.c
--- elf32-mips.c	2001/04/08 05:11:48	1.91
+++ elf32-mips.c	2001/04/09 01:01:13
@@ -3982,7 +3982,7 @@ mips_elf_link_hash_newfunc (entry, table
 }
 
 void
-_bfd_mips_elf_hide_symbol (info, h)
+_bfd_mips_elf_remove_plt_entry (info, h)
      struct bfd_link_info *info;
      struct mips_elf_link_hash_entry *h;
 {
@@ -3995,7 +3995,6 @@ _bfd_mips_elf_hide_symbol (info, h)
 
   h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
   h->root.plt.offset = (bfd_vma) -1;
-  h->root.dynindx = -1;
 
   /* FIXME: Do we allocate too much GOT space here?  */
   g->local_gotno++;
@@ -9381,7 +9380,7 @@ static const struct ecoff_debug_swap mip
 #define elf_backend_copy_indirect_symbol \
 					_bfd_mips_elf_copy_indirect_symbol
 
-#define elf_backend_hide_symbol		_bfd_mips_elf_hide_symbol
+#define elf_backend_remove_plt_entry	_bfd_mips_elf_remove_plt_entry
 
 #define bfd_elf32_bfd_is_local_label_name \
 					mips_elf_is_local_label_name
Index: elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.14
diff -u -p -r1.14 elfxx-ia64.c
--- elfxx-ia64.c	2001/02/27 03:26:47	1.14
+++ elfxx-ia64.c	2001/04/09 01:01:57
@@ -1514,7 +1514,7 @@ elfNN_ia64_hash_copy_indirect (xdir, xin
 }
 
 static void
-elfNN_ia64_hash_hide_symbol (info, xh)
+elfNN_ia64_hash_remove_plt_entry (info, xh)
      struct bfd_link_info *info ATTRIBUTE_UNUSED;
      struct elf_link_hash_entry *xh;
 {
@@ -1524,7 +1524,6 @@ elfNN_ia64_hash_hide_symbol (info, xh)
   h = (struct elfNN_ia64_link_hash_entry *)xh;
 
   h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
-  h->root.dynindx = -1;
 
   for (dyn_i = h->info; dyn_i; dyn_i = dyn_i->next)
     dyn_i->want_plt2 = 0;
@@ -4362,7 +4361,7 @@ elfNN_ia64_print_private_bfd_data (abfd,
 #define elf_backend_default_use_rela_p	1
 #define elf_backend_want_dynbss		0
 #define elf_backend_copy_indirect_symbol elfNN_ia64_hash_copy_indirect
-#define elf_backend_hide_symbol		elfNN_ia64_hash_hide_symbol
+#define elf_backend_remove_plt_entry	elfNN_ia64_hash_remove_plt_entry
 
 #include "elfNN-target.h"
 



More information about the Binutils mailing list