public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Move weak definitions to DSOs for ld weak tests.
@ 2001-09-13 10:35 H . J . Lu
  2001-09-17  8:13 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: H . J . Lu @ 2001-09-13 10:35 UTC (permalink / raw)
  To: binutils

It turns out that I have to move weak definitions to DSOs since ld.so
may not be involved at all for the references in the executable to weak
symbols defined in the executable. I'd like to check in this patch to
test the weak definitions in DSOs.


H.J.
----
2001-09-13  H.J. Lu  <hjl@gnu.org>

	* ld-elfweak/foo1c.c: New.

	* ld-elfweak/main.c (foo): Remove weak defintion.
	* ld-elfweak/main1.c (deallocate_foo): Likewise.

	* ld-elfweak/weakdata.dsym: Updated.

	* ld-elfweak/elfweak.exp (build_exec): Take dumpname for the
	object name to dump.
	Move weak definitions to DSOs.

Index: ld-elfweak/elfweak.exp
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/testsuite/ld-elfweak/elfweak.exp,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 elfweak.exp
--- ld-elfweak/elfweak.exp	2001/09/11 18:16:55	1.1.1.2
+++ ld-elfweak/elfweak.exp	2001/09/13 17:25:50
@@ -291,7 +291,7 @@ proc build_lib {test libname objs dynsym
     pass $test
 }
 
