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]

[PATCH] Fix some ld-elfvsb on ppc64/gcc3.4


Hi!

When not using -fpic/-fPIC, we really can't expect overriding to work
if there is definition in the same source file.  GCC assumes a symbol
in the executable can't be overridden (maybe it would be better to
have separate GCC switches for flag_shlib and flag_pic).
On PPC64 this means that GCC can avoid the nop after bl .shlib_overriddencall2
in shlib_shlibcall2 routine.

Ok to commit?

I still get
FAIL: visibility (hidden_undef_def) (non PIC)
FAIL: visibility (hidden_undef_def) (non PIC, load offset)
FAIL: visibility (hidden_undef_def)
FAIL: visibility (hidden_undef_def) (PIC main, non PIC so)
FAIL: visibility (hidden_undef_def) (PIC main)
failures on ppc64 when using gcc 3.4 (and not when using gcc 3.3).
The problem is that ld doesn't report undefined reference to
`visibility_func', just visibility{,_def,_var}.
The difference in generated assembly is:
grep -w visibility_func ld/tmpdir/mainnp.s*
ld/tmpdir/mainnp.s-gcc.3.3:     .hidden visibility_func
ld/tmpdir/mainnp.s-gcc.3.3:     .tc visibility_func[TC],visibility_func
ld/tmpdir/mainnp.s-gcc.3.3:     bl .visibility_func
ld/tmpdir/mainnp.s-gcc.3.4:     .hidden visibility_func
ld/tmpdir/mainnp.s-gcc.3.4:     bl .visibility_func

2004-08-03  Jakub Jelinek  <jakub@redhat.com>

	* ld-elfvsb/sh1.c (overriddenvar, shlib_overriddencall2): If
	!SHARED, move to...
	* ld-elfvsb/sh2.c: ... here.
	* ld-elfvsb/elfvsb.exp: Add -DSHARED to compiler options when building
	{sh[123],main}.c with $picflag.

--- ld/testsuite/ld-elfvsb/sh1.c.jj	2003-05-05 17:46:50.000000000 -0400
+++ ld/testsuite/ld-elfvsb/sh1.c	2004-08-03 13:15:48.000000000 -0400
@@ -13,7 +13,11 @@ extern int mainvar;
 /* 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 @@ shlib_shlibcall2 ()
   return shlib_overriddencall2 ();
 }
 
+#ifdef SHARED
 int
 shlib_overriddencall2 ()
 {
   return 7;
 }
 #endif
+#endif
 
 /* This function calls a function defined by the main program.  */
 
--- ld/testsuite/ld-elfvsb/elfvsb.exp.jj	2004-05-27 14:26:05.000000000 -0400
+++ ld/testsuite/ld-elfvsb/elfvsb.exp	2004-08-03 13:13:40.000000000 -0400
@@ -315,8 +315,8 @@ proc visibility_run {visibility} {
 
 	# 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 @@ proc visibility_run {visibility} {
     }
 
     # 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" $srcd
 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"] {
--- ld/testsuite/ld-elfvsb/sh2.c.jj	2003-05-05 17:46:50.000000000 -0400
+++ ld/testsuite/ld-elfvsb/sh2.c	2004-08-03 13:14:22.000000000 -0400
@@ -44,3 +44,13 @@ visibility_func_weak ()
   return 2;
 }
 #endif
+
+#if !defined (XCOFF_TEST) && !defined (SHARED)
+int overriddenvar = -1;
+
+int
+shlib_overriddencall2 ()
+{
+  return 7;
+}
+#endif

	Jakub


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