+2008-12-05 Catherine Moore <clm@codesourcery.com>
+
+ * gcc-target/mips/mips-nonpic: New testsuite.
+
2008-12-05 Steve Ellcey <sje@cup.hp.com>
PR other/28614
--- /dev/null
+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
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+/* { 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);
+}
--- /dev/null
+# 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
+# <http://www.gnu.org/licenses/>.
+
+# 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
--- /dev/null
+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);
--- /dev/null
+#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);
+}
--- /dev/null
+#include "mips-nonpic.h"
+int hit_nonpic_addr = 0;
+void
+nonpic_addr ()
+{
+ nonpic_receive_fn_addr (&nonpic_nothing);
+ hit_nonpic_addr++;
+}
--- /dev/null
+#include "mips-nonpic.h"
+int hit_nonpic_call = 0;
+void
+nonpic_call ()
+{
+ pic_nothing ();
+ pic_addr ();
+ hit_nonpic_call++;
+}
--- /dev/null
+#include "mips-nonpic.h"
+int hit_nonpic_nothing = 0;
+void
+nonpic_nothing ()
+{
+ hit_nonpic_nothing++;
+}
--- /dev/null
+#include "mips-nonpic.h"
+void
+nonpic_receive_fn_addr (void *x)
+{
+ if (x != &nonpic_nothing)
+ abort ();
+}
--- /dev/null
+#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);
+}
--- /dev/null
+#include "mips-nonpic.h"
+int hit_pic_addr = 0;
+void
+pic_addr ()
+{
+ pic_receive_fn_addr (&pic_nothing);
+ hit_pic_addr++;
+}
--- /dev/null
+#include "mips-nonpic.h"
+int hit_pic_call = 0;
+void
+pic_call ()
+{
+ nonpic_nothing ();
+ nonpic_addr ();
+ hit_pic_call++;
+}
--- /dev/null
+#include "mips-nonpic.h"
+int hit_pic_nothing = 0;
+void
+pic_nothing ()
+{
+ hit_pic_nothing++;
+}
--- /dev/null
+#include "mips-nonpic.h"
+void
+pic_receive_fn_addr (void *x)
+{
+ if (x != &pic_nothing)
+ abort ();
+}