From e17b9d74740df413fae2502c0010591c7998c40d Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 6 Nov 2023 21:50:37 -0500 Subject: ldso: fix TLSDESC addend processing on archs with backwards descriptors presently this only affects 32-bit arm. despite correctly reversing the function pointer and argument fields based on the TLSDESC_BACKWARDS macro, we did not read the addend from the swapped-order argument field, so nonzero addends were lost, producing wrong runtime addresses for TLS objects needing an addend. based on report and patch by Rui Ueyama. --- ldso/dynlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ldso/dynlink.c b/ldso/dynlink.c index 6ba51b0a..324aa859 100644 --- a/ldso/dynlink.c +++ b/ldso/dynlink.c @@ -517,7 +517,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri break; #endif case REL_TLSDESC: - if (stride<3) addend = reloc_addr[1]; + if (stride<3) addend = reloc_addr[!TLSDESC_BACKWARDS]; if (def.dso->tls_id > static_tls_cnt) { struct td_index *new = malloc(sizeof *new); if (!new) { -- cgit v1.2.1