A new visibility patch

H . J . Lu hjl@valinux.com
Sat May 20 22:59:00 GMT 2000


This patch tries to ensure we only set ELF_ST_VISIBILITY in the
binary where the symbol is defined. Martin, any comments?


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

	* elflink.h (elf_link_output_extsym): Clear the visibility
	field for symbols not defined locally.

Index: elflink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.h,v
retrieving revision 1.26
diff -u -p -r1.26 elflink.h
--- elflink.h	2000/05/18 22:10:35	1.26
+++ elflink.h	2000/05/21 05:54:31
@@ -5089,6 +5089,13 @@ elf_link_output_extsym (h, data)
       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 (sym.st_shndx == SHN_UNDEF
+      || ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+	   && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_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
      in the entry in the .hash section.  */


More information about the Binutils mailing list