This is the mail archive of the binutils@sourceware.cygnus.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 visibility.


On Mon, May 22, 2000 at 01:20:21PM -0700, Ulrich Drepper wrote:
> Martin von Loewis <loewis@informatik.hu-berlin.de> writes:
> 
> > The ABI says
> 
> Martin, you can stop arguing.  Visibility on undefined references make
> no sense.  Both HJ and I were there when this extension was designed
> and decided.  And just to be sure we asked today for clarification.
> Any future comment is just noise.  The patch seems to do the right
> thing and the intent is to not have any of the bits set for undefined
> references.
> 

This patch implements undefined symbols with the non-default
visibility attributes for ia32. I will add it to others if it is
ok with everyone. However, weak undefined symbols with hidden and
internal only work with the current glibc 2.2. I will send a patch
for glibc 2.1 later.


H.J.
-- 
H.J. Lu (hjl@gnu.org)
---
2000-05-22  H.J. Lu  <hjl@gnu.org>

	* elf32-i386.c (elf_i386_relocate_section): Don't allow the
	undefined symbol with the non-default visibility attributes.

	* elflink.c (_bfd_elf_link_record_dynamic_symbol): Correctly
	handle weak undefined symbols with hidden and internal
	attributes.

	* elflink.h (elf_link_output_extsym): Clear the visibility
	attributes and the ELF_LINK_FORCED_LOCAL bit for symbols
	not locally defined.

Index: elf32-i386.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf32-i386.c,v
retrieving revision 1.13
diff -u -p -r1.13 elf32-i386.c
--- elf32-i386.c	2000/05/02 17:23:17	1.13
+++ elf32-i386.c	2000/05/22 21:26:04
@@ -1390,14 +1390,17 @@ elf_i386_relocate_section (output_bfd, i
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic && !info->no_undefined)
+	  else if (info->shared && !info->symbolic
+		   && !info->no_undefined
+		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
 	  else
 	    {
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined))))
+		      (!info->shared || info->no_undefined
+		       || ELF_ST_VISIBILITY (h->other)))))
 		return false;
 	      relocation = 0;
 	    }
Index: elflink.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.c,v
retrieving revision 1.3
diff -u -p -r1.3 elflink.c
--- elflink.c	2000/05/02 17:23:17	1.3
+++ elflink.c	2000/05/22 23:11:14
@@ -235,10 +235,17 @@ _bfd_elf_link_record_dynamic_symbol (inf
 	      
 	      (*info->callbacks->undefined_symbol)
 		(info, name, abfd, bfd_und_section_ptr, 0, true);
+
+	      /* We have flaged a fatal error. We now treat this as
+	         a normal symbol to avoid further error messages. */
+	      h->other ^= ELF_ST_VISIBILITY (h->other);
 	    }
-	  
-	  h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
-	  return true;
+	  else
+	    {
+	      h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+	      if (h->root.type != bfd_link_hash_undefweak)
+		return true;
+	    }
 
 	default:
 	  break;
Index: elflink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.h,v
retrieving revision 1.28
diff -u -p -r1.28 elflink.h
--- elflink.h	2000/05/22 16:24:25	1.28
+++ elflink.h	2000/05/22 22:53:10
@@ -4895,6 +4895,15 @@ elf_link_output_extsym (h, data)
   Elf_Internal_Sym sym;
   asection *input_sec;
 
+  /* If a symbol is not defined locally, we clear the visibility
+     field and the ELF_LINK_FORCED_LOCAL bit. */
+  if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+      && ELF_ST_VISIBILITY(h->other))
+    {
+      h->elf_link_hash_flags &= ~ELF_LINK_FORCED_LOCAL;
+      h->other ^= ELF_ST_VISIBILITY(h->other);
+    }
+
   /* Decide whether to output this symbol in this pass.  */
   if (eoinfo->localsyms)
     {
@@ -5088,11 +5097,6 @@ elf_link_output_extsym (h, data)
 	bindtype = STB_WEAK;
       sym.st_info = ELF_ST_INFO (bindtype, ELF_ST_TYPE (sym.st_info));
     }
-
-  /* If a symbol is not defined locally, we clear the visibility
-     field. */
-  if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
-    sym.st_other ^= ELF_ST_VISIBILITY(sym.st_other);
 
   /* If this symbol should be put in the .dynsym section, then put it
      there now.  We have already know the symbol index.  We also fill

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