-proc build_exec { test execname objs flags dat dynsymexp symexp} {
+proc build_exec { test execname dumpname objs flags dat dynsymexp symexp} {
     global ld
     global objdump
     global tmpdir
@@ -311,14 +311,14 @@ proc build_exec { test execname objs fla
     }
 
     if {![string match "" $dynsymexp]} then {
-        if {![objdump_dynsymstuff $objdump $tmpdir/$execname $srcdir/$subdir/$dynsymexp]} {
+        if {![objdump_dynsymstuff $objdump $tmpdir/$dumpname $srcdir/$subdir/$dynsymexp]} {
 	    fail $test
 	    return
 	}
     }
 
     if {![string match "" $symexp]} then {
-        if {![objdump_symstuff $objdump $tmpdir/$execname $srcdir/$subdir/$symexp]} {
+        if {![objdump_symstuff $objdump $tmpdir/$dumpname $srcdir/$subdir/$symexp]} {
 	    fail $test
 	    return
 	}
@@ -404,6 +404,11 @@ if ![ld_compile "$CC $CFLAGS $picflag" $
     return
 }
 
+if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/foo1c.c $tmpdir/foo1c.o] {
+    unresolved "ELF weak"
+    return
+}
+
 if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o] {
     unresolved "ELF weak"
     return
@@ -434,18 +439,28 @@ if {![ld_link $ld $tmpdir/libfoo1b.so "$
     return
 }
 
+if {![ld_link $ld $tmpdir/libfoo1c.so "$shared $tmpdir/foo1c.o tmpdir/libbar.so"]} {
+    fail "ELF weak"
+    return
+}
+
+if {![ld_link $ld $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} {
+    fail "ELF weak"
+    return
+}
+
 build_lib "ELF DSO weak func first" libfoo "foo.o bar.o" dso.dsym
 build_lib "ELF DSO weak func last" libfoo "bar.o foo.o" dso.dsym
 setup_xfail "*-*-*"
 build_lib "ELF DSO weak func first DSO" libfoo "foo.o libbar.so" dsow.dsym
 setup_xfail "*-*-*"
 build_lib "ELF DSO weak func last DSO" libfoo "libbar.so foo.o" dsow.dsym
-build_exec "ELF weak func first" foo "main.o bar.o" "" strong "" strong.sym
-build_exec "ELF weak func last" foo "bar.o main.o" "" strong "" strong.sym
+build_exec "ELF weak func first" foo foo "main.o bar.o" "" strong "" strong.sym
+build_exec "ELF weak func last" foo foo "bar.o main.o" "" strong "" strong.sym
 setup_xfail "*-*-*"
-build_exec "ELF weak func first DSO" foo "main.o libbar.so" "-rpath ." weak weak.dsym ""
+build_exec "ELF weak func first DSO" foo libfoo1c.so "main.o libfoo1c.so libbar.so" "-rpath ." weak weak.dsym ""
 setup_xfail "*-*-*"
-build_exec "ELF weak func last DSO" foo "libbar.so main.o" "-rpath ." weak weak.dsym ""
+build_exec "ELF weak func last DSO" foo libfoo1c.so "libbar.so libfoo1c.so main.o" "-rpath ." weak weak.dsym ""
 
 build_lib "ELF DSO weak data first" libfoo "bar1a.o foo1a.o" dsodata.dsym
 build_lib "ELF DSO weak data last" libfoo "foo1a.o bar1a.o" dsodata.dsym
@@ -457,15 +472,15 @@ setup_xfail "*-*-*"
 build_lib "ELF DSO weak data first DSO common" libfoo "bar1a.o libfoo1b.so" dsowdata.dsym
 setup_xfail "*-*-*"
 build_lib "ELF DSO weak data last DSO common" libfoo "libfoo1b.so bar1a.o" dsowdata.dsym
-build_exec "ELF weak data first" foo "main1.o bar1a.o foo1a.o" "" strongdata "" strongdata.sym
-build_exec "ELF weak data last" foo "foo1a.o main1.o bar1a.o" "" strongdata "" strongdata.sym
-build_exec "ELF weak data first common" foo "main1.o bar1a.o foo1b.o" "" strongdata "" strongcomm.sym
-build_exec "ELF weak data last common" foo "foo1b.o main1.o bar1a.o" "" strongdata "" strongcomm.sym
+build_exec "ELF weak data first" foo foo "main1.o bar1a.o foo1a.o" "" strongdata "" strongdata.sym
+build_exec "ELF weak data last" foo foo "foo1a.o main1.o bar1a.o" "" strongdata "" strongdata.sym
+build_exec "ELF weak data first common" foo foo "main1.o bar1a.o foo1b.o" "" strongdata "" strongcomm.sym
+build_exec "ELF weak data last common" foo foo "foo1b.o main1.o bar1a.o" "" strongdata "" strongcomm.sym
 setup_xfail "*-*-*"
-build_exec "ELF weak data first DSO" foo "main1.o bar1a.o libfoo1a.so" "-rpath ." weakdata weakdata.dsym ""
+build_exec "ELF weak data first DSO" foo libbar1a.so "main1.o libbar1a.so libfoo1a.so" "-rpath ." weakdata weakdata.dsym ""
 setup_xfail "*-*-*"
-build_exec "ELF weak data last DSO" foo "libfoo1a.so main1.o bar1a.o" "-rpath ." weakdata weakdata.dsym ""
+build_exec "ELF weak data last DSO" foo libbar1a.so "libfoo1a.so main1.o libbar1a.so" "-rpath ." weakdata weakdata.dsym ""
 setup_xfail "*-*-*"
-build_exec "ELF weak data first DSO common" foo "main1.o bar1a.o libfoo1b.so" "-rpath ." weakdata weakdata.dsym ""
+build_exec "ELF weak data first DSO common" foo libbar1a.so "main1.o libbar1a.so libfoo1b.so" "-rpath ." weakdata weakdata.dsym ""
 setup_xfail "*-*-*"
-build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o bar1a.o" "-rpath ." weakdata weakdata.dsym ""
+build_exec "ELF weak data last DSO common" foo libbar1a.so "libfoo1b.so main1.o libbar1a.so" "-rpath ." weakdata weakdata.dsym ""
Index: ld-elfweak/main.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/testsuite/ld-elfweak/main.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 main.c
--- ld-elfweak/main.c	2001/09/10 17:18:24	1.1.1.1
+++ ld-elfweak/main.c	2001/09/13 17:25:50
@@ -1,14 +1,6 @@
 #include <stdio.h>
 
-#pragma weak foo
-
 extern void foo ();
-
-void
-foo ()
-{
-  printf ("weak foo\n");
-}
 
 int
 main ()
Index: ld-elfweak/main1.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/testsuite/ld-elfweak/main1.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 main1.c
--- ld-elfweak/main1.c	2001/09/11 18:16:56	1.1.1.1
+++ ld-elfweak/main1.c	2001/09/13 17:25:50
@@ -1,7 +1,6 @@
 #include <stdio.h>
 
-#pragma weak deallocate_foo
-int deallocate_foo = 1;
+extern int deallocate_foo;
 
 extern int * bar ();
 extern int * foo ();
Index: ld-elfweak/weakdata.dsym
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/testsuite/ld-elfweak/weakdata.dsym,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 weakdata.dsym
--- ld-elfweak/weakdata.dsym	2001/09/11 18:16:56	1.1.1.1
+++ ld-elfweak/weakdata.dsym	2001/09/13 17:25:50
@@ -1,2 +1 @@
 [0-9a-f]*[ 	]+w[ 	]+DO[ 	]+.data[	]+[0-9a-f]*[ 	]+(Base[ 	]+|[ 	]*)deallocate_foo
-[0-9a-f]*[ 	]+DF[ 	]+\*UND\*[	]+[0-9a-f]*[ 	]+(Base[ 	]+|[ 	]*)foo
--- /dev/null	Fri Mar 23 20:37:44 2001
+++ ld-elfweak/foo1c.c	Thu Sep 13 09:59:58 2001
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+#pragma weak foo
+
+extern void foo ();
+
+void
+foo ()
+{
+  printf ("weak foo\n");
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: Move weak definitions to DSOs for ld weak tests.
  2001-09-13 10:35 PATCH: Move weak definitions to DSOs for ld weak tests H . J . Lu
@ 2001-09-17  8:13 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2001-09-17  8:13 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils

Hi H.J.

> 2001-09-13  H.J. Lu  <hjl@gnu.org>
> 
> 	* ld-elfweak/foo1c.c: New.
> 
> 	* ld-elfweak/main.c (foo): Remove weak defintion.
> 	* ld-elfweak/main1.c (deallocate_foo): Likewise.
> 
> 	* ld-elfweak/weakdata.dsym: Updated.
> 
> 	* ld-elfweak/elfweak.exp (build_exec): Take dumpname for the
> 	object name to dump.
> 	Move weak definitions to DSOs.

Approved.

Cheers
        Nick

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-09-17  8:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-13 10:35 PATCH: Move weak definitions to DSOs for ld weak tests H . J . Lu
2001-09-17  8:13 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).