From: H.J. Lu Date: Tue, 11 Jan 2022 15:28:25 +0000 (-0800) Subject: x86-64: Enable Intel CET X-Git-Tag: v1.5.4^2~277^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51ab182bd4af347b08fd1b9df179078c4f596e24;p=thirdparty%2Fzstd.git x86-64: Enable Intel CET Intel Control-flow Enforcement Technology (CET): https://en.wikipedia.org/wiki/Control-flow_integrity#Intel_Control-flow_Enforcement_Technology requires that on Linux, all linker input files are marked as CET enabled in .note.gnu.property section. For high-level language source codes, .note.gnu.property section is added by compiler with the -fcf-protection option. For assembly sources, include to add .note.gnu.property section. --- diff --git a/lib/common/portability_macros.h b/lib/common/portability_macros.h index 2143817f5..23a650885 100644 --- a/lib/common/portability_macros.h +++ b/lib/common/portability_macros.h @@ -134,4 +134,15 @@ # define ZSTD_ENABLE_ASM_X86_64_BMI2 0 #endif +/* + * For x86 ELF targets, add .note.gnu.property section for Intel CET in + * assembly sources when CET is enabled. + */ +#if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) \ + && defined(__has_include) +# if __has_include() +# include +# endif +#endif + #endif /* ZSTD_PORTABILITY_MACROS_H */