From: Catherine Moore Date: Fri, 5 Dec 2008 20:53:26 +0000 (-0500) Subject: mips-nonpic: New testsuite. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=00ad9a06d63b3a7f3f48e2463f34166967d51873;p=gcc.git mips-nonpic: New testsuite. 2008-12-05 Catherine Moore * gcc-target/mips/mips-nonpic: New testsuite. From-SVN: r142492 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5da990070fb..6a0d2c6933d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-12-05 Catherine Moore + + * gcc-target/mips/mips-nonpic: New testsuite. + 2008-12-05 Steve Ellcey PR other/28614 diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/README b/gcc/testsuite/gcc.target/mips/mips-nonpic/README new file mode 100644 index 00000000000..bdd62c19398 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/README @@ -0,0 +1,20 @@ +These tests are meant to test the interoperability of PIC and nonpic objects for mips. +This table shows the various combinations and each case is tested by one of the nonpic tests. +Test Case The PIC code The non-PIC code The result (stub and/or PLT) + +main-1.c nothing nothing Neither (trivial) +main-2.c nothing call only PLT entry +main-3.c nothing address taken only Neither (* But creating a PLT entry is valid) +main-4.c nothing address and call PLT entry +main-5.c call only nothing .MIPS.stubs entry +main-6.c call only call only .MIPS.stubs and PLT +main-7.c call only address taken only .MIPS.stubs (* Also creating a PLT entry is valid) +main-8.c call only address and call .MIPS.stubs and PLT entry +main-9.c address taken only nothing Neither +main-10.c address taken only call only PLT entry +main-11.c address taken only address taken only Neither (* But creating a PLT entry is valid) +main-12.c address taken only address and call PLT entry +main-13.c address and call nothing Neither +main-14.c address and call call only PLT entry +main-15.c address and call address taken only Neither (* But creating a PLT entry is valid) +main-16.c address and call address and call PLT entry diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-1.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-1.c new file mode 100644 index 00000000000..2f428717a32 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-1.c @@ -0,0 +1,17 @@ +/* { dg-options "pic-nothing.o nonpic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_nothing (); + pic_nothing (); + + if (hit_nonpic_nothing != 1) + abort (); + + if (hit_pic_nothing != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-10.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-10.c new file mode 100644 index 00000000000..6c3601861ab --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-10.c @@ -0,0 +1,18 @@ +/* { dg-options "nonpic-call.o pic-addr.o pic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_call (); + pic_addr (); + + if (hit_nonpic_call != 1) + abort (); + + if (hit_pic_addr != 2) + abort (); + + exit (0); + +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-11.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-11.c new file mode 100644 index 00000000000..1d8a6d20cdf --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-11.c @@ -0,0 +1,17 @@ +/* { dg-options "nonpic-addr.o pic-addr.o nonpic-receive-fn-addr.o pic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_addr (); + pic_addr (); + + if (hit_nonpic_addr != 1) + abort (); + + if (hit_pic_addr != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-12.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-12.c new file mode 100644 index 00000000000..f57b5ce172a --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-12.c @@ -0,0 +1,17 @@ +/* { dg-options "nonpic-addr-call.o pic-addr.o pic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_addr_call (); + pic_addr (); + + if (hit_nonpic_addr_call != 1) + abort (); + + if (hit_pic_addr != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-13.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-13.c new file mode 100644 index 00000000000..d2b88e1f384 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-13.c @@ -0,0 +1,17 @@ +/* { dg-options "pic-addr-call.o nonpic-receive-fn-addr.o nonpic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_nothing (); + pic_addr_call (); + + if (hit_nonpic_nothing != 1) + abort (); + + if (hit_pic_addr_call != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-14.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-14.c new file mode 100644 index 00000000000..6318a2240af --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-14.c @@ -0,0 +1,17 @@ +/* { dg-options "nonpic-call.o pic-addr.o pic-receive-fn-addr.o pic-addr-call.o nonpic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_call (); + pic_addr_call (); + + if (hit_nonpic_call != 1) + abort (); + + if (hit_pic_addr_call != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-15.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-15.c new file mode 100644 index 00000000000..1c165043a55 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-15.c @@ -0,0 +1,17 @@ +/* { dg-options "nonpic-addr.o pic-receive-fn-addr.o pic-addr-call.o nonpic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_addr (); + pic_addr_call (); + + if (hit_nonpic_addr != 1) + abort (); + + if (hit_pic_addr_call != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-16.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-16.c new file mode 100644 index 00000000000..3119979d354 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-16.c @@ -0,0 +1,17 @@ +/* { dg-options "nonpic-addr-call.o pic-receive-fn-addr.o pic-addr-call.o nonpic-receive-fn-addr.o pic-nothing.o nonpic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_addr_call (); + pic_addr_call (); + + if (hit_nonpic_addr_call != 1) + abort (); + + if (hit_pic_addr_call != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-2.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-2.c new file mode 100644 index 00000000000..8a66e7a7af6 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-2.c @@ -0,0 +1,17 @@ +/* { dg-options "pic-addr.o nonpic-call.o pic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_call (); + pic_nothing (); + + if (hit_nonpic_call != 1) + abort (); + + if (hit_pic_nothing != 2) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-3.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-3.c new file mode 100644 index 00000000000..c9c8dac7081 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-3.c @@ -0,0 +1,17 @@ +/* { dg-options "nonpic-addr.o nonpic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_addr (); + pic_nothing (); + + if (hit_nonpic_addr != 1) + abort (); + + if (hit_pic_nothing != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-4.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-4.c new file mode 100644 index 00000000000..c10c213ac78 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-4.c @@ -0,0 +1,17 @@ +/* { dg-options "pic-addr.o pic-receive-fn-addr.o nonpic-addr-call.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_addr_call (); + pic_nothing (); + + if (hit_nonpic_addr_call != 1) + abort (); + + if (hit_pic_nothing != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-5.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-5.c new file mode 100644 index 00000000000..9b6dd8aff2e --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-5.c @@ -0,0 +1,17 @@ +/* { dg-options "pic-addr.o pic-call.o nonpic-addr.o pic-receive-fn-addr.o nonpic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + nonpic_nothing (); + pic_call (); + + if (hit_nonpic_nothing != 2) + abort (); + + if (hit_pic_call != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-6.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-6.c new file mode 100644 index 00000000000..90b220f0f0f --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-6.c @@ -0,0 +1,17 @@ +/* { dg-options "pic-call.o nonpic-call.o nonpic-addr.o pic-addr.o nonpic-receive-fn-addr.o pic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + pic_call (); + nonpic_call (); + + if (hit_pic_call != 1) + abort (); + + if (hit_nonpic_call != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-7.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-7.c new file mode 100644 index 00000000000..8cef63f3c44 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-7.c @@ -0,0 +1,17 @@ +/* { dg-options "pic-call.o nonpic-addr.o nonpic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + pic_call (); + nonpic_addr (); + + if (hit_pic_call != 1) + abort (); + + if (hit_nonpic_addr != 2) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-8.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-8.c new file mode 100644 index 00000000000..0200bf2dde3 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-8.c @@ -0,0 +1,17 @@ +/* { dg-options "pic-call.o nonpic-addr-call.o nonpic-addr.o nonpic-receive-fn-addr.o pic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + pic_call (); + nonpic_addr_call (); + + if (hit_pic_call != 1) + abort (); + + if (hit_nonpic_addr_call != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/main-9.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-9.c new file mode 100644 index 00000000000..4144172ccd4 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/main-9.c @@ -0,0 +1,10 @@ +/* { dg-options "pic-addr.o pic-receive-fn-addr.o nonpic-nothing.o pic-nothing.o" } */ + +#include "mips-nonpic.h" + +main () +{ + pic_addr (); + nonpic_nothing (); + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/mips-nonpic.exp b/gcc/testsuite/gcc.target/mips/mips-nonpic/mips-nonpic.exp new file mode 100644 index 00000000000..47443acda58 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/mips-nonpic.exp @@ -0,0 +1,54 @@ +# Copyright (C) 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. +load_lib gcc-dg.exp +load_lib target-supports.exp + +# Exit immediately if this isn't a MIPS target. +if ![istarget mips*-*-*] { + return +} + +# Pic and nonpic are not link-compatible for VXWorks targets. +if [istarget mips*-*-vxworks] { + return +} + +if { ![check_effective_target_fpic] } { + return +} + +dg-init + +set old-dg-do-what-default "${dg-do-what-default}" +set dg-do-what-default "assemble" + +foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/pic-*.c]] { + verbose "Compiling [file tail [file dirname $testcase]]/[file tail $testcase]" + dg-test -keep-output $testcase "-fpic" "" +} + +foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/nonpic-*.c]] { + verbose "Compiling [file tail [file dirname $testcase]]/[file tail $testcase]" + dg-test -keep-output $testcase "-fno-pic" "" +} + +set dg-do-what-default "run" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/main-*.c]] "-fno-pic" "" + +set dg-do-what-default "${old-dg-do-what-default}" +dg-finish diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/mips-nonpic.h b/gcc/testsuite/gcc.target/mips/mips-nonpic/mips-nonpic.h new file mode 100644 index 00000000000..e9fe9921885 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/mips-nonpic.h @@ -0,0 +1,20 @@ +extern int hit_pic_addr; +extern int hit_pic_addr_call; +extern int hit_pic_nothing; +extern int hit_pic_call; + +extern int hit_nonpic_addr; +extern int hit_nonpic_addr_call; +extern int hit_nonpic_call; +extern int hit_nonpic_nothing; + +extern void nonpic_addr (void); +extern void nonpic_nothing (void); +extern void nonpic_receive_fn_addr (void *); + +extern void pic_addr (void); +extern void pic_receive_fn_addr (void *); +extern void pic_nothing (void); + +extern void abort (void); +extern void exit (int); diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-addr-call.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-addr-call.c new file mode 100644 index 00000000000..19d0e434924 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-addr-call.c @@ -0,0 +1,8 @@ +#include "mips-nonpic.h" +int hit_nonpic_addr_call = 0; +void +nonpic_addr_call (void) +{ + hit_nonpic_addr_call++; + pic_receive_fn_addr (&pic_nothing); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-addr.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-addr.c new file mode 100644 index 00000000000..c919e83b98e --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-addr.c @@ -0,0 +1,8 @@ +#include "mips-nonpic.h" +int hit_nonpic_addr = 0; +void +nonpic_addr () +{ + nonpic_receive_fn_addr (&nonpic_nothing); + hit_nonpic_addr++; +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-call.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-call.c new file mode 100644 index 00000000000..8d368b42e95 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-call.c @@ -0,0 +1,9 @@ +#include "mips-nonpic.h" +int hit_nonpic_call = 0; +void +nonpic_call () +{ + pic_nothing (); + pic_addr (); + hit_nonpic_call++; +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-nothing.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-nothing.c new file mode 100644 index 00000000000..90356fb24ff --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-nothing.c @@ -0,0 +1,7 @@ +#include "mips-nonpic.h" +int hit_nonpic_nothing = 0; +void +nonpic_nothing () +{ + hit_nonpic_nothing++; +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-receive-fn-addr.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-receive-fn-addr.c new file mode 100644 index 00000000000..8b548c9ef51 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/nonpic-receive-fn-addr.c @@ -0,0 +1,7 @@ +#include "mips-nonpic.h" +void +nonpic_receive_fn_addr (void *x) +{ + if (x != &nonpic_nothing) + abort (); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-addr-call.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-addr-call.c new file mode 100644 index 00000000000..2db729392ed --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-addr-call.c @@ -0,0 +1,8 @@ +#include "mips-nonpic.h" +int hit_pic_addr_call = 0; +void +pic_addr_call (void) +{ + hit_pic_addr_call++; + nonpic_receive_fn_addr (&nonpic_nothing); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-addr.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-addr.c new file mode 100644 index 00000000000..a9073923501 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-addr.c @@ -0,0 +1,8 @@ +#include "mips-nonpic.h" +int hit_pic_addr = 0; +void +pic_addr () +{ + pic_receive_fn_addr (&pic_nothing); + hit_pic_addr++; +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-call.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-call.c new file mode 100644 index 00000000000..0c73b93339b --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-call.c @@ -0,0 +1,9 @@ +#include "mips-nonpic.h" +int hit_pic_call = 0; +void +pic_call () +{ + nonpic_nothing (); + nonpic_addr (); + hit_pic_call++; +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-nothing.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-nothing.c new file mode 100644 index 00000000000..3e45390813b --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-nothing.c @@ -0,0 +1,7 @@ +#include "mips-nonpic.h" +int hit_pic_nothing = 0; +void +pic_nothing () +{ + hit_pic_nothing++; +} diff --git a/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-receive-fn-addr.c b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-receive-fn-addr.c new file mode 100644 index 00000000000..4a40e0a182f --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-nonpic/pic-receive-fn-addr.c @@ -0,0 +1,7 @@ +#include "mips-nonpic.h" +void +pic_receive_fn_addr (void *x) +{ + if (x != &pic_nothing) + abort (); +}