From a664545d5360f7e57d9f89ba333c26629bef1685 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 20 Apr 2004 14:50:22 +0000 Subject: [PATCH] 2004-04-20 H.J. Lu * ld-elfweak/elfweak.exp: Add an undefined weak size change test. * ld-elfweak/size.dat: New file. * ld-elfweak/size_bar.c: Likewise. * ld-elfweak/size_foo.c: Likewise. * ld-elfweak/size_main.c: Likewise. --- ld/testsuite/ChangeLog | 10 ++++++++++ ld/testsuite/ld-elfweak/elfweak.exp | 30 ++++++++++++++++++++++++++++- ld/testsuite/ld-elfweak/size.dat | 3 +++ ld/testsuite/ld-elfweak/size_bar.c | 11 +++++++++++ ld/testsuite/ld-elfweak/size_foo.c | 8 ++++++++ ld/testsuite/ld-elfweak/size_main.c | 8 ++++++++ 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-elfweak/size.dat create mode 100644 ld/testsuite/ld-elfweak/size_bar.c create mode 100644 ld/testsuite/ld-elfweak/size_foo.c create mode 100644 ld/testsuite/ld-elfweak/size_main.c diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index d6828351b2f..4d302ecb369 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2004-04-20 H.J. Lu + + * ld-elfweak/elfweak.exp: Add an undefined weak size change + test. + + * ld-elfweak/size.dat: New file. + * ld-elfweak/size_bar.c: Likewise. + * ld-elfweak/size_foo.c: Likewise. + * ld-elfweak/size_main.c: Likewise. + 2004-04-14 Brian Ford DJ Delorie diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp index 8fc6832b0bf..78b6358d9a5 100644 --- a/ld/testsuite/ld-elfweak/elfweak.exp +++ b/ld/testsuite/ld-elfweak/elfweak.exp @@ -287,7 +287,8 @@ proc build_lib {test libname objs dynsymexp} { return } - if {![objdump_dynsymstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$dynsymexp]} { + if {![string match "" $dynsymexp] \ + && ![objdump_dynsymstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$dynsymexp]} { fail $test return } @@ -465,3 +466,30 @@ build_exec "ELF weak data first DSO" foo "main1.o libbar1a.so libfoo1a.so" "-Wl, build_exec "ELF weak data last DSO" foo "libfoo1a.so main1.o libbar1a.so" "-Wl,-rpath,." weakdata weakdata.dsym "" build_exec "ELF weak data first DSO common" foo "main1.o libbar1a.so libfoo1b.so" "-Wl,-rpath,." weakdata weakdata.dsym "" build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-Wl,-rpath,." weakdata weakdata.dsym "" + +if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/size_foo.c $tmpdir/size_foo.o] { + unresolved "ELF weak (size)" + return +} + +if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/size_bar.c $tmpdir/size_bar.o] { + unresolved "ELF weak (size)" + return +} + +build_lib "ELF DSO small bar (size)" libsize_bar "size_bar.o" "" +build_lib "ELF DSO foo with small bar (size)" libsize_foo "size_foo.o libsize_bar.so" "" + +if ![ld_compile "$CC $CFLAGS $picflag -DSIZE_BIG" $srcdir/$subdir/size_bar.c $tmpdir/size_bar.o] { + unresolved "ELF weak (size)" + return +} + +build_lib "ELF DSO big bar (size)" libsize_bar "size_bar.o" "" + +if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/size_main.c $tmpdir/size_main.o] { + unresolved "ELF weak (size)" + return +} + +build_exec "ELF weak size" size_main "size_main.o libsize_foo.so libsize_bar.so" "-Wl,-rpath,." size "" "" diff --git a/ld/testsuite/ld-elfweak/size.dat b/ld/testsuite/ld-elfweak/size.dat new file mode 100644 index 00000000000..01e79c32a8c --- /dev/null +++ b/ld/testsuite/ld-elfweak/size.dat @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/ld/testsuite/ld-elfweak/size_bar.c b/ld/testsuite/ld-elfweak/size_bar.c new file mode 100644 index 00000000000..7f32890c8a3 --- /dev/null +++ b/ld/testsuite/ld-elfweak/size_bar.c @@ -0,0 +1,11 @@ +#include + +void +bar () +{ +#ifdef SIZE_BIG + printf ("1\n"); + printf ("2\n"); + printf ("3\n"); +#endif +} diff --git a/ld/testsuite/ld-elfweak/size_foo.c b/ld/testsuite/ld-elfweak/size_foo.c new file mode 100644 index 00000000000..2276f62774b --- /dev/null +++ b/ld/testsuite/ld-elfweak/size_foo.c @@ -0,0 +1,8 @@ +#pragma weak bar + +extern void bar (); + +foo () +{ + bar (); +} diff --git a/ld/testsuite/ld-elfweak/size_main.c b/ld/testsuite/ld-elfweak/size_main.c new file mode 100644 index 00000000000..2cee0a9446a --- /dev/null +++ b/ld/testsuite/ld-elfweak/size_main.c @@ -0,0 +1,8 @@ +extern void foo (); + +int +main () +{ + foo (); + return 0; +} -- 2.30.2