mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Draft riscv64 TLSDESC implementation
@ 2023-08-22 17:38 Rich Felker
  2024-01-21 22:28 ` Rich Felker
  0 siblings, 1 reply; 10+ messages in thread
From: Rich Felker @ 2023-08-22 17:38 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

The psABI work is not finalized, but based on the current status of
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373, I think
the attached is a valid (but untested) implementation of TLSDESC for
riscv64. Actually activating it requires also adding the relocation
type macro to riscv64/reloc.h.

If any rv folks could look it over and make sure I haven't made any
stupid asm errors or missed any obvious optimizations, that would help
to quickly get this merged when the psABI is finalized.

Rich

[-- Attachment #2: tlsdesc.s --]
[-- Type: text/plain, Size: 590 bytes --]

.text
.global __tlsdesc_static
.hidden __tlsdesc_static
.type __tlsdesc_static,%function
__tlsdesc_static:
	ld a0,8(a0)
	jr t0

.global __tlsdesc_dynamic
.hidden __tlsdesc_dynamic
.type __tlsdesc_dynamic,%function
__tlsdesc_dynamic:
	add sp,sp,-8
	sd t1,(sp)
	sd t2,8(sp)

	ld t2,-8(tp) # t2=dtv

	ld a0,8(a0)  # a0=&{modidx,off}
	ld t1,8(a0)  # t1=off
	ld a0,(a0)   # a0=modidx
	sll a0,a0,3  # a0=8*modidx

	add a0,a0,t2 # a0=dtv+8*modidx
	ld a0,(a0)   # a0=dtv[modidx]
	add a0,a0,t1 # a0=dtv[modidx]+off
	sub a0,a0,tp # a0=dtv[modidx]+off-tp

	ld t1,(sp)
	ld t2,8(sp)
	add sp,sp,8
	jr t0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-01-27  0:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-22 17:38 [musl] Draft riscv64 TLSDESC implementation Rich Felker
2024-01-21 22:28 ` Rich Felker
2024-01-21 23:48   ` Fangrui Song
2024-01-22  0:03     ` Rich Felker
2024-01-22  3:41       ` Tatsuyuki Ishi
2024-01-23  8:52         ` Fangrui Song
2024-01-23 13:26           ` Rich Felker
2024-01-25  6:48             ` Fangrui Song
     [not found]             ` <CAN30aBFHo2NmDknvhVUyWOvXuhvFZBvrzO6vm1PqEB7e2P9NTg@mail.gmail.com>
2024-01-27  0:11               ` Fangrui Song
     [not found]   ` <DS7PR12MB576582CD9FF325AAE6FA8B0CCB762@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-01-22  3:38     ` Tatsuyuki Ishi

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).