2001-09-11 H.J. Lu <hjl@gnu.org>
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 11 Sep 2001 14:25:16 +0000 (14:25 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 11 Sep 2001 14:25:16 +0000 (14:25 +0000)
* ld-elfweak/elfweak.exp (build_lib): Take a list of object
files.
(build_exec): Likewise.
Add more tests and make some xfail.

* ld-elfweak/dso.dsym: Support symbol versioning.
* ld-elfweak/dsow.dsym: Likewise.

* ld-elfweak/main1.c: New.
* ld-elfweak/bar1a.c: Likewise.
* ld-elfweak/bar1b.c: Likewise.
* ld-elfweak/bar1c.c: Likewise.
* ld-elfweak/foo1a.c: Likewise.
* ld-elfweak/foo1b.c: Likewise.
* ld-elfweak/dsodata.dsym: Likewise.
* ld-elfweak/dsowdata.dsym: Likewise.
* ld-elfweak/weakdata.dsym: Likewise.
* ld-elfweak/strongcomm.sym: Likewise.
* ld-elfweak/strongdata.sym: Likewise.
* ld-elfweak/weakdata.dat: Likewise.
* ld-elfweak/strongdata.dat: Likewise.

17 files changed:
ld/testsuite/ChangeLog
ld/testsuite/ld-elfweak/bar1a.c [new file with mode: 0644]
ld/testsuite/ld-elfweak/bar1b.c [new file with mode: 0644]
ld/testsuite/ld-elfweak/bar1c.c [new file with mode: 0644]
ld/testsuite/ld-elfweak/dso.dsym
ld/testsuite/ld-elfweak/dsodata.dsym [new file with mode: 0644]
ld/testsuite/ld-elfweak/dsow.dsym
ld/testsuite/ld-elfweak/dsowdata.dsym [new file with mode: 0644]
ld/testsuite/ld-elfweak/elfweak.exp
ld/testsuite/ld-elfweak/foo1a.c [new file with mode: 0644]
ld/testsuite/ld-elfweak/foo1b.c [new file with mode: 0644]
ld/testsuite/ld-elfweak/main1.c [new file with mode: 0644]
ld/testsuite/ld-elfweak/strongcomm.sym [new file with mode: 0644]
ld/testsuite/ld-elfweak/strongdata.dat [new file with mode: 0644]
ld/testsuite/ld-elfweak/strongdata.sym [new file with mode: 0644]
ld/testsuite/ld-elfweak/weakdata.dat [new file with mode: 0644]
ld/testsuite/ld-elfweak/weakdata.dsym [new file with mode: 0644]

index 80136d319a2c65c03e4064a594b4feaacfa37172..72e9cff40c9673d988a48708130a77ef2881f657 100644 (file)
@@ -1,3 +1,27 @@
+2001-09-11  H.J. Lu  <hjl@gnu.org>
+
+       * ld-elfweak/elfweak.exp (build_lib): Take a list of object
+       files.
+       (build_exec): Likewise.
+       Add more tests and make some xfail.
+
+       * ld-elfweak/dso.dsym: Support symbol versioning.
+       * ld-elfweak/dsow.dsym: Likewise.
+
+       * ld-elfweak/main1.c: New.
+       * ld-elfweak/bar1a.c: Likewise.
+       * ld-elfweak/bar1b.c: Likewise.
+       * ld-elfweak/bar1c.c: Likewise.
+       * ld-elfweak/foo1a.c: Likewise.
+       * ld-elfweak/foo1b.c: Likewise.
+       * ld-elfweak/dsodata.dsym: Likewise.
+       * ld-elfweak/dsowdata.dsym: Likewise.
+       * ld-elfweak/weakdata.dsym: Likewise.
+       * ld-elfweak/strongcomm.sym: Likewise.
+       * ld-elfweak/strongdata.sym: Likewise.
+       * ld-elfweak/weakdata.dat: Likewise.
+       * ld-elfweak/strongdata.dat: Likewise.
+
 2001-09-10  H.J. Lu  <hjl@gnu.org>
 
        * ld-elfweak/elfweak.exp: New.
diff --git a/ld/testsuite/ld-elfweak/bar1a.c b/ld/testsuite/ld-elfweak/bar1a.c
new file mode 100644 (file)
index 0000000..7ca1f04
--- /dev/null
@@ -0,0 +1,9 @@
+#pragma weak deallocate_foo
+
+int deallocate_foo = 1;
+
+int *
+bar()
+{
+  return &deallocate_foo;
+}
diff --git a/ld/testsuite/ld-elfweak/bar1b.c b/ld/testsuite/ld-elfweak/bar1b.c
new file mode 100644 (file)
index 0000000..bab68ab
--- /dev/null
@@ -0,0 +1,7 @@
+int deallocate_foo = 0;
+
+int *
+bar()
+{
+  return &deallocate_foo;
+}
diff --git a/ld/testsuite/ld-elfweak/bar1c.c b/ld/testsuite/ld-elfweak/bar1c.c
new file mode 100644 (file)
index 0000000..901f065
--- /dev/null
@@ -0,0 +1,7 @@
+int deallocate_foo;
+
+int *
+bar()
+{
+  return &deallocate_foo;
+}
index 287b12d6bf60d726631944a52a73aada7a053916..3dff6aca97896a02dc4fe518d8fd196d9fde60ac 100644 (file)
@@ -1 +1 @@
-[0-9a-f]*[     ]+g[    ]+DF[   ]+.text[        ]+[0-9a-f]*[    ]+foo
+[0-9a-f]*[     ]+g[    ]+DF[   ]+.text[        ]+[0-9a-f]*[    ]+(Base[        ]+|[    ]*)foo
diff --git a/ld/testsuite/ld-elfweak/dsodata.dsym b/ld/testsuite/ld-elfweak/dsodata.dsym
new file mode 100644 (file)
index 0000000..596e334
--- /dev/null
@@ -0,0 +1,2 @@
+[0-9a-f]*[     ]+g[    ]+DO[   ]+.data[        ]+[0-9a-f]*[    ]+(Base[        ]+|[    ]*)deallocate_foo
+[0-9a-f]*[     ]+g[    ]+DF[   ]+.text[        ]+[0-9a-f]*[    ]+(Base[        ]+|[    ]*)foo
index aac6e7b24394e123a2e00419381b8d50770d671b..62cb4c20ec7bf8ac73750778f6ebbb2a835b993c 100644 (file)
@@ -1 +1 @@
-[0-9a-f]*[     ]+w[    ]+DF[   ]+.text[        ]+[0-9a-f]*[    ]+foo
+[0-9a-f]*[     ]+w[    ]+DF[   ]+.text[        ]+[0-9a-f]*[    ]+(Base[        ]+|[    ]*)foo
diff --git a/ld/testsuite/ld-elfweak/dsowdata.dsym b/ld/testsuite/ld-elfweak/dsowdata.dsym
new file mode 100644 (file)
index 0000000..0b5cca3
--- /dev/null
@@ -0,0 +1 @@
+[0-9a-f]*[     ]+w[    ]+DO[   ]+.data[        ]+[0-9a-f]*[    ]+(Base[        ]+|[    ]*)deallocate_foo
index 8ea4954068e4b59ec8ce459697fa93e9e1f541d5..ea751f3684448004b851b9e81441d7b2e689b39e 100644 (file)
@@ -266,7 +266,7 @@ proc objdump_dynsymstuff { objdump object expectfile } {
 
 }
 
-proc build_lib {test libname obj1 obj2 dynsymexp} {
+proc build_lib {test libname objs dynsymexp} {
     global ld
     global objdump
     global tmpdir
@@ -274,7 +274,12 @@ proc build_lib {test libname obj1 obj2 dynsymexp} {
     global srcdir
     global subdir
 
-    if {![ld_simple_link $ld $tmpdir/$libname.so "$shared $tmpdir/$obj1 $tmpdir/$obj2"]} {
+    set files ""
+    foreach obj $objs {
+      set files "$files $tmpdir/$obj"
+    }
+
+    if {![ld_link $ld $tmpdir/$libname.so "$shared $files"]} {
        fail $test
        return
     }
@@ -286,7 +291,7 @@ proc build_lib {test libname obj1 obj2 dynsymexp} {
     pass $test
 }
 
-proc build_exec { test execname obj1 obj2 flags dat dynsymexp symexp} {
+proc build_exec { test execname objs flags dat dynsymexp symexp} {
     global ld
     global objdump
     global tmpdir
@@ -295,7 +300,12 @@ proc build_exec { test execname obj1 obj2 flags dat dynsymexp symexp} {
     global subdir
     global exec_output
 
-    if {![ld_link $ld $tmpdir/$execname "$flags $tmpdir/$obj1 $tmpdir/$obj2"]} {
+    set files ""
+    foreach obj $objs {
+      set files "$files $tmpdir/$obj"
+    }
+
+    if {![ld_link $ld $tmpdir/$execname "$flags $files"]} {
        fail "$test"
        return
     }
@@ -379,16 +389,83 @@ if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c $tmpdir/main.o] {
     return
 }
 
-if {![ld_simple_link $ld $tmpdir/libbar.so "$shared $tmpdir/bar.o"]} {
+if {![ld_link $ld $tmpdir/libbar.so "$shared $tmpdir/bar.o"]} {
+    fail "ELF weak"
+    return
+}
+
+if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/foo1a.c $tmpdir/foo1a.o] {
+    unresolved "ELF weak"
+    return
+}
+
+if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/foo1b.c $tmpdir/foo1b.o] {
+    unresolved "ELF weak"
+    return
+}
+
+if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o] {
+    unresolved "ELF weak"
+    return
+}
+
+if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/bar1b.c $tmpdir/bar1b.o] {
+    unresolved "ELF weak"
+    return
+}
+
+if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o] {
+    unresolved "ELF weak"
+    return
+}
+
+if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main1.c $tmpdir/main1.o] {
+    unresolved "ELF weak"
+    return
+}
+
+if {![ld_link $ld $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]} {
+    fail "ELF weak"
+    return
+}
+
+if {![ld_link $ld $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"]} {
     fail "ELF weak"
     return
 }
 
-build_lib "ELF DSO weak first" libfoo foo.o bar.o dso.dsym
-build_lib "ELF DSO weak last" libfoo bar.o foo.o dso.dsym
-build_lib "ELF DSO weak first DSO" libfoo foo.o libbar.so dsow.dsym
-build_lib "ELF DSO weak last DSO" libfoo libbar.so foo.o dsow.dsym
-build_exec "ELF weak first" foo main.o bar.o "" strong "" strong.sym
-build_exec "ELF weak last" foo bar.o main.o "" strong "" strong.sym
-build_exec "ELF weak first DSO" foo main.o libbar.so "-rpath ." weak weak.dsym ""
-build_exec "ELF weak last DSO" foo libbar.so main.o "-rpath ." weak weak.dsym ""
+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
+setup_xfail "*-*-*"
+build_exec "ELF weak func first DSO" foo "main.o 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_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
+setup_xfail "*-*-*"
+build_lib "ELF DSO weak data first DSO" libfoo "bar1a.o libfoo1a.so" dsowdata.dsym
+setup_xfail "*-*-*"
+build_lib "ELF DSO weak data last DSO" libfoo "libfoo1a.so bar1a.o" dsowdata.dsym
+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
+setup_xfail "*-*-*"
+build_exec "ELF weak data first DSO" foo "main1.o bar1a.o 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 ""
+setup_xfail "*-*-*"
+build_exec "ELF weak data first DSO common" foo "main1.o bar1a.o 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 ""
diff --git a/ld/testsuite/ld-elfweak/foo1a.c b/ld/testsuite/ld-elfweak/foo1a.c
new file mode 100644 (file)
index 0000000..a653020
--- /dev/null
@@ -0,0 +1,7 @@
+int deallocate_foo = 0;
+
+int *
+foo ()
+{
+  return &deallocate_foo;
+}
diff --git a/ld/testsuite/ld-elfweak/foo1b.c b/ld/testsuite/ld-elfweak/foo1b.c
new file mode 100644 (file)
index 0000000..d71a635
--- /dev/null
@@ -0,0 +1,7 @@
+int deallocate_foo;
+
+int *
+foo ()
+{
+  return &deallocate_foo;
+}
diff --git a/ld/testsuite/ld-elfweak/main1.c b/ld/testsuite/ld-elfweak/main1.c
new file mode 100644 (file)
index 0000000..8a897a2
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+#pragma weak deallocate_foo
+int deallocate_foo = 1;
+
+extern int * bar ();
+extern int * foo ();
+extern void abort ();
+
+int
+main ()
+{
+  if (&deallocate_foo != bar () || &deallocate_foo != foo ())
+    abort ();
+
+  if (deallocate_foo)
+    printf ("weak deallocate_foo\n");
+  else
+    printf ("strong deallocate_foo\n");
+
+  return 0;
+}
diff --git a/ld/testsuite/ld-elfweak/strongcomm.sym b/ld/testsuite/ld-elfweak/strongcomm.sym
new file mode 100644 (file)
index 0000000..4b9cf4c
--- /dev/null
@@ -0,0 +1,2 @@
+[0-9a-f]*[     ]+g[    ]+O[    ]+.bss[ ]+[0-9a-f]*[    ]+deallocate_foo
+[0-9a-f]*[     ]+g[    ]+F[    ]+.text[        ]+[0-9a-f]*[    ]+foo
diff --git a/ld/testsuite/ld-elfweak/strongdata.dat b/ld/testsuite/ld-elfweak/strongdata.dat
new file mode 100644 (file)
index 0000000..8232e85
--- /dev/null
@@ -0,0 +1 @@
+strong deallocate_foo
diff --git a/ld/testsuite/ld-elfweak/strongdata.sym b/ld/testsuite/ld-elfweak/strongdata.sym
new file mode 100644 (file)
index 0000000..413725e
--- /dev/null
@@ -0,0 +1,2 @@
+[0-9a-f]*[     ]+g[    ]+O[    ]+.data[        ]+[0-9a-f]*[    ]+deallocate_foo
+[0-9a-f]*[     ]+g[    ]+F[    ]+.text[        ]+[0-9a-f]*[    ]+foo
diff --git a/ld/testsuite/ld-elfweak/weakdata.dat b/ld/testsuite/ld-elfweak/weakdata.dat
new file mode 100644 (file)
index 0000000..96668fa
--- /dev/null
@@ -0,0 +1 @@
+weak deallocate_foo
diff --git a/ld/testsuite/ld-elfweak/weakdata.dsym b/ld/testsuite/ld-elfweak/weakdata.dsym
new file mode 100644 (file)
index 0000000..4f1873b
--- /dev/null
@@ -0,0 +1,2 @@
+[0-9a-f]*[     ]+w[    ]+DO[   ]+.data[        ]+[0-9a-f]*[    ]+(Base[        ]+|[    ]*)deallocate_foo
+[0-9a-f]*[     ]+DF[   ]+\*UND\*[      ]+[0-9a-f]*[    ]+(Base[        ]+|[    ]*)foo