vxworks.h (SUBTARGET_OVERRIDE_OPTIONS): Reject -mrelax unless compiling RTP PIC.
authorRichard Sandiford <richard@codesourcery.com>
Wed, 4 Jul 2007 13:01:33 +0000 (13:01 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 4 Jul 2007 13:01:33 +0000 (13:01 +0000)
gcc/
* config/sh/vxworks.h (SUBTARGET_OVERRIDE_OPTIONS): Reject -mrelax
unless compiling RTP PIC.

gcc/testsuite/
* gcc.dg/sh-relax.c: Skip for VxWorks if non-PIC.
* gcc.dg/sh-relax-vxworks.c: New test.

From-SVN: r126317

gcc/ChangeLog
gcc/config/sh/vxworks.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/sh-relax-vxworks.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/sh-relax.c

index a2949209d0499465db7727828bc3aae780b892d6..af67cfb0caa633fd853331e5f64c13ddf70f9d08 100644 (file)
@@ -1,3 +1,8 @@
+2007-07-04  Richard Sandiford  <richard@codesourcery.com>
+
+       * config/sh/vxworks.h (SUBTARGET_OVERRIDE_OPTIONS): Reject -mrelax
+       unless compiling RTP PIC.
+
 2007-07-04  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/32482
index 63f2bbf6969a474bc521ec1cf07359f566ebdfd6..82b32f143c6ca76e394e4e955796bcf94e660577 100644 (file)
@@ -30,7 +30,20 @@ Boston, MA 02110-1301, USA.  */
   while (0)
 
 #undef SUBTARGET_OVERRIDE_OPTIONS
-#define SUBTARGET_OVERRIDE_OPTIONS VXWORKS_OVERRIDE_OPTIONS
+#define SUBTARGET_OVERRIDE_OPTIONS                             \
+  do                                                           \
+    {                                                          \
+      VXWORKS_OVERRIDE_OPTIONS;                                        \
+      /* The kernel loader cannot handle the relaxation                \
+        relocations, so it cannot load kernel modules          \
+        (which are ET_REL) or RTP executables (which are       \
+        linked with --emit-relocs).  No relaxation relocations \
+        appear in shared libraries, so relaxation is OK        \
+        for RTP PIC.  */                                       \
+      if (TARGET_RELAX && !(TARGET_VXWORKS_RTP && flag_pic))   \
+       error ("-mrelax is only supported for RTP PIC");        \
+    }                                                          \
+  while (0)
 
 #undef SUBTARGET_CPP_SPEC
 #define SUBTARGET_CPP_SPEC VXWORKS_ADDITIONAL_CPP_SPEC
index 261286e57c3433363e3430a84c416eb5b17d2d7e..30516ad65c14cc4a6ea8723b52187f4500565c41 100644 (file)
@@ -1,3 +1,8 @@
+2007-07-04  Richard Sandiford  <richard@codesourcery.com>
+
+       * gcc.dg/sh-relax.c: Skip for VxWorks if non-PIC.
+       * gcc.dg/sh-relax-vxworks.c: New test.
+
 2007-07-04  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/32500
diff --git a/gcc/testsuite/gcc.dg/sh-relax-vxworks.c b/gcc/testsuite/gcc.dg/sh-relax-vxworks.c
new file mode 100644 (file)
index 0000000..f8c2ffe
--- /dev/null
@@ -0,0 +1,5 @@
+/* Check that -mrelax produces the correct error message.  */
+/* { dg-do compile { target { sh-*-vxworks* && nonpic } } } */
+/* { dg-error "-mrelax is only supported for RTP PIC" "" { target *-*-* } 0 } */
+/* { dg-options "-O1 -mrelax" } */
+int x;
index e204f063e8400afda1fc88a0f8f207dab7f93f9d..54422de46d2415870472d8d87c87aa676dcece09 100644 (file)
@@ -1,5 +1,5 @@
 /* Check that -mrelax works.  */
-/* { dg-do run { target sh-*-* sh?-*-* } } */
+/* { dg-do run { target { { sh-*-* sh?-*-* } && { ! { sh*-*-vxworks* && nonpic } } } } } */
 /* { dg-options "-O1 -mrelax" } */
 
 extern void abort (void);