[Bug malloc/32996] i386 TLS helper functions don't preserve XMM registers

fweimer at redhat dot com sourceware-bugzilla@sourceware.org
Sun Jun 8 08:46:50 GMT 2025


https://sourceware.org/bugzilla/show_bug.cgi?id=32996

--- Comment #16 from Florian Weimer <fweimer at redhat dot com> ---
(In reply to H.J. Lu from comment #15)
> The problem is that GCC thinks that ___tls_get_addr only clobbers bx, dx and
> cx:
> 
> (insn:TI 5 19 6 2 (parallel [
>             (set (reg/f:SI 0 ax [101])
>                 (unspec:SI [
>                         (reg:SI 3 bx [98])
>                         (symbol_ref:SI ("x") [flags 0x10]  <var_decl
> 0x7fd38b5a0
> 130 x>)
>                         (symbol_ref:SI ("___tls_get_addr"))
>                         (reg/f:SI 7 sp)
>                     ] UNSPEC_TLS_GD))
>             (clobber (reg:SI 1 dx [103]))
>             (clobber (reg:SI 2 cx [104]))
>             (clobber (reg:CC 17 flags))
>         ]) "x.c":6:10 1652 {*tls_global_dynamic_32_gnu}
>      (expr_list:REG_DEAD (reg:SI 3 bx [98])
>         (expr_list:REG_UNUSED (reg:CC 17 flags)
>             (expr_list:REG_UNUSED (reg:SI 2 cx [104])
>                 (expr_list:REG_UNUSED (reg:SI 1 dx [103])
>                     (nil))))))
> 
> But vector registers aren't preserved.

This is a bit odd because glibc takes care to preserve %ecx and %edx. Regarding
%ebx, the PLT stub may require that it has been set up as the GOT pointer, but
the call will not change it further.

Given that binaries that assume GCC's peculiar clobbers are out there, should
we adjust glibc (for ___tls_get_addr, with three underscores)? It looks like an
implementation could be mostly shared with the existing GNU2 TLS descriptor
callback.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list