When a user uses -fhardened and explicitly weakens any of the hardening
measures implies by -fhardened, a warning should appear IIUIC.
-fhardened implies -fcf-protection=full. I tried to override it by all
the remaining -fcf-protection and I indeed receive the warning except
for -fcf-protection=none which seems strange.
Reproducible: Always
Steps to Reproduce:
$ cat files/main.cc
#include <iostream>
using namespace std;
int main(void) {
cout << "hello world" << endl;
return 0;
}
# not actually overriding -> no warning as expected
$ g++ -fhardened -fcf-protection=full -Whardened -O2 -o cxx_hello.exe main.cc
# overriding to branch-only -> warning as expected
$ g++ -fhardened -fcf-protection=branch -Whardened -O2 -o cxx_hello.exe main.cc
cc1plus: warning: ‘-fcf-protection=full’ is not enabled by ‘-fhardened’ because it was specified on the command line [-Whardened]
# overriding to none (disabling it altogether) -> no warning???
$ g++ -fhardened -fcf-protection=none -Whardened -O2 -o cxx_hello.exe main.cc
When a user uses -fhardened and explicitly weakens any of the hardening measures implies by -fhardened, a warning should appear IIUIC. -fhardened implies -fcf-protection=full. I tried to override it by all the remaining -fcf-protection and I indeed receive the warning except for -fcf-protection=none which seems strange. Reproducible: Always Steps to Reproduce: $ cat files/main.cc #include <iostream> using namespace std; int main(void) { cout << "hello world" << endl; return 0; } # not actually overriding -> no warning as expected $ g++ -fhardened -fcf-protection=full -Whardened -O2 -o cxx_hello.exe main.cc # overriding to branch-only -> warning as expected $ g++ -fhardened -fcf-protection=branch -Whardened -O2 -o cxx_hello.exe main.cc cc1plus: warning: ‘-fcf-protection=full’ is not enabled by ‘-fhardened’ because it was specified on the command line [-Whardened] # overriding to none (disabling it altogether) -> no warning??? $ g++ -fhardened -fcf-protection=none -Whardened -O2 -o cxx_hello.exe main.cc