[COMMITTED] bpf: disable -fstack-protector in BPF

From: Unknown
Date: Tue Jan 17 2023 - 11:16:32 EST


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 | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
index 576a1fe8eab..b268801d00c 100644
--- a/gcc/config/bpf/bpf.cc
+++ b/gcc/config/bpf/bpf.cc
@@ -253,6 +253,14 @@ bpf_option_override (void)
if (bpf_has_jmp32 =3D=3D -1)
bpf_has_jmp32 =3D (bpf_isa >=3D ISA_V3);
=20
+ /* 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 =3D 0;
+ }
}
=20
#undef TARGET_OPTION_OVERRIDE
--=20
2.30.2