]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
bpf: disable -fstack-protector in BPF
authorJose E. Marchesi <jose.marchesi@oracle.com>
Tue, 17 Jan 2023 16:16:32 +0000 (17:16 +0100)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Tue, 17 Jan 2023 16:16:32 +0000 (17:16 +0100)
The stack protector is not supported in BPF.  This patch disables
-fstack-protector in bpf-* targets, along with the emission of a note
indicating that the feature is not supported in this platform.

Regtested in bpf-unknown-none.

gcc/ChangeLog:

* config/bpf/bpf.cc (bpf_option_override): Disable
-fstack-protector.

gcc/config/bpf/bpf.cc

index 576a1fe8eabf2337ecadfa9d313d8e17b0bc2fcb..b268801d00c784e2ef9e47265e5e92c7c90a0722 100644 (file)
@@ -253,6 +253,14 @@ bpf_option_override (void)
   if (bpf_has_jmp32 == -1)
     bpf_has_jmp32 = (bpf_isa >= ISA_V3);
 
+  /* Disable -fstack-protector as it is not supported in BPF.  */
+  if (flag_stack_protect)
+    {
+      inform (input_location,
+              "%<-fstack-protector%> does not work "
+              " on this architecture");
+      flag_stack_protect = 0;
+    }
 }
 
 #undef TARGET_OPTION_OVERRIDE