diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-07-20 11:35:54 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-07-20 17:58:26 -0300 |
commit | a3090c2c98facbab3d47aa23a94f8d2caeb78d71 (patch) | |
tree | 73e79c30d449aff75fb3d7c72bdb1e29baf24533 /configure.ac | |
parent | 6c85c5a1773d786ccdc375e34431488fbcdd88e0 (diff) | |
download | glibc-a3090c2c98facbab3d47aa23a94f8d2caeb78d71.tar.gz glibc-a3090c2c98facbab3d47aa23a94f8d2caeb78d71.tar.xz glibc-a3090c2c98facbab3d47aa23a94f8d2caeb78d71.zip |
scripts: Fix fortify checks if compiler does not support _FORTIFY_SOURCE=3
The 30379efad1 added _FORTIFY_SOURCE checks without check if compiler does support all used fortify levels. This patch fixes it by first checking at configure time the maximum support fortify level and using it instead of a pre-defined one. Checked on x86_64 with gcc 11, 12, and 13. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Tested-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index f508a3722b..12d1f50b14 100644 --- a/configure.ac +++ b/configure.ac @@ -1578,17 +1578,17 @@ dnl support it no_fortify_source="-Wp,-U_FORTIFY_SOURCE" fortify_source="${no_fortify_source}" -AC_CACHE_CHECK([for __builtin_dynamic_object_size], [libc_cv___builtin_dynamic_object_size], [ +AC_CACHE_CHECK([for maximum supported _FORTIFY_SOURCE level], + [libc_cv_supported_fortify_source], [ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_dynamic_object_size("", 0)])], - [libc_cv___builtin_dynamic_object_size=yes - AS_IF([test "$enable_fortify_source" = yes], [enable_fortify_source=3])], - [libc_cv___builtin_dynamic_object_size=no - AS_IF([test "$enable_fortify_source" = yes], [enable_fortify_source=2])]) + [libc_cv_supported_fortify_source=3], + [libc_cv_supported_fortify_source=2]) ]) AS_CASE([$enable_fortify_source], + [yes], [libc_cv_fortify_source=yes enable_fortify_source=$libc_cv_supported_fortify_source], [1|2], [libc_cv_fortify_source=yes], - [3], [AS_IF([test "$libc_cv___builtin_dynamic_object_size" = yes], + [3], [AS_IF([test $libc_cv_supported_fortify_source = 3], [libc_cv_fortify_source=yes], [AC_MSG_ERROR([Compiler doesn't provide necessary support for _FORTIFY_SOURCE=3])])], [libc_cv_fortify_source=no]) @@ -1601,6 +1601,7 @@ AC_SUBST(enable_fortify_source) AC_SUBST(libc_cv_fortify_source) AC_SUBST(no_fortify_source) AC_SUBST(fortify_source) +LIBC_CONFIG_VAR([supported-fortify], [$libc_cv_supported_fortify_source]) dnl Starting with binutils 2.35, GAS can attach multiple symbol versions dnl to one symbol (PR 23840). |