Submitted By: Ken Moffat <ken at linuxfromscratch dot org>
Date: 2006-07-22
Initial Package Version: 2.17
Origin: Jakub Jelinek, http://sourceware.org/ml/binutils/2004-08/msg00030.html
Upstream Status: unknown
Description: Fixes ld visibility errors on ppc64, rediffed to apply with -p1.  The original was for a much earlier version of binutils, but still applies.  I couldn't find why this wasn't committed, but at the time it only fixed some of the failures he was seeing.

diff -Naur binutils-2.17vanilla/ld/testsuite/ld-elfvsb/elfvsb.exp binutils-2.17/ld/testsuite/ld-elfvsb/elfvsb.exp
--- binutils-2.17vanilla/ld/testsuite/ld-elfvsb/elfvsb.exp	2005-05-12 08:32:06.000000000 +0100
+++ binutils-2.17/ld/testsuite/ld-elfvsb/elfvsb.exp	2006-07-22 20:19:41.000000000 +0100
@@ -315,8 +315,8 @@
 
 	# Now compile the code using -fpic.
 
-	if { ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o] 
-	    || ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
+	if { ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG -DSHARED $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o] 
+	    || ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG -DSHARED $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
 	    unresolved "visibility ($visibility)"
 	} else {
 	    if { [ string match $visibility "protected" ]
@@ -337,7 +337,7 @@
     }
 
     # Now do the same tests again, but this time compile main.c PIC.
-    if ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
+    if ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG -DSHARED $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
 	unresolved "visibility ($visibility) (PIC main, non PIC so)"
 	unresolved "visibility ($visibility) (PIC main)"
     } else {
@@ -446,7 +446,7 @@
 if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
     unresolved "weak hidden symbol"
 } else {
-   if { ![ld_compile "$CC -g $CFLAGS $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
+   if { ![ld_compile "$CC -g $CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
 	unresolved "weak hidden symbol"
     } else {
 	if ![ld_simple_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
diff -Naur binutils-2.17vanilla/ld/testsuite/ld-elfvsb/sh1.c binutils-2.17/ld/testsuite/ld-elfvsb/sh1.c
--- binutils-2.17vanilla/ld/testsuite/ld-elfvsb/sh1.c	2003-05-05 06:46:53.000000000 +0100
+++ binutils-2.17/ld/testsuite/ld-elfvsb/sh1.c	2006-07-22 20:19:41.000000000 +0100
@@ -13,7 +13,11 @@
 /* This variable is defined in the shared library, and overridden by
    the main program.  */
 #ifndef XCOFF_TEST
+#ifdef SHARED
 int overriddenvar = -1;
+#else
+extern int overriddenvar;
+#endif
 #endif
 
 /* This variable is defined in the shared library.  */
@@ -76,12 +80,14 @@
   return shlib_overriddencall2 ();
 }
 
+#ifdef SHARED
 int
 shlib_overriddencall2 ()
 {
   return 7;
 }
 #endif
+#endif
 
 /* This function calls a function defined by the main program.  */
 
diff -Naur binutils-2.17vanilla/ld/testsuite/ld-elfvsb/sh2.c binutils-2.17/ld/testsuite/ld-elfvsb/sh2.c
--- binutils-2.17vanilla/ld/testsuite/ld-elfvsb/sh2.c	2003-04-28 04:31:36.000000000 +0100
+++ binutils-2.17/ld/testsuite/ld-elfvsb/sh2.c	2006-07-22 20:19:41.000000000 +0100
@@ -44,3 +44,13 @@
   return 2;
 }
 #endif
+
+#if !defined (XCOFF_TEST) && !defined (SHARED)
+int overriddenvar = -1;
+
+int
+shlib_overriddencall2 ()
+{
+  return 7;
+}
+#endif
