1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +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:
Adhemerval Zanella
2023-07-20 11:35:54 -03:00
parent 6c85c5a177
commit a3090c2c98
5 changed files with 30 additions and 30 deletions

View File

@ -29,11 +29,12 @@ cxx_modes="-std=c++98 -std=gnu++98 -std=c++11 -std=gnu++11"
# These are probably the most commonly used three.
lib_modes="-D_DEFAULT_SOURCE=1 -D_GNU_SOURCE=1 -D_XOPEN_SOURCE=700"
# Also check for fortify modes, since it might be enabled as default.
fortify_modes="1 2 3"
# Also check for fortify modes, since it might be enabled as default. The
# maximum value to be checked is define by maximum_fortify argument.
fortify_modes=""
if [ $# -lt 3 ]; then
echo "usage: $0 c|c++ \"compile command\" header header header..." >&2
echo "usage: $0 c|c++ maximum_fortify \"compile command\" header header header..." >&2
exit 2
fi
case "$1" in
@ -50,6 +51,8 @@ case "$1" in
exit 2;;
esac
shift
fortify_modes=$(seq -s' ' 1 $1)
shift
cc_cmd="$1"
shift
trap "rm -f '$cih_test_c'" 0
@ -104,7 +107,6 @@ EOF
for lang_mode in "" $lang_modes; do
for lib_mode in "" $lib_modes; do
for fortify_mode in "" $fortify_modes; do
echo :::: $lang_mode $lib_mode $fortify_mode
if [ -z "$lib_mode" ]; then
expanded_lib_mode='/* default library mode */'
else
@ -114,6 +116,7 @@ EOF
if [ ! -z $fortify_mode ]; then
fortify_mode="#define _FORTIFY_SOURCE $fortify_mode"
fi
echo :::: $lang_mode $lib_mode $fortify_mode
cat >"$cih_test_c" <<EOF
/* These macros may have been defined on the command line. They are
inappropriate for this test. */