1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

Disable SFrame support by default

And add extra checks to enable for binutils 2.45 and if the architecture
explicitly enables it.  When SFrame is disabled, all the related code
is also not enabled for backtrace() and _dl_find_object(), so SFrame
backtracking is not used even if the binary has the SFrame segment.

This patch also adds some other related fixes:

  * Fixed an issue with AC_CHECK_PROG_VER, where the READELF_SFRAME
    usage prevented specifying a different readelf through READELF
    environment variable at configure time.

  * Add an extra arch-specific internal definition,
    libc_cv_support_sframe, to disable --enable-sframe on architectures
    that have binutils but not glibc support (s390x).

  * Renamed the tests without the .sframe segment and move the
    tst-backtrace1 from pthread to debug.

  * Use the built compiler strip to remove the .sframe segment,
    instead of the system one (which might not support SFrame).

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
Adhemerval Zanella
2025-07-23 10:47:23 -03:00
committed by Andreas K. Hüttel
parent ce488f7c16
commit a12d72019e
17 changed files with 141 additions and 88 deletions

100
configure vendored
View File

@@ -620,8 +620,6 @@ DEFINES
static_nss
profile
libc_cv_multidir
enable_gsframe
READELF_SFRAME
libc_cv_test_x86_have_amx_tile
test_enable_cet
libc_cv_test_cc_mprefer_vector_width
@@ -694,6 +692,7 @@ MAKEINFO
MSGFMT
MAKE
LD
STRIP
NM
OBJDUMP
READELF
@@ -1510,8 +1509,7 @@ Optional Features:
Use -D_FORTIFY_SOURCE=[1|2|3] to control code
hardening, defaults to highest possible value
supported by the build compiler.
--disable-sframe Disable building with SFrame stack trace information
[default=yes if GNU as is 2.41 or older]
--enable-sframe Enable building with SFrame support [default=no]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -4895,7 +4893,7 @@ if test ${enable_sframe+y}
then :
enableval=$enable_sframe; use_sframe=$enableval
else case e in #(
e) use_sframe=notset ;;
e) use_sframe=no ;;
esac
fi
@@ -5142,6 +5140,10 @@ if test -z "$NM"; then
NM=`$CC -print-prog-name=nm`
fi
if test -z "$STRIP"; then
STRIP=`$CC -print-prog-name=strip`
fi
# Accept binutils 2.39 or newer.
@@ -9356,21 +9358,30 @@ have-libgcc_s = $libc_cv_have_libgcc_s"
# Glibc stacktracer supports SFrame v2 or newer
libc_cv_readelf_version_ok=yes
# SFrame is supported from 2.41 or higher
for ac_prog in $READELF
enable_gsframe=no
if test $use_sframe = yes; then
# SFrame requires to be explicit enabled by the architecture
if test -z $libc_cv_support_sframe; then
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
as_fn_error $? "the architecture doesn't support SFrame
See 'config.log' for more details" "$LINENO" 5; }
fi
# SFrame requires binutils 2.45 or higher.
libc_cv_sframe_readelf_version=yes
for ac_prog in $READELF
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_prog_READELF_SFRAME+y}
if test ${ac_cv_prog_READELF+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) if test -n "$READELF_SFRAME"; then
ac_cv_prog_READELF_SFRAME="$READELF_SFRAME" # Let the user override the test.
e) if test -n "$READELF"; then
ac_cv_prog_READELF="$READELF" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -9383,7 +9394,7 @@ do
esac
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
ac_cv_prog_READELF_SFRAME="$ac_prog"
ac_cv_prog_READELF="$ac_prog"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -9394,29 +9405,29 @@ IFS=$as_save_IFS
fi ;;
esac
fi
READELF_SFRAME=$ac_cv_prog_READELF_SFRAME
if test -n "$READELF_SFRAME"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $READELF_SFRAME" >&5
printf "%s\n" "$READELF_SFRAME" >&6; }
READELF=$ac_cv_prog_READELF
if test -n "$READELF"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $READELF" >&5
printf "%s\n" "$READELF" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
test -n "$READELF_SFRAME" && break
test -n "$READELF" && break
done
if test -z "$READELF_SFRAME"; then
if test -z "$READELF"; then
ac_verc_fail=yes
else
# Found it, now check the version.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $READELF_SFRAME" >&5
printf %s "checking version of $READELF_SFRAME... " >&6; }
ac_prog_version=`$READELF_SFRAME --version 2>&1 | sed -n 's/^.*GNU readelf.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $READELF" >&5
printf %s "checking version of $READELF... " >&6; }
ac_prog_version=`$READELF --version 2>&1 | sed -n 's/^.*GNU readelf.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
2.4[1-9]*|2.[5-9][0-9]*|[3-9].*|[1-9][0-9][0-9]*)
2.4[5-9]*|2.[5-9][0-9]*|2.[1-9][0-9][0-9]*|[3-9]*|[1-9][0-9]*)
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
@@ -9425,12 +9436,17 @@ printf %s "checking version of $READELF_SFRAME... " >&6; }
printf "%s\n" "$ac_prog_version" >&6; }
fi
if test $ac_verc_fail = yes; then
libc_cv_readelf_version_ok=no
libc_cv_sframe_readelf_version=no
fi
if test $libc_cv_sframe_readelf_version == no; then
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
as_fn_error $? "binutils too old to enable SFrame
See 'config.log' for more details" "$LINENO" 5; }
fi
# Check the current toolchain for SFrame support
if test $libc_cv_readelf_version_ok = yes; then
# Check if the current toolchain supports SFrame
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SFrame support" >&5
printf %s "checking for SFrame support... " >&6; }
if test ${libc_cv_default_sframe+y}
@@ -9443,32 +9459,32 @@ int test_function(void)
return 42;
}
EOF
libc_cv_default_sframe=no
if ${CC} -c conftest.c -o conftest.o -Wa,--gsframe >/dev/null 2>&1 && \
# Check if .sframe section is present and if version > 1
$READELF --sframe conftest.o | grep "SFRAME_VER" | grep -qv "VERSION_1"; then
libc_cv_default_sframe=yes
fi
rm -f conftest.c conftest.o
libc_cv_default_sframe=no
if ${CC} -c conftest.c -o conftest.o -Wa,--gsframe >/dev/null 2>&1 && \
# Check if .sframe section is present and if version > 1
$READELF --sframe conftest.o | grep "SFRAME_VER" | grep -qv "VERSION_1"; then
libc_cv_default_sframe=yes
fi
rm -f conftest.c conftest.o
;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_default_sframe" >&5
printf "%s\n" "$libc_cv_default_sframe" >&6; }
fi
# Prevent enabling sframe on non-supporting toolchains
enable_gsframe=no
if test $use_sframe$libc_cv_default_sframe = yesyes || \
test $use_sframe$libc_cv_default_sframe = notsetyes; then
enable_gsframe=yes
elif test $use_sframe = yes; then
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
if test $libc_cv_default_sframe == no; then
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
as_fn_error $? "toolchain doesn't support SFrame v2 or higher
See 'config.log' for more details" "$LINENO" 5; }
fi
fi
enable_gsframe=yes
printf "%s\n" "#define ENABLE_SFRAME 1" >>confdefs.h
fi
config_vars="$config_vars
enable-gsframe = $enable_gsframe"
# Set the `multidir' variable by grabbing the variable from the compiler.
# We do it once and save the result in a generated makefile.