On Monday, July 29, 2024, Thiago Macieira wrote:
I was hasty in my reply, because you need to store at least one thing to make
it work: the return address you replaced with yours. You can't keep it r10
because it's a volatile register. You can't use the stack because you have
none available. You have to use a thread-local variable and to make that
reentrant, you'd need to have a linked list of return addresses allocated
using the heap. So it's possible... just terribly cumbersome.
I don't know where you're going with your linked list. If you look at the GodBolt I gave you, you'll see I have it working on x86_32 with one simple thread-local variable.
Ain't no linked lists round these parts.