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]
Other format: [Raw text]

powerpc64-linux shared lib fix.


Hi Stuart,
  Looking at the dynamic syms exported by libjvm_g.so, I see

$ powerpc64-linux-readelf -s -D other/libjvm_g.so | grep stat
  296 271: 000000000033c1c0    60    FUNC   WEAK DEFAULT  10 .stat
  3465 1037: 0000000000267408    60    FUNC GLOBAL DEFAULT  10 .staticUpdate
  1093 1221: 00000000003b4858    24  NOTYPE GLOBAL DEFAULT  15 staticUpdate
  1064 1596: 00000000003dce48     8  OBJECT GLOBAL DEFAULT  24 statsExit
  2412 1598: 000000000033c1c0    60    FUNC GLOBAL DEFAULT  10 .__stat
  290 1852: 0000000000000000    24  NOTYPE GLOBAL DEFAULT UND __xstat

We have a function sym, ".stat", exported from the shared lib without
a corresponding function descriptor sym, "stat".  That's Bad.

The second hunk of this patch should fix the problem.  The first hunk
is just a tidy-up.

	* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Don't copy is_func
	and is_func_descriptor.
	(func_desc_adjust): Hide function code sym in shared libs unless
	there is a matching exported function descriptor sym.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.43
diff -u -p -r1.43 elf64-ppc.c
--- bfd/elf64-ppc.c	22 May 2002 04:22:08 -0000	1.43
+++ bfd/elf64-ppc.c	24 May 2002 03:52:51 -0000
@@ -2583,8 +2583,11 @@ ppc64_elf_copy_indirect_symbol (dir, ind
       eind->dyn_relocs = NULL;
     }
 
-  edir->is_func |= eind->is_func;
-  edir->is_func_descriptor |= eind->is_func_descriptor;
+  /* We don't need to copy is_func and is_func_descriptor;  They're
+     never set when copy_indirect_symbol is called for indirect
+     symbols at the add_symbols stage of linking, and they're not
+     relevant when copy_indirect_symbol is called for weakdefs.
+     weakdefs are only held for non-function syms.  */
 
   _bfd_elf_link_hash_copy_indirect (dir, ind);
 }
@@ -3236,8 +3239,14 @@ func_desc_adjust (h, inf)
 	 been imported from another library.  Function code syms that
 	 are really in the library we must leave global to prevent the
 	 linker dragging in a definition from a static library.  */
-      force_local = ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
-		     && info->shared);
+      force_local = (info->shared
+		     && ((h->elf_link_hash_flags
+			  & ELF_LINK_HASH_DEF_REGULAR) == 0
+			 || fdh == NULL
+			 || (fdh->elf_link_hash_flags
+			     & ELF_LINK_HASH_DEF_REGULAR) == 0
+			 || (fdh->elf_link_hash_flags
+			     & ELF_LINK_FORCED_LOCAL) != 0));
       _bfd_elf_link_hash_hide_symbol (info, h, force_local);
     }
 

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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