mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
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>
This commit is contained in:
13
configure.ac
13
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).
|
||||
|
Reference in New Issue
Block a user