]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
arm: Fix tst-gnu2-tls2
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 20 Jan 2026 13:11:10 +0000 (10:11 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 2 Feb 2026 17:37:05 +0000 (14:37 -0300)
On armv7a vfpv4 tst-gnu2-tls2 fails with:

  open tst-gnu2-tls2mod0.so
  open tst-gnu2-tls2mod1.so
  open tst-gnu2-tls2mod2.so
  close tst-gnu2-tls2mod0.so
  close tst-gnu2-tls2mod1.so
  open tst-gnu2-tls2mod0.so
  open tst-gnu2-tls2mod1.so
  Didn't expect signal from child: got `Aborted'

Because AFTER_TLSDESC_CALL might clobber caller-saved registers and
the zero array might call the memset function resolution, which itself
might clobber some vector registers.

The AFTER_TLSDESC_CALL calls memset and memcmp, and both the
lazy resolution and the routines themselves can clobber the
caller-saved registes used in the tests.

Checked on arm-linux-gnueabihf (armv7-a vpfv4 / QEMU).

Reviewed-by: Florian Weimer <fweimer@redhat.com>
sysdeps/arm/tst-gnu2-tls2.h

index 821551c85608ef9a1c42efc80cd4ed033ee7dee1..6fa98f83f63451cdff23fb04fbfbe72eccf7dae0 100644 (file)
       SAVE_VFP_D32                                     \
     }
 
-# define VFP_STACK_REQ (16*8)
-# if __BYTE_ORDER == __BIG_ENDIAN
-#  define DISP 7
-# else
-#  define DISP 0
-# endif
+# define VFP_STACK_REQ (16)
 
 # ifdef HAVE_ARM_PCS_VFP_D32
 #  define CHECK_VFP_D32                                                        \
-      char vfp[VFP_STACK_REQ];                                         \
+      uint64_t vfp[VFP_STACK_REQ];                                     \
       asm volatile ("vstmia %0, {d16-d31}\n"                           \
                    :                                                   \
                    : "r" (vfp)                                         \
                    : "memory");                                        \
                                                                        \
-      char expected[VFP_STACK_REQ] = { 0 };                            \
       for (int i = 0; i < 16; ++i)                                     \
-       expected[i * 8 + DISP] = i + 17;                                \
-                                                                       \
-      if (memcmp (vfp, expected, VFP_STACK_REQ) != 0)                  \
-        abort ();
+        if (vfp[i] != i + 17)                                          \
+         abort ();
 # else
 #  define CHECK_VFP_D32
 # endif
 # define AFTER_TLSDESC_CALL()                                          \
   if (hwcap & HWCAP_ARM_VFP)                                           \
     {                                                                  \
-      char vfp[VFP_STACK_REQ];                                         \
+      uint64_t vfp[VFP_STACK_REQ];                                     \
       asm volatile ("vstmia %0, {d0-d15}\n"                            \
                    :                                                   \
                    : "r" (vfp)                                         \
                    : "memory");                                        \
                                                                        \
-      char expected[VFP_STACK_REQ] = { 0 };                            \
       for (int i = 0; i < 16; ++i)                                     \
-       expected[i * 8 + DISP] = i + 1;                                 \
-                                                                       \
-      if (memcmp (vfp, expected, VFP_STACK_REQ) != 0)                  \
-        abort ();                                                      \
+        if (vfp[i] != i + 1)                                           \
+         abort ();                                                     \
     }                                                                  \
   if (hwcap & HWCAP_ARM_VFPD32)                                                \
     {                                                                  \