aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-07-20 11:35:54 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-07-20 17:58:26 -0300
commita3090c2c98facbab3d47aa23a94f8d2caeb78d71 (patch)
tree73e79c30d449aff75fb3d7c72bdb1e29baf24533 /scripts
parent6c85c5a1773d786ccdc375e34431488fbcdd88e0 (diff)
downloadglibc-a3090c2c98facbab3d47aa23a94f8d2caeb78d71.zip
glibc-a3090c2c98facbab3d47aa23a94f8d2caeb78d71.tar.gz
glibc-a3090c2c98facbab3d47aa23a94f8d2caeb78d71.tar.bz2
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 'scripts')
-rw-r--r--scripts/check-installed-headers.sh11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/check-installed-headers.sh b/scripts/check-installed-headers.sh
index 23506a2..ee9f534 100644
--- a/scripts/check-installed-headers.sh
+++ b/scripts/check-installed-headers.sh
@@ -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. */