Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lhupl8lxlpt.fsf@oldenburg.str.redhat.com>
Date: Thu, 11 Dec 2025 13:10:54 +0100
From: Florian Weimer <fweimer@...hat.com>
To: Bill Roberts <bill.roberts@....com>
Cc: musl@...ts.openwall.com
Subject: Re: [RFC 07/14] aarch64: rewrite tlsdesc reoutines in C
 using inline asm

* Bill Roberts:

> Rewrite the AArch64 __tlsdesc_dynamic and __tlsdesc_static
> routines from assembly into implementations using inline assembly.
>
> This change eliminates the need for handwritten function prologues and
> epilogues in tlsdesc.s, which simplifies maintenance and allows the compiler
> to automatically insert architecture features such as BTI landing pads and
> pointer authentication (PAC) sequences where applicable.
>
> Moving to C also enables the compiler to manage register allocation,
> stack usage, and ABI compliance automatically while keeping the low-level
> behavior (bitmasks and register accesses) explicit and verifiable.
>
> No functional changes intended.
>
> Signed-off-by: Bill Roberts <bill.roberts@....com>
> ---
>  src/ldso/aarch64/tlsdesc.c | 50 ++++++++++++++++++++++++++++++++++++++
>  src/ldso/aarch64/tlsdesc.s | 31 -----------------------
>  2 files changed, 50 insertions(+), 31 deletions(-)
>  create mode 100644 src/ldso/aarch64/tlsdesc.c
>  delete mode 100644 src/ldso/aarch64/tlsdesc.s
>
> diff --git a/src/ldso/aarch64/tlsdesc.c b/src/ldso/aarch64/tlsdesc.c
> new file mode 100644
> index 00000000..224a9387
> --- /dev/null
> +++ b/src/ldso/aarch64/tlsdesc.c
> @@ -0,0 +1,50 @@
> +#include <stddef.h>
> +#include <stdint.h>
> +
> +/* size_t __tlsdesc_static(size_t *a) { return a[1]; } */
> +__attribute__((visibility("hidden")))
> +size_t __tlsdesc_static(size_t *a)
> +{
> +	size_t result;
> +
> +	__asm__ __volatile__(
> +		"ldr %0, [%1, #8]\n\t"   /* result = *(a + 8) */
> +		: "=r"(result)
> +		: "r"(a)
> +		: "memory"
> +	);
> +
> +	return result;
> +}

I don't think these descriptor functions use the default AArch64 psABI,
so they can't be written in C (unless special compiler flags or function
attributes are used).

Thanks,
Florian

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.