It is ok to have undefined hidden symbols in a .o file

H . J . Lu hjl@valinux.com
Mon Jun 5 12:59:00 GMT 2000


Where there are

1. foo is undefined, hidden in bar.o
2. foo is defined in foo.o.

both

# gcc -shared -o libfoo.so bar.o foo.o
# gcc -shared -o libfoo.so foo.o bar.o

should work. This patch fixes it. I'd like to check it in if it
is ok with everyone.


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

	* elflink.c (_bfd_elf_link_record_dynamic_symbol): Don't flag
	an error when seeing an undefined symbol with hidden/internal
	attributes. It is handled in *_relocate_section ().

Index: elflink.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.c,v
retrieving revision 1.4
diff -u -p -r1.4 elflink.c
--- elflink.c	2000/05/30 19:32:42	1.4
+++ elflink.c	2000/06/05 19:50:49
@@ -226,21 +226,8 @@ _bfd_elf_link_record_dynamic_symbol (inf
 	{
 	case STV_INTERNAL:
 	case STV_HIDDEN:
-	  /* This symbol must be defined in the shared object or
-	     executable.  */
-	  if (h->root.type == bfd_link_hash_undefined)
-	    {
-	      bfd * abfd = h->root.u.undef.abfd;
-	      const char * name = h->root.root.string;
-	      
-	      (*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);
-	    }
-	  else if (h->root.type != bfd_link_hash_undefweak)
+	  if (h->root.type != bfd_link_hash_undefined
+	      && h->root.type != bfd_link_hash_undefweak)
 	    {
 	      h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
 	      return true;


More information about the Binutils mailing list