This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: A patch for elflink.h


On Fri, Apr 27, 2001 at 10:31:21AM -0700, H . J . Lu wrote:
> Thanks for the bug report. I believe this patch fixes it. I will check
> it in shortly and I will make binutils 2.11.90.0.7 this weekend. I am
> also enclosing a testcase here.
> 
> 
> H.J.
> ----
> 2001-04-27  H.J. Lu  <hjl@gnu.org>
> 
> 	* elflink.h (elf_fix_symbol_flags): Hide a symbol if and only
> 	if the symbol has hidden or internal visibility.
> 

The above patch won't work for hppa. Here is a new one. Any comments?
I'd like to chek it in today.

Thanks.


H.J.
----
2001-04-27  H.J. Lu  <hjl@gnu.org>

	* elf.c (_bfd_elf_link_hash_hide_symbol): Set dynindx to -1
	only for ELF_LINK_FORCED_LOCAL.
	* elf32-hppa.c (elf32_hppa_hide_symbol): Likewise.
	* elf32-mips.c (_bfd_mips_elf_hide_symbol): Likewise.
	* elfxx-ia64.c (elfNN_ia64_hash_hide_symbol): Likewise.

	* elflink.h (elf_fix_symbol_flags): Set ELF_LINK_FORCED_LOCAL
	if the symbol has hidden or internal visibility.

Index: elf.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf.c,v
retrieving revision 1.50
diff -u -p -r1.50 elf.c
--- elf.c	2001/04/24 16:28:53	1.50
+++ elf.c	2001/04/27 18:45:09
@@ -1014,8 +1014,9 @@ _bfd_elf_link_hash_hide_symbol (info, h)
      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;
+  if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+    h->dynindx = -1;
 }
 
 /* Initialize an ELF linker hash table.  */
Index: elf32-hppa.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf32-hppa.c,v
retrieving revision 1.22
diff -u -p -r1.22 elf32-hppa.c
--- elf32-hppa.c	2001/03/23 22:37:30	1.22
+++ elf32-hppa.c	2001/04/27 18:45:09
@@ -1863,7 +1863,8 @@ elf32_hppa_hide_symbol (info, h)
      struct bfd_link_info *info ATTRIBUTE_UNUSED;
      struct elf_link_hash_entry *h;
 {
-  h->dynindx = -1;
+  if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+    h->dynindx = -1;
   if (! ((struct elf32_hppa_link_hash_entry *) h)->plabel)
     {
       h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
Index: elf32-mips.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf32-mips.c,v
retrieving revision 1.25
diff -u -p -r1.25 elf32-mips.c
--- elf32-mips.c	2001/04/24 16:28:54	1.25
+++ elf32-mips.c	2001/04/27 18:45:10
@@ -4002,7 +4002,8 @@ _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;
+  if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+    h->root.dynindx = -1;
 
   /* FIXME: Do we allocate too much GOT space here?  */
   g->local_gotno++;
Index: elflink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.h,v
retrieving revision 1.56
diff -u -p -r1.56 elflink.h
--- elflink.h	2001/04/13 18:47:22	1.56
+++ elflink.h	2001/04/27 18:45:10
@@ -3553,6 +3553,9 @@ elf_fix_symbol_flags (h, eif)
     {
       struct elf_backend_data *bed;
       bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
+      if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
+	  || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
+	h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
       (*bed->elf_backend_hide_symbol) (eif->info, h);
     }
 
Index: elfxx-ia64.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elfxx-ia64.c,v
retrieving revision 1.6
diff -u -p -r1.6 elfxx-ia64.c
--- elfxx-ia64.c	2001/02/27 04:54:09	1.6
+++ elfxx-ia64.c	2001/04/27 18:45:10
@@ -1524,7 +1524,8 @@ 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;
+  if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+    h->root.dynindx = -1;
 
   for (dyn_i = h->info; dyn_i; dyn_i = dyn_i->next)
     dyn_i->want_plt2 = 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]