1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00
Files
glibc/sysdeps/unix/sysv/linux/aarch64/tst-tlsdesc-pac.c
Adhemerval Zanella 4352e2cc93 aarch64: Fix _dl_tlsdesc_dynamic unwind for pac-ret (BZ 32612)
When libgcc is built with pac-ret, it requires to autenticate the
unwinding frame based on CFI information.  The _dl_tlsdesc_dynamic
uses a custom calling convention, where it is responsible to save
and restore all registers it might use (even volatile).

The pac-ret support added by 1be3d6eb82
was added only on the slow-path, but the fast path also adds DWARF
Register Rule Instruction (cfi_adjust_cfa_offset) since it requires
to save/restore some auxiliary register.  It seems that this is not
fully supported neither by libgcc nor AArch64 ABI [1].

Instead, move paciasp/autiasp to function prologue/epilogue to be
used on both fast and slow paths.

I also corrected the _dl_tlsdesc_dynamic comment description, it was
copied from i386 implementation without any adjustment.

Checked on aarch64-linux-gnu with a toolchain built with
--enable-standard-branch-protection on a system with pac-ret
support.

[1]  https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#id1

Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
2025-03-31 10:08:06 -03:00

49 lines
1.4 KiB
C

/* AArch64 tests for unwinding TLSDESC (BZ 32612)
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 <stdlib.h>
#include <unwind.h>
#include <support/xdlfcn.h>
static _Unwind_Reason_Code
unwind_callback (struct _Unwind_Context* context, void* closure)
{
return _URC_NO_REASON;
}
/* Assume that TLS variable from tst-tlsdesc-pac-mod.so will trigger
the slow-path that allocates the required memory with malloc. */
void *
malloc (size_t s)
{
_Unwind_Backtrace (unwind_callback, NULL);
return calloc (1, s);
}
static int
do_test (void)
{
void *h = xdlopen ("tst-tlsdesc-pac-mod.so", RTLD_LAZY);
void (*func)(void) = xdlsym (h, "bar");
func ();
return 0;
}
#include <support/test-driver.c>