aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/x86
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/x86')
-rw-r--r--sysdeps/x86/Makefile51
-rw-r--r--sysdeps/x86/Versions5
-rw-r--r--sysdeps/x86/atomic-machine.h96
-rw-r--r--sysdeps/x86/configure139
-rw-r--r--sysdeps/x86/configure.ac76
-rw-r--r--sysdeps/x86/cpu-features.c14
-rw-r--r--sysdeps/x86/sysdep.h23
-rw-r--r--sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c2
-rw-r--r--sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c2
-rw-r--r--sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c2
-rw-r--r--sysdeps/x86/tst-gnu2-tls2.c36
-rw-r--r--sysdeps/x86/tst-gnu2-tls2.h37
-rw-r--r--sysdeps/x86/tst-tls23.c22
-rw-r--r--sysdeps/x86/tst-tls23.h35
14 files changed, 464 insertions, 76 deletions
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
index 01b0192..e32a430 100644
--- a/sysdeps/x86/Makefile
+++ b/sysdeps/x86/Makefile
@@ -4,7 +4,13 @@ endif
ifeq ($(subdir),elf)
sysdep_routines += get-cpuid-feature-leaf
-sysdep-dl-routines += dl-get-cpu-features
+sysdep-dl-routines += \
+ dl-get-cpu-features \
+ dl-tlsdesc \
+ tls_get_addr \
+ tlsdesc \
+# sysdep-dl-routines
+
sysdep_headers += \
bits/platform/features.h \
bits/platform/x86.h \
@@ -90,14 +96,22 @@ tst-ifunc-isa-2-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SSE4_2,-AVX,-AVX2,-AVX512
tst-ifunc-isa-2-static-ENV = $(tst-ifunc-isa-2-ENV)
tst-hwcap-tunables-ARGS = -- $(host-test-program-cmd)
-CFLAGS-tst-gnu2-tls2.c += -msse
+CFLAGS-tst-gnu2-tls2.c += -msse2
CFLAGS-tst-gnu2-tls2mod0.c += -msse2 -mtune=haswell
CFLAGS-tst-gnu2-tls2mod1.c += -msse2 -mtune=haswell
CFLAGS-tst-gnu2-tls2mod2.c += -msse2 -mtune=haswell
-LDFLAGS-tst-gnu2-tls2-x86-noxsave += -Wl,-z,lazy
-LDFLAGS-tst-gnu2-tls2-x86-noxsavec += -Wl,-z,lazy
-LDFLAGS-tst-gnu2-tls2-x86-noxsavexsavec += -Wl,-z,lazy
+LDFLAGS-tst-gnu2-tls2 += -rdynamic
+LDFLAGS-tst-gnu2-tls2mod0.so += -Wl,-z,undefs
+LDFLAGS-tst-gnu2-tls2mod1.so += -Wl,-z,undefs
+LDFLAGS-tst-gnu2-tls2mod2.so += -Wl,-z,undefs
+
+CFLAGS-tst-gnu2-tls2-x86-noxsave.c += -msse2
+CFLAGS-tst-gnu2-tls2-x86-noxsavec.c += -msse2
+CFLAGS-tst-gnu2-tls2-x86-noxsavexsavec.c += -msse2
+LDFLAGS-tst-gnu2-tls2-x86-noxsave += -Wl,-z,lazy -rdynamic
+LDFLAGS-tst-gnu2-tls2-x86-noxsavec += -Wl,-z,lazy -rdynamic
+LDFLAGS-tst-gnu2-tls2-x86-noxsavexsavec += -Wl,-z,lazy -rdynamic
# Test for bug 32810: incorrect XSAVE state size if XSAVEC is disabled
# via tunable.
@@ -113,6 +127,33 @@ $(objpfx)tst-gnu2-tls2-x86-noxsavexsavec.out: \
$(objpfx)tst-gnu2-tls2mod0.so \
$(objpfx)tst-gnu2-tls2mod1.so \
$(objpfx)tst-gnu2-tls2mod2.so
+
+CFLAGS-tst-tls23.c += -msse2
+CFLAGS-tst-tls23-mod.c += -msse2 -mtune=haswell
+
+LDFLAGS-tst-tls23 += -rdynamic
+tst-tls23-mod.so-no-z-defs = yes
+
+$(objpfx)tst-tls23-mod.so: $(libsupport)
+
+tests-special += $(objpfx)check-gnu2-tls.out
+
+$(objpfx)check-gnu2-tls.out: $(common-objpfx)libc.so
+ LC_ALL=C $(READELF) -V -W $< \
+ | sed -ne '/.gnu.version_d/, /.gnu.version_r/ p' \
+ | grep GLIBC_ABI_GNU2_TLS > $@; \
+ $(evaluate-test)
+generated += check-gnu2-tls.out
+
+ifneq (,$(test-cc-cflags-no-direct-extern-access))
+CFLAGS-tst-protected1a.c += $(test-cc-cflags-no-direct-extern-access)
+CFLAGS-tst-protected1b.c += $(test-cc-cflags-no-direct-extern-access)
+CFLAGS-vismain.c += $(test-cc-cflags-no-direct-extern-access)
+endif
+endif
+
+ifeq ($(subdir),gmon)
+CFLAGS-mcount.c += -mgeneral-regs-only
endif
ifeq ($(subdir),math)
diff --git a/sysdeps/x86/Versions b/sysdeps/x86/Versions
index 4b10c4b..e8dcfcc 100644
--- a/sysdeps/x86/Versions
+++ b/sysdeps/x86/Versions
@@ -7,4 +7,9 @@ libc {
GLIBC_2.33 {
__x86_get_cpuid_feature_leaf;
}
+ GLIBC_ABI_GNU2_TLS {
+ # This symbol is used only for empty version map and will be removed
+ # by scripts/versions.awk.
+ __placeholder_only_for_empty_version_map;
+ }
}
diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h
index 5452716..ac59f77 100644
--- a/sysdeps/x86/atomic-machine.h
+++ b/sysdeps/x86/atomic-machine.h
@@ -256,22 +256,22 @@
#define atomic_add_negative(mem, value) \
- ({ unsigned char __result; \
+ ({ _Bool __result; \
if (sizeof (*mem) == 1) \
- __asm __volatile (LOCK_PREFIX "addb %b2, %0; sets %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "addb %b2, %0" \
+ : "=m" (*mem), "=@ccs" (__result) \
: IBR_CONSTRAINT (value), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm __volatile (LOCK_PREFIX "addw %w2, %0; sets %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "addw %w2, %0" \
+ : "=m" (*mem), "=@ccs" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm __volatile (LOCK_PREFIX "addl %2, %0; sets %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "addl %2, %0" \
+ : "=m" (*mem), "=@ccs" (__result) \
: "ir" (value), "m" (*mem)); \
else if (__HAVE_64B_ATOMICS) \
- __asm __volatile (LOCK_PREFIX "addq %q2, %0; sets %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "addq %q2, %0" \
+ : "=m" (*mem), "=@ccs" (__result) \
: "ir" ((int64_t) cast_to_integer (value)), \
"m" (*mem)); \
else \
@@ -280,26 +280,26 @@
#define atomic_add_zero(mem, value) \
- ({ unsigned char __result; \
+ ({ _Bool __result; \
if (sizeof (*mem) == 1) \
- __asm __volatile (LOCK_PREFIX "addb %b2, %0; setz %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "addb %b2, %0" \
+ : "=m" (*mem), "=@ccz" (__result) \
: IBR_CONSTRAINT (value), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm __volatile (LOCK_PREFIX "addw %w2, %0; setz %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "addw %w2, %0" \
+ : "=m" (*mem), "=@ccz" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm __volatile (LOCK_PREFIX "addl %2, %0; setz %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "addl %2, %0" \
+ : "=m" (*mem), "=@ccz" (__result) \
: "ir" (value), "m" (*mem)); \
else if (__HAVE_64B_ATOMICS) \
- __asm __volatile (LOCK_PREFIX "addq %q2, %0; setz %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "addq %q2, %0" \
+ : "=m" (*mem), "=@ccz" (__result) \
: "ir" ((int64_t) cast_to_integer (value)), \
"m" (*mem)); \
else \
- __atomic_link_error (); \
+ __atomic_link_error (); \
__result; })
@@ -339,25 +339,25 @@
#define atomic_increment_and_test(mem) \
- ({ unsigned char __result; \
+ ({ _Bool __result; \
if (sizeof (*mem) == 1) \
- __asm __volatile (LOCK_PREFIX "incb %b0; sete %b1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "incb %b0" \
+ : "=m" (*mem), "=@cce" (__result) \
: "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm __volatile (LOCK_PREFIX "incw %w0; sete %w1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "incw %w0" \
+ : "=m" (*mem), "=@cce" (__result) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm __volatile (LOCK_PREFIX "incl %0; sete %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "incl %0" \
+ : "=m" (*mem), "=@cce" (__result) \
: "m" (*mem)); \
else if (__HAVE_64B_ATOMICS) \
- __asm __volatile (LOCK_PREFIX "incq %q0; sete %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "incq %q0" \
+ : "=m" (*mem), "=@cce" (__result) \
: "m" (*mem)); \
else \
- __atomic_link_error (); \
+ __atomic_link_error (); \
__result; })
@@ -397,22 +397,22 @@
#define atomic_decrement_and_test(mem) \
- ({ unsigned char __result; \
+ ({ _Bool __result; \
if (sizeof (*mem) == 1) \
- __asm __volatile (LOCK_PREFIX "decb %b0; sete %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "decb %b0" \
+ : "=m" (*mem), "=@cce" (__result) \
: "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm __volatile (LOCK_PREFIX "decw %w0; sete %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "decw %w0" \
+ : "=m" (*mem), "=@cce" (__result) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm __volatile (LOCK_PREFIX "decl %0; sete %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "decl %0" \
+ : "=m" (*mem), "=@cce" (__result) \
: "m" (*mem)); \
else \
- __asm __volatile (LOCK_PREFIX "decq %q0; sete %1" \
- : "=m" (*mem), "=qm" (__result) \
+ __asm __volatile (LOCK_PREFIX "decq %q0" \
+ : "=m" (*mem), "=@cce" (__result) \
: "m" (*mem)); \
__result; })
@@ -445,25 +445,25 @@
#define atomic_bit_test_set(mem, bit) \
- ({ unsigned char __result; \
+ ({ _Bool __result; \
if (sizeof (*mem) == 1) \
- __asm __volatile (LOCK_PREFIX "btsb %3, %1; setc %0" \
- : "=q" (__result), "=m" (*mem) \
+ __asm __volatile (LOCK_PREFIX "btsb %3, %1" \
+ : "=@ccc" (__result), "=m" (*mem) \
: "m" (*mem), IBR_CONSTRAINT (bit)); \
else if (sizeof (*mem) == 2) \
- __asm __volatile (LOCK_PREFIX "btsw %3, %1; setc %0" \
- : "=q" (__result), "=m" (*mem) \
+ __asm __volatile (LOCK_PREFIX "btsw %3, %1" \
+ : "=@ccc" (__result), "=m" (*mem) \
: "m" (*mem), "ir" (bit)); \
else if (sizeof (*mem) == 4) \
- __asm __volatile (LOCK_PREFIX "btsl %3, %1; setc %0" \
- : "=q" (__result), "=m" (*mem) \
+ __asm __volatile (LOCK_PREFIX "btsl %3, %1" \
+ : "=@ccc" (__result), "=m" (*mem) \
: "m" (*mem), "ir" (bit)); \
else if (__HAVE_64B_ATOMICS) \
- __asm __volatile (LOCK_PREFIX "btsq %3, %1; setc %0" \
- : "=q" (__result), "=m" (*mem) \
+ __asm __volatile (LOCK_PREFIX "btsq %3, %1" \
+ : "=@ccc" (__result), "=m" (*mem) \
: "m" (*mem), "ir" (bit)); \
else \
- __atomic_link_error (); \
+ __atomic_link_error (); \
__result; })
diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure
index c7ea9ac..a021cdb 100644
--- a/sysdeps/x86/configure
+++ b/sysdeps/x86/configure
@@ -66,7 +66,7 @@ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest c
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then
count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l`
- if test "$count" = 1; then
+ if test "$count" -eq 1; then
libc_cv_include_x86_isa_level=yes
fi
fi
@@ -171,8 +171,12 @@ fi
config_vars="$config_vars
have-x86-isa-level = $libc_cv_have_x86_isa_level"
config_vars="$config_vars
+x86-isa-level-2-or-above = 2 3 4"
+config_vars="$config_vars
x86-isa-level-3-or-above = 3 4"
config_vars="$config_vars
+x86-isa-level-4-or-above = 4"
+config_vars="$config_vars
enable-x86-isa-level = $libc_cv_include_x86_isa_level"
@@ -185,7 +189,7 @@ if test ${libc_cv_have_test_cc_cflags_mfpmath_387+y}
then :
printf %s "(cached) " >&6
else case e in #(
- e) if { ac_try='${CC-cc} -c -Werror -mfpmath=387 -xc /dev/null -S -o /dev/null'
+ e) if { ac_try='${CC-cc} -Werror -mfpmath=387 -xc /dev/null -S -o /dev/null'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
@@ -209,6 +213,137 @@ CC="$saved_CC"
config_vars="$config_vars
have-test-cc-cflags-mfpmath-387 = $libc_cv_have_test_cc_cflags_mfpmath_387"
+conftest_code="
+extern int foo;
+int *
+foo_p (void)
+{
+ return &foo;
+}
+"
+
+cat > conftest.c <<EOF
+$conftest_code
+EOF
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if no direct extern access is enabled by default" >&5
+printf %s "checking if no direct extern access is enabled by default... " >&6; }
+if test ${libc_cv_cc_no_direct_extern_access+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -S -O2 -fno-pic 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_cc_cflags_no_direct_extern_access=no
+if test "$base_machine" = x86_64; then
+ if grep -E -q "mov[lq][ ]+foo@GOTPCREL\(%rip\)," conftest; then
+ libc_cv_cc_no_direct_extern_access=yes
+ fi
+elif test "$base_machine" = i386; then
+ if grep -E -q "movl[ ]+foo@GOT," conftest; then
+ libc_cv_cc_no_direct_extern_access=yes
+ fi
+else
+ echo unsupported machine: $base_machine
+ rm -f conftest*
+ exit 1
+fi
+
+ else
+
+echo failed to check no direct external data access
+rm -f conftest*
+exit 1
+
+ fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_no_direct_extern_access" >&5
+printf "%s\n" "$libc_cv_cc_no_direct_extern_access" >&6; }
+rm -f conftest*
+
+
+
+saved_CC="$CC"
+CC="$TEST_CC"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -mno-direct-extern-access works in testing" >&5
+printf %s "checking if -mno-direct-extern-access works in testing... " >&6; }
+if test ${libc_cv_test_cc_cflags_mno_direct_extern_access+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) if { ac_try='${CC-cc} -Werror -mno-direct-extern-access -xc /dev/null -S -o /dev/null'
+ { { 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_cflags_mno_direct_extern_access=yes
+else case e in #(
+ e) libc_cv_test_cc_cflags_mno_direct_extern_access=no
+ ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_cflags_mno_direct_extern_access" >&5
+printf "%s\n" "$libc_cv_test_cc_cflags_mno_direct_extern_access" >&6; }
+
+CC="$saved_CC"
+
+
+
+
+
+saved_CC="$CC"
+CC="$TEST_CC"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -fno-direct-access-external-data works in testing" >&5
+printf %s "checking if -fno-direct-access-external-data works in testing... " >&6; }
+if test ${libc_cv_test_cc_cflags_fno_direct_access_external_data+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) if { ac_try='${CC-cc} -Werror -fno-direct-access-external-data -xc /dev/null -S -o /dev/null'
+ { { 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_cflags_fno_direct_access_external_data=yes
+else case e in #(
+ e) libc_cv_test_cc_cflags_fno_direct_access_external_data=no
+ ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_cflags_fno_direct_access_external_data" >&5
+printf "%s\n" "$libc_cv_test_cc_cflags_fno_direct_access_external_data" >&6; }
+
+CC="$saved_CC"
+
+
+
+if test $libc_cv_test_cc_cflags_mno_direct_extern_access = yes; then
+ libc_cv_test_cc_cflags_no_direct_extern_access="-mno-direct-extern-access"
+elif test $libc_cv_test_cc_cflags_fno_direct_access_external_data = yes; then
+ libc_cv_test_cc_cflags_no_direct_extern_access="-fno-direct-access-external-data"
+fi
+
+config_vars="$config_vars
+test-cc-cflags-no-direct-extern-access = $libc_cv_test_cc_cflags_no_direct_extern_access"
+
+if test "${libc_cv_cc_no_direct_extern_access}${libc_cv_test_cc_cflags_no_direct_extern_access}" = yes; then
+ libc_cv_protected_data=no
+fi
+
printf "%s\n" "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac
index 031f917..a87e2f6 100644
--- a/sysdeps/x86/configure.ac
+++ b/sysdeps/x86/configure.ac
@@ -57,7 +57,7 @@ EOF
libc_cv_include_x86_isa_level=no
if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest conftest1.S conftest2.S); then
count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l`
- if test "$count" = 1; then
+ if test "$count" -eq 1; then
libc_cv_include_x86_isa_level=yes
fi
fi
@@ -117,12 +117,14 @@ else
AC_DEFINE_UNQUOTED(MINIMUM_X86_ISA_LEVEL, $libc_cv_have_x86_isa_level)
fi
LIBC_CONFIG_VAR([have-x86-isa-level], [$libc_cv_have_x86_isa_level])
+LIBC_CONFIG_VAR([x86-isa-level-2-or-above], [2 3 4])
LIBC_CONFIG_VAR([x86-isa-level-3-or-above], [3 4])
+LIBC_CONFIG_VAR([x86-isa-level-4-or-above], [4])
LIBC_CONFIG_VAR([enable-x86-isa-level], [$libc_cv_include_x86_isa_level])
dnl Check if TEST_CC supports -mfpmath=387
LIBC_TRY_TEST_CC_OPTION([if -mfpmath=387 works],
- [-c -Werror -mfpmath=387],
+ [-Werror -mfpmath=387],
libc_cv_have_test_cc_cflags_mfpmath_387,
[libc_cv_have_test_cc_cflags_mfpmath_387=yes],
[libc_cv_have_test_cc_cflags_mfpmath_387=no]
@@ -130,5 +132,75 @@ LIBC_TRY_TEST_CC_OPTION([if -mfpmath=387 works],
LIBC_CONFIG_VAR(have-test-cc-cflags-mfpmath-387,
$libc_cv_have_test_cc_cflags_mfpmath_387)
+conftest_code="
+extern int foo;
+int *
+foo_p (void)
+{
+ return &foo;
+}
+"
+dnl Check if CC enables no direct extern access by default.
+LIBC_TRY_CC_COMMAND([if no direct extern access is enabled by default],
+ [$conftest_code],
+ [-S -O2 -fno-pic],
+ libc_cv_cc_no_direct_extern_access,
+ [
+libc_cv_cc_cflags_no_direct_extern_access=no
+if test "$base_machine" = x86_64; then
+ if grep -E -q "mov[lq][ ]+foo@GOTPCREL\(%rip\)," conftest; then
+ libc_cv_cc_no_direct_extern_access=yes
+ fi
+elif test "$base_machine" = i386; then
+ if grep -E -q "movl[ ]+foo@GOT," conftest; then
+ libc_cv_cc_no_direct_extern_access=yes
+ fi
+else
+ echo unsupported machine: $base_machine
+ rm -f conftest*
+ exit 1
+fi
+ ],
+ [
+echo failed to check no direct external data access
+rm -f conftest*
+exit 1
+])
+
+dnl Check if TEST_CC supports -mno-direct-extern-access.
+LIBC_TRY_TEST_CC_OPTION([if -mno-direct-extern-access works],
+ [-Werror -mno-direct-extern-access],
+ libc_cv_test_cc_cflags_mno_direct_extern_access,
+ [libc_cv_test_cc_cflags_mno_direct_extern_access=yes],
+ [libc_cv_test_cc_cflags_mno_direct_extern_access=no]
+)
+
+dnl Check if TEST_CC supports -fno-direct-access-external-data.
+LIBC_TRY_TEST_CC_OPTION([if -fno-direct-access-external-data works],
+ [-Werror -fno-direct-access-external-data],
+ libc_cv_test_cc_cflags_fno_direct_access_external_data,
+ [libc_cv_test_cc_cflags_fno_direct_access_external_data=yes],
+ [libc_cv_test_cc_cflags_fno_direct_access_external_data=no]
+)
+
+if test $libc_cv_test_cc_cflags_mno_direct_extern_access = yes; then
+ libc_cv_test_cc_cflags_no_direct_extern_access="-mno-direct-extern-access"
+elif test $libc_cv_test_cc_cflags_fno_direct_access_external_data = yes; then
+ libc_cv_test_cc_cflags_no_direct_extern_access="-fno-direct-access-external-data"
+fi
+
+LIBC_CONFIG_VAR(test-cc-cflags-no-direct-extern-access,
+ $libc_cv_test_cc_cflags_no_direct_extern_access)
+
+dnl If the building compiler enables no direct external data access by
+dnl default, access to protected data in shared libraries from executables
+dnl must be compiled with no direct external data access. If the testing
+dnl compiler doesn't support it, set have-protected-data to no to disable
+dnl the tests which requires no direct external data access.
+dnl
+if test "${libc_cv_cc_no_direct_extern_access}${libc_cv_test_cc_cflags_no_direct_extern_access}" = yes; then
+ libc_cv_protected_data=no
+fi
+
dnl Static PIE is supported.
AC_DEFINE(SUPPORT_STATIC_PIE)
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index b13b7b7..b7d1506 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -542,6 +542,7 @@ enum intel_microarch
INTEL_BIGCORE_ARROWLAKE,
INTEL_BIGCORE_PANTHERLAKE,
INTEL_BIGCORE_GRANITERAPIDS,
+ INTEL_BIGCORE_DIAMONDRAPIDS,
/* Mixed (bigcore + atom SOC). */
INTEL_MIXED_LAKEFIELD,
@@ -817,6 +818,16 @@ disable_tsx:
break;
}
}
+ else if (family == 19)
+ switch (model)
+ {
+ case 0x01:
+ microarch = INTEL_BIGCORE_DIAMONDRAPIDS;
+ break;
+
+ default:
+ break;
+ }
switch (microarch)
{
@@ -926,6 +937,7 @@ disable_tsx:
case INTEL_BIGCORE_SAPPHIRERAPIDS:
case INTEL_BIGCORE_EMERALDRAPIDS:
case INTEL_BIGCORE_GRANITERAPIDS:
+ case INTEL_BIGCORE_DIAMONDRAPIDS:
/* Default tuned Mixed (bigcore + atom SOC). */
case INTEL_MIXED_LAKEFIELD:
case INTEL_MIXED_ALDERLAKE:
@@ -1244,7 +1256,7 @@ no_cpuid:
#endif
if (MINIMUM_X86_ISA_LEVEL >= AVX_X86_ISA_LEVEL
- || (GLRO(dl_x86_cpu_features).xsave_state_size != 0))
+ || cpu_features->xsave_state_size != 0)
{
if (CPU_FEATURE_USABLE_P (cpu_features, XSAVEC))
{
diff --git a/sysdeps/x86/sysdep.h b/sysdeps/x86/sysdep.h
index c3c73e7..b8e963b 100644
--- a/sysdeps/x86/sysdep.h
+++ b/sysdeps/x86/sysdep.h
@@ -183,6 +183,29 @@
#define atom_text_section .section ".text.atom", "ax"
+#ifndef DL_STACK_ALIGNMENT
+/* Due to GCC bug:
+
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066
+
+ __tls_get_addr may be called with 8-byte/4-byte stack alignment.
+ Although this bug has been fixed in GCC 4.9.4, 5.3 and 6, we can't
+ assume that stack will be always aligned at 16 bytes. */
+# ifdef __x86_64__
+# define DL_STACK_ALIGNMENT 8
+# define MINIMUM_ALIGNMENT 16
+# else
+# define DL_STACK_ALIGNMENT 4
+# endif
+#endif
+
+/* True if _dl_runtime_resolve/_dl_tlsdesc_dynamic should align stack for
+ STATE_SAVE or align stack to MINIMUM_ALIGNMENT bytes before calling
+ _dl_fixup/__tls_get_addr. */
+#define DL_RUNTIME_RESOLVE_REALIGN_STACK \
+ (STATE_SAVE_ALIGNMENT > DL_STACK_ALIGNMENT \
+ || MINIMUM_ALIGNMENT > DL_STACK_ALIGNMENT)
+
#endif /* __ASSEMBLER__ */
#endif /* _X86_SYSDEP_H */
diff --git a/sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c b/sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c
index f0024c1..963c4f3 100644
--- a/sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c
+++ b/sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
diff --git a/sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c b/sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c
index f0024c1..963c4f3 100644
--- a/sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c
+++ b/sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
diff --git a/sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c b/sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c
index f0024c1..963c4f3 100644
--- a/sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c
+++ b/sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
diff --git a/sysdeps/x86/tst-gnu2-tls2.c b/sysdeps/x86/tst-gnu2-tls2.c
index de900a4..b3195ff 100644
--- a/sysdeps/x86/tst-gnu2-tls2.c
+++ b/sysdeps/x86/tst-gnu2-tls2.c
@@ -1,20 +1,26 @@
-#ifndef __x86_64__
-#include <sys/platform/x86.h>
+#ifndef TEST_AMX
+# ifndef __x86_64__
+# include <sys/platform/x86.h>
-#define IS_SUPPORTED() CPU_FEATURE_ACTIVE (SSE2)
-#endif
+# define IS_SUPPORTED() CPU_FEATURE_ACTIVE (SSE2)
+# endif
-/* Clear XMM0...XMM7 */
-#define PREPARE_MALLOC() \
-{ \
- asm volatile ("xorps %%xmm0, %%xmm0" : : : "xmm0" ); \
- asm volatile ("xorps %%xmm1, %%xmm1" : : : "xmm1" ); \
- asm volatile ("xorps %%xmm2, %%xmm2" : : : "xmm2" ); \
- asm volatile ("xorps %%xmm3, %%xmm3" : : : "xmm3" ); \
- asm volatile ("xorps %%xmm4, %%xmm4" : : : "xmm4" ); \
- asm volatile ("xorps %%xmm5, %%xmm5" : : : "xmm5" ); \
- asm volatile ("xorps %%xmm6, %%xmm6" : : : "xmm6" ); \
- asm volatile ("xorps %%xmm7, %%xmm7" : : : "xmm7" ); \
+/* Set XMM0...XMM7 to all 1s. */
+# define PREPARE_MALLOC() \
+{ \
+ asm volatile ("pcmpeqd %%xmm0, %%xmm0" : : : "xmm0" ); \
+ asm volatile ("pcmpeqd %%xmm1, %%xmm1" : : : "xmm1" ); \
+ asm volatile ("pcmpeqd %%xmm2, %%xmm2" : : : "xmm2" ); \
+ asm volatile ("pcmpeqd %%xmm3, %%xmm3" : : : "xmm3" ); \
+ asm volatile ("pcmpeqd %%xmm4, %%xmm4" : : : "xmm4" ); \
+ asm volatile ("pcmpeqd %%xmm5, %%xmm5" : : : "xmm5" ); \
+ asm volatile ("pcmpeqd %%xmm6, %%xmm6" : : : "xmm6" ); \
+ asm volatile ("pcmpeqd %%xmm7, %%xmm7" : : : "xmm7" ); \
}
+#endif
#include <elf/tst-gnu2-tls2.c>
+
+#ifndef TEST_AMX
+v2di v1, v2, v3;
+#endif
diff --git a/sysdeps/x86/tst-gnu2-tls2.h b/sysdeps/x86/tst-gnu2-tls2.h
new file mode 100644
index 0000000..fdbb565
--- /dev/null
+++ b/sysdeps/x86/tst-gnu2-tls2.h
@@ -0,0 +1,37 @@
+/* Test TLSDESC relocation, x86 version.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef TEST_AMX
+# include <support/check.h>
+
+typedef long long v2di __attribute__((vector_size(16)));
+extern v2di v1, v2, v3;
+
+# define BEFORE_TLSDESC_CALL() \
+ v1 = __extension__(v2di){0, 0}; \
+ v2 = __extension__(v2di){0, 0};
+
+# define AFTER_TLSDESC_CALL() \
+ v3 = __extension__(v2di){0, 0}; \
+ asm volatile ("" : "+x" (v3)); \
+ union { v2di x; long long a[2]; } u; \
+ u.x = v3; \
+ TEST_VERIFY_EXIT (u.a[0] == 0 && u.a[1] == 0);
+#endif
+
+#include <elf/tst-gnu2-tls2.h>
diff --git a/sysdeps/x86/tst-tls23.c b/sysdeps/x86/tst-tls23.c
new file mode 100644
index 0000000..6130d91
--- /dev/null
+++ b/sysdeps/x86/tst-tls23.c
@@ -0,0 +1,22 @@
+#ifndef __x86_64__
+#include <sys/platform/x86.h>
+
+#define IS_SUPPORTED() CPU_FEATURE_ACTIVE (SSE2)
+#endif
+
+/* Set XMM0...XMM7 to all 1s. */
+#define PREPARE_MALLOC() \
+{ \
+ asm volatile ("pcmpeqd %%xmm0, %%xmm0" : : : "xmm0" ); \
+ asm volatile ("pcmpeqd %%xmm1, %%xmm1" : : : "xmm1" ); \
+ asm volatile ("pcmpeqd %%xmm2, %%xmm2" : : : "xmm2" ); \
+ asm volatile ("pcmpeqd %%xmm3, %%xmm3" : : : "xmm3" ); \
+ asm volatile ("pcmpeqd %%xmm4, %%xmm4" : : : "xmm4" ); \
+ asm volatile ("pcmpeqd %%xmm5, %%xmm5" : : : "xmm5" ); \
+ asm volatile ("pcmpeqd %%xmm6, %%xmm6" : : : "xmm6" ); \
+ asm volatile ("pcmpeqd %%xmm7, %%xmm7" : : : "xmm7" ); \
+}
+
+#include <elf/tst-tls23.c>
+
+v2di v1, v2, v3;
diff --git a/sysdeps/x86/tst-tls23.h b/sysdeps/x86/tst-tls23.h
new file mode 100644
index 0000000..21cee4c
--- /dev/null
+++ b/sysdeps/x86/tst-tls23.h
@@ -0,0 +1,35 @@
+/* Test that __tls_get_addr preserves XMM registers.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+
+typedef long long v2di __attribute__((vector_size(16)));
+extern v2di v1, v2, v3;
+
+#define BEFORE_TLS_CALL() \
+ v1 = __extension__(v2di){0, 0}; \
+ v2 = __extension__(v2di){0, 0};
+
+#define AFTER_TLS_CALL() \
+ v3 = __extension__(v2di){0, 0}; \
+ asm volatile ("" : "+x" (v3)); \
+ union { v2di x; long long a[2]; } u; \
+ u.x = v3; \
+ TEST_VERIFY_EXIT (u.a[0] == 0 && u.a[1] == 0);
+
+#include <elf/tst-tls23.h>