diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2001-09-11 14:25:16 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2001-09-11 14:25:16 +0000 |
commit | bd7c9df68b3a0d97e93d022cd55e94a86bd31dbe (patch) | |
tree | c63a17130bc1248d5f4c52a4909c80e478011378 /ld/testsuite/ld-elfweak | |
parent | 63da102c1d237abc57975e8731a0386377a2d47a (diff) | |
download | fsf-binutils-gdb-bd7c9df68b3a0d97e93d022cd55e94a86bd31dbe.zip fsf-binutils-gdb-bd7c9df68b3a0d97e93d022cd55e94a86bd31dbe.tar.gz fsf-binutils-gdb-bd7c9df68b3a0d97e93d022cd55e94a86bd31dbe.tar.bz2 |
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.
Diffstat (limited to 'ld/testsuite/ld-elfweak')
-rw-r--r-- | ld/testsuite/ld-elfweak/bar1a.c | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/bar1b.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/bar1c.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/dso.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/dsodata.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/dsow.dsym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/dsowdata.dsym | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/elfweak.exp | 103 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/foo1a.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/foo1b.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/main1.c | 22 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/strongcomm.sym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/strongdata.dat | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/strongdata.sym | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/weakdata.dat | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elfweak/weakdata.dsym | 2 |
16 files changed, 162 insertions, 15 deletions
diff --git a/ld/testsuite/ld-elfweak/bar1a.c b/ld/testsuite/ld-elfweak/bar1a.c new file mode 100644 index 0000000..7ca1f04 --- /dev/null +++ b/ld/testsuite/ld-elfweak/bar1a.c @@ -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 index 0000000..bab68ab --- /dev/null +++ b/ld/testsuite/ld-elfweak/bar1b.c @@ -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 index 0000000..901f065 --- /dev/null +++ b/ld/testsuite/ld-elfweak/bar1c.c @@ -0,0 +1,7 @@ +int deallocate_foo; + +int * +bar() +{ + return &deallocate_foo; +} diff --git a/ld/testsuite/ld-elfweak/dso.dsym b/ld/testsuite/ld-elfweak/dso.dsym index 287b12d..3dff6ac 100644 --- a/ld/testsuite/ld-elfweak/dso.dsym +++ b/ld/testsuite/ld-elfweak/dso.dsym @@ -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 index 0000000..596e334 --- /dev/null +++ b/ld/testsuite/ld-elfweak/dsodata.dsym @@ -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 diff --git a/ld/testsuite/ld-elfweak/dsow.dsym b/ld/testsuite/ld-elfweak/dsow.dsym index aac6e7b..62cb4c2 100644 --- a/ld/testsuite/ld-elfweak/dsow.dsym +++ b/ld/testsuite/ld-elfweak/dsow.dsym @@ -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 index 0000000..0b5cca3 --- /dev/null +++ b/ld/testsuite/ld-elfweak/dsowdata.dsym @@ -0,0 +1 @@ +[0-9a-f]*[ ]+w[ ]+DO[ ]+.data[ ]+[0-9a-f]*[ ]+(Base[ ]+|[ ]*)deallocate_foo diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp index 8ea4954..ea751f3 100644 --- a/ld/testsuite/ld-elfweak/elfweak.exp +++ b/ld/testsuite/ld-elfweak/elfweak.exp @@ -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 index 0000000..a653020 --- /dev/null +++ b/ld/testsuite/ld-elfweak/foo1a.c @@ -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 index 0000000..d71a635 --- /dev/null +++ b/ld/testsuite/ld-elfweak/foo1b.c @@ -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 index 0000000..8a897a2 --- /dev/null +++ b/ld/testsuite/ld-elfweak/main1.c @@ -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 index 0000000..4b9cf4c --- /dev/null +++ b/ld/testsuite/ld-elfweak/strongcomm.sym @@ -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 index 0000000..8232e85 --- /dev/null +++ b/ld/testsuite/ld-elfweak/strongdata.dat @@ -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 index 0000000..413725e --- /dev/null +++ b/ld/testsuite/ld-elfweak/strongdata.sym @@ -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 index 0000000..96668fa --- /dev/null +++ b/ld/testsuite/ld-elfweak/weakdata.dat @@ -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 index 0000000..4f1873b --- /dev/null +++ b/ld/testsuite/ld-elfweak/weakdata.dsym @@ -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 |