mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
Enable execstack tests only if compiler supports trampoline
Since trampoline is required to test execstack, enable execstack tests only if compiler supports trampoline. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
parent
f5fb9fa011
commit
d9d30f6cb5
4 changed files with 80 additions and 2 deletions
47
configure
vendored
47
configure
vendored
|
@ -7774,6 +7774,53 @@ config_vars="$config_vars
|
|||
cc-option-wimplicit-fallthrough = $libc_cv_cc_wimplicit_fallthrough"
|
||||
|
||||
|
||||
conftest_code="
|
||||
void bar (void (*callback) (void));
|
||||
int foo (void)
|
||||
{
|
||||
int var = 0;
|
||||
void callback (void) { var = 1; }
|
||||
bar (callback);
|
||||
return var;
|
||||
}
|
||||
"
|
||||
|
||||
|
||||
cat > conftest.c <<EOF
|
||||
$conftest_code
|
||||
EOF
|
||||
|
||||
saved_CC="$CC"
|
||||
CC="$TEST_CC"
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking support for trampolines in testing" >&5
|
||||
printf %s "checking support for trampolines in testing... " >&6; }
|
||||
if test ${libc_cv_test_cc_trampolines+y}
|
||||
then :
|
||||
printf %s "(cached) " >&6
|
||||
else case e in #(
|
||||
e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -c -Werror conftest.c -o conftest 1>&5'
|
||||
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; }
|
||||
then
|
||||
libc_cv_test_cc_trampolines=yes
|
||||
else
|
||||
libc_cv_test_cc_trampolines=no
|
||||
|
||||
fi ;;
|
||||
esac
|
||||
fi
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_trampolines" >&5
|
||||
printf "%s\n" "$libc_cv_test_cc_trampolines" >&6; }
|
||||
|
||||
CC="$saved_CC"
|
||||
|
||||
rm -f conftest*
|
||||
config_vars="$config_vars
|
||||
have-test-cc-trampoline = $libc_cv_test_cc_trampolines"
|
||||
|
||||
|
||||
|
||||
saved_CC="$CC"
|
||||
|
|
22
configure.ac
22
configure.ac
|
@ -1527,6 +1527,28 @@ LIBC_CONFIG_VAR([cc-option-wimplicit-fallthrough],
|
|||
[$libc_cv_cc_wimplicit_fallthrough])
|
||||
AC_SUBST(libc_cv_test_cc_wimplicit_fallthrough)
|
||||
|
||||
conftest_code="
|
||||
void bar (void (*callback) (void));
|
||||
int foo (void)
|
||||
{
|
||||
int var = 0;
|
||||
void callback (void) { var = 1; }
|
||||
bar (callback);
|
||||
return var;
|
||||
}
|
||||
"
|
||||
|
||||
dnl Check if TEST_CC support trampolines.
|
||||
LIBC_TRY_TEST_CC_COMMAND([support for trampolines],
|
||||
[$conftest_code],
|
||||
[-c -Werror],
|
||||
libc_cv_test_cc_trampolines,
|
||||
[libc_cv_test_cc_trampolines=yes],
|
||||
[libc_cv_test_cc_trampolines=no]
|
||||
)
|
||||
LIBC_CONFIG_VAR([have-test-cc-trampoline],
|
||||
[$libc_cv_test_cc_trampolines])
|
||||
|
||||
dnl Check if TEST_CC supports -finput-charset=ascii.
|
||||
LIBC_TRY_TEST_CC_OPTION([-finput-charset=ascii],
|
||||
[-c -Werror -finput-charset=ascii],
|
||||
|
|
|
@ -557,12 +557,14 @@ endif
|
|||
selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
|
||||
|
||||
ifneq ($(selinux-enabled),1)
|
||||
ifeq ($(have-test-cc-trampoline),yes)
|
||||
tests-execstack-yes = \
|
||||
tst-execstack \
|
||||
tst-execstack-needed \
|
||||
tst-execstack-prog \
|
||||
# tests-execstack-yes
|
||||
endif
|
||||
endif
|
||||
ifeq ($(have-depaudit),yes)
|
||||
tests += \
|
||||
tst-audit14 \
|
||||
|
@ -1146,7 +1148,9 @@ tests-pie += vismain
|
|||
CFLAGS-vismain.c += $(PIE-ccflag)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(have-test-cc-trampoline),yes)
|
||||
modules-execstack-yes = tst-execstack-mod
|
||||
endif
|
||||
extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
|
||||
|
||||
# filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
|
||||
|
|
|
@ -474,7 +474,7 @@ tests-internal += \
|
|||
tst-tls3-malloc \
|
||||
tst-tls5 \
|
||||
# tests-internal
|
||||
ifeq ($(have-z-execstack),yes)
|
||||
ifeq ($(have-z-execstack)$(have-test-cc-trampoline),yesyes)
|
||||
tests += tst-execstack-threads
|
||||
endif
|
||||
endif
|
||||
|
@ -483,7 +483,6 @@ modules-names = \
|
|||
tst-audit-threads-mod1 \
|
||||
tst-audit-threads-mod2 \
|
||||
tst-compat-forwarder-mod \
|
||||
tst-execstack-threads-mod \
|
||||
tst-stack4mod \
|
||||
tst-tls3mod \
|
||||
tst-tls5mod \
|
||||
|
@ -504,6 +503,12 @@ test-extras += \
|
|||
tst-cleanupx4aux \
|
||||
# test-extras
|
||||
|
||||
ifneq ($(have-test-clang),yes)
|
||||
modules-names += \
|
||||
tst-execstack-threads-mod \
|
||||
# modules-names
|
||||
endif
|
||||
|
||||
# This test exercises compat symbols removed in glibc 2.34.
|
||||
ifdef have-GLIBC_2.33
|
||||
tests += tst-cleanup4
|
||||
|
|
Loading…
Add table
Reference in a new issue