#define VXWORKS_PERSONALITY "llvm"
/* VxWorks uses R18 as a TCB pointer. We must pick something else as
- the static chain and R18 needs to be claimed "fixed". Until we
- arrange to override the common parts of the port family to
- acknowledge the latter, configure --with-specs="-ffixed-r18". */
+ the static chain and R18 needs to be claimed "fixed" (TARGET_OS_USES_R18
+ does that in aarch64_conditional_register_usage). */
#undef STATIC_CHAIN_REGNUM
#define STATIC_CHAIN_REGNUM 9
-
+#define TARGET_OS_USES_R18
aarch64_stack_protector_guard_offset = offs;
}
- if ((flag_sanitize & SANITIZE_SHADOW_CALL_STACK)
- && !fixed_regs[R18_REGNUM])
- error ("%<-fsanitize=shadow-call-stack%> requires %<-ffixed-x18%>");
+ if ((flag_sanitize & SANITIZE_SHADOW_CALL_STACK))
+ {
+ if (!fixed_regs[R18_REGNUM])
+ error ("%<-fsanitize=shadow-call-stack%> requires %<-ffixed-x18%>");
+#ifdef TARGET_OS_USES_R18
+ else
+ sorry ("%<-fsanitize=shadow-call-stack%> conflicts with the use of"
+ " register x18 by the target operating system");
+#endif
+ }
aarch64_feature_flags isa_flags = aarch64_get_isa_flags (opts);
if ((isa_flags & (AARCH64_FL_SM_ON | AARCH64_FL_ZA_ON))
fixed_regs[SPECULATION_SCRATCH_REGNUM] = 1;
call_used_regs[SPECULATION_SCRATCH_REGNUM] = 1;
}
+
+#ifdef TARGET_OS_USES_R18
+ /* R18 is the STATIC_CHAIN_REGNUM on most aarch64 ports, but VxWorks
+ uses it as the TCB, so aarch64-vxworks.h overrides
+ STATIC_CHAIN_REGNUM, and here we mark R18 as fixed. */
+ fixed_regs[R18_REGNUM] = 1;
+ call_used_regs[R18_REGNUM] = 1;
+#endif
}
/* Implement TARGET_MEMBER_TYPE_FORCES_BLK. */
#elif defined(__i386__)
# define CHAIN "%ecx"
#elif defined(__aarch64__)
-# define CHAIN "x18"
+# if defined __vxworks
+# define CHAIN "x9"
+# else
+# define CHAIN "x18"
+# endif
#elif defined(__alpha__)
# define CHAIN "$1"
#elif defined(__arm__)
"r" (inner->next), /* x15 */
"r" (inner->next), /* x16 */
"r" (inner->next), /* x17 */
+#ifndef __vxworks /* x18 is a fixed register on VxWorks, used for the TCB. */
"r" (inner->next), /* x18 */
+#endif
"r" (inner->next) : /* x30 */
"x19", "x20", "x21", "x22", "x23",
"x24", "x25", "x26", "x27", "x28");
int i;
-/* { dg-error "'-fsanitize=shadow-call-stack' requires '-ffixed-x18'" "" {target "aarch64*-*-*" } 0 } */
+/* aarch64-*-vxworks has x18 as a fixed register. */
+/* { dg-error "'-fsanitize=shadow-call-stack' requires '-ffixed-x18'" "" { target { aarch64*-*-* && { ! aarch64-*-vxworks* } } } 0 } */
+/* { dg-message "sorry, unimplemented: '-fsanitize=shadow-call-stack' conflicts with the use of register x18" "" { target { aarch64-*-vxworks* } } 0 } */
/* { dg-do compile } */
/* { dg-options "-fsanitize=shadow-call-stack -ffixed-x18 -fexceptions" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
int i;
/* scs_pop: ldr x30, [x18, #-8]! */
/* { dg-do compile } */
/* { dg-options "-O2 -fsanitize=shadow-call-stack -ffixed-x18 -fno-exceptions" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
int foo (int);
/* scs_pop: ldr x30, [x18, #-8]! */
/* { dg-do compile } */
/* { dg-options "-O2 -fno-omit-frame-pointer -fsanitize=shadow-call-stack -ffixed-x18 -fno-exceptions" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
int foo (int);
/* { dg-do compile } */
/* { dg-options "-O2 -fno-omit-frame-pointer -fsanitize=shadow-call-stack -fno-exceptions -ffixed-x18 --save-temps -fno-stack-protector" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
#include "test_frame_common.h"
/* { dg-do compile } */
/* { dg-options "-O2 -fomit-frame-pointer -fsanitize=shadow-call-stack -fno-exceptions -ffixed-x18 --save-temps -fno-stack-protector" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
#include "test_frame_common.h"
/* { dg-do compile } */
/* { dg-options "-O2 -fomit-frame-pointer -fsanitize=shadow-call-stack -fno-exceptions -ffixed-x18 --save-temps -fno-stack-protector" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
#include "test_frame_common.h"
/* { dg-do compile } */
/* { dg-options "-O0 -fomit-frame-pointer -fsanitize=shadow-call-stack -fno-exceptions -ffixed-x18 --save-temps -fno-stack-protector" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
int func1 (void)
{
/* { dg-options "-O2 -fstack-clash-protection -fomit-frame-pointer --param stack-clash-protection-guard-size=12 -fsanitize=shadow-call-stack -ffixed-x18 -fno-stack-protector" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
/* { dg-final { check-function-bodies "**" "" } } */
void f(int, ...);
/* { dg-options "-O2 -fstack-protector-all -fstack-clash-protection -fomit-frame-pointer --param stack-clash-protection-guard-size=12 -fsanitize=shadow-call-stack -ffixed-x18" } */
+/* { dg-skip-if "conflicts with x18" { aarch64-*-vxworks* } } */
#include "stack-check-prologue-19.c"