From ba5a7c968cbc21143b33aaba85bf3d80aeb10777 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 11 Jan 2022 07:28:25 -0800 Subject: [PATCH] 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. --- lib/common/portability_macros.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/common/portability_macros.h b/lib/common/portability_macros.h index 627ef9eed4a..0984ed71b93 100644 --- a/lib/common/portability_macros.h +++ b/lib/common/portability_macros.h @@ -128,4 +128,14 @@ # define ZSTD_ENABLE_ASM_X86_64_BMI2 0 #endif +/* + * Add .note.gnu.property section for Intel CET in assembly sources + * when CET is enabled. + */ +#if (defined(__x86_64__) || defined(__i386__)) && defined(__has_include) +# if __has_include() +# include +# endif +#endif + #endif /* ZSTD_PORTABILITY_MACROS_H */