This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Reject -mrelax for SH VwWorks unless generating RTP PIC
- From: Richard Sandiford <richard at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 04 Jul 2007 14:02:07 +0100
- Subject: [committed] Reject -mrelax for SH VwWorks unless generating RTP PIC
As the comment explains, the VxWorks kernel loader cannot handle the
SH relaxation relocations. This patch adds an appropriate error
message, along with a test, and skips gcc.dg/sh-relax.c in this case.
Tested on sh-wrs-vxworks. Approved by Nathan and applied.
Richard
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.
Index: gcc/config/sh/vxworks.h
===================================================================
--- gcc/config/sh/vxworks.h 2007-07-04 04:38:34.000000000 -0700
+++ gcc/config/sh/vxworks.h 2007-07-04 04:38:34.000000000 -0700
@@ -30,7 +30,20 @@ #define TARGET_OS_CPP_BUILTINS() \
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: gcc/testsuite/gcc.dg/sh-relax.c
===================================================================
--- gcc/testsuite/gcc.dg/sh-relax.c 2007-07-04 04:35:01.000000000 -0700
+++ gcc/testsuite/gcc.dg/sh-relax.c 2007-07-04 04:38:34.000000000 -0700
@@ -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);
Index: gcc/testsuite/gcc.dg/sh-relax-vxworks.c
===================================================================
--- /dev/null 2007-04-22 10:31:05.567569208 -0700
+++ gcc/testsuite/gcc.dg/sh-relax-vxworks.c 2007-07-04 04:38:34.000000000 -0700
@@ -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;