mirror of
git://git.musl-libc.org/musl
synced 2024-12-21 22:30:09 +00:00
35cd7c0950
if __cp_cancel was reached via __syscall_cp, r12 will necessarily
still contain a GOT pointer (for libc.so or for the static-linked main
program) valid for entering __cancel. however, in the case of async
cancellation, r12 may contain any scratch value; it's not necessarily
even a valid GOT pointer for the code that was interrupted.
unlike in commit 0ec49dab67
where the
corresponding issue was fixed for powerpc64, there is fundamentally no
way for fdpic code to recompute its GOT pointer. so a new mechanism is
introduced for cancel_handler to write a GOT register value into the
interrupted context on archs where it is needed.
18 lines
432 B
C
18 lines
432 B
C
static inline struct pthread *__pthread_self()
|
|
{
|
|
char *self;
|
|
__asm__ __volatile__ ("stc gbr,%0" : "=r" (self) );
|
|
return (struct pthread *) (self - sizeof(struct pthread));
|
|
}
|
|
|
|
#define TLS_ABOVE_TP
|
|
#define GAP_ABOVE_TP 8
|
|
#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
|
|
|
|
#define MC_PC sc_pc
|
|
|
|
#ifdef __FDPIC__
|
|
#define MC_GOT sc_regs[12]
|
|
#define CANCEL_GOT (*(uintptr_t *)((char *)__syscall_cp_asm+sizeof(uintptr_t)))
|
|
#endif
|