mirror of
git://git.musl-libc.org/musl
synced 2024-12-14 02:35:17 +00:00
remove redundant pthread struct members repeated for layout purposes
dtv_copy, canary2, and canary_at_end existed solely to match multiple ABI and asm-accessed layouts simultaneously. now that pthread_arch.h can be included before struct __pthread is defined, the struct layout can depend on macros defined by pthread_arch.h.
This commit is contained in:
parent
3a5b9ae7cf
commit
57f6e85c9d
@ -14,5 +14,3 @@ static inline uintptr_t __get_tp()
|
||||
// the kernel calls the ip "nip", it's the first saved value after the 32
|
||||
// GPRs.
|
||||
#define MC_PC gregs[32]
|
||||
|
||||
#define CANARY canary_at_end
|
||||
|
@ -14,5 +14,3 @@ static inline uintptr_t __get_tp()
|
||||
// the kernel calls the ip "nip", it's the first saved value after the 32
|
||||
// GPRs.
|
||||
#define MC_PC gp_regs[32]
|
||||
|
||||
#define CANARY canary_at_end
|
||||
|
@ -7,6 +7,6 @@ static inline uintptr_t __get_tp()
|
||||
|
||||
#define MC_PC gregs[REG_RIP]
|
||||
|
||||
#define CANARY canary2
|
||||
#define CANARY_PAD
|
||||
|
||||
#define tls_mod_off_t unsigned long long
|
||||
|
@ -1579,7 +1579,7 @@ static void install_new_tls(void)
|
||||
|
||||
/* Install new dtv for each thread. */
|
||||
for (j=0, td=self; !j || td!=self; j++, td=td->next) {
|
||||
td->dtv = td->dtv_copy = newdtv[j];
|
||||
td->dtv = newdtv[j];
|
||||
}
|
||||
|
||||
__tl_unlock();
|
||||
|
2
src/env/__init_tls.c
vendored
2
src/env/__init_tls.c
vendored
@ -67,7 +67,7 @@ void *__copy_tls(unsigned char *mem)
|
||||
}
|
||||
#endif
|
||||
dtv[0] = libc.tls_cnt;
|
||||
td->dtv = td->dtv_copy = dtv;
|
||||
td->dtv = dtv;
|
||||
return td;
|
||||
}
|
||||
|
||||
|
2
src/env/__stack_chk_fail.c
vendored
2
src/env/__stack_chk_fail.c
vendored
@ -9,7 +9,7 @@ void __init_ssp(void *entropy)
|
||||
if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));
|
||||
else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;
|
||||
|
||||
__pthread_self()->CANARY = __stack_chk_guard;
|
||||
__pthread_self()->canary = __stack_chk_guard;
|
||||
}
|
||||
|
||||
void __stack_chk_fail(void)
|
||||
|
@ -11,16 +11,25 @@
|
||||
#include "atomic.h"
|
||||
#include "futex.h"
|
||||
|
||||
#include "pthread_arch.h"
|
||||
|
||||
#define pthread __pthread
|
||||
|
||||
struct pthread {
|
||||
/* Part 1 -- these fields may be external or
|
||||
* internal (accessed via asm) ABI. Do not change. */
|
||||
struct pthread *self;
|
||||
#ifndef TLS_ABOVE_TP
|
||||
uintptr_t *dtv;
|
||||
#endif
|
||||
struct pthread *prev, *next; /* non-ABI */
|
||||
uintptr_t sysinfo;
|
||||
uintptr_t canary, canary2;
|
||||
#ifndef TLS_ABOVE_TP
|
||||
#ifdef CANARY_PAD
|
||||
uintptr_t canary_pad;
|
||||
#endif
|
||||
uintptr_t canary;
|
||||
#endif
|
||||
|
||||
/* Part 2 -- implementation details, non-ABI. */
|
||||
int tid;
|
||||
@ -52,8 +61,10 @@ struct pthread {
|
||||
|
||||
/* Part 3 -- the positions of these fields relative to
|
||||
* the end of the structure is external and internal ABI. */
|
||||
uintptr_t canary_at_end;
|
||||
uintptr_t *dtv_copy;
|
||||
#ifdef TLS_ABOVE_TP
|
||||
uintptr_t canary;
|
||||
uintptr_t *dtv;
|
||||
#endif
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -99,12 +110,6 @@ struct __timer {
|
||||
#define _b_waiters2 __u.__vi[4]
|
||||
#define _b_inst __u.__p[3]
|
||||
|
||||
#include "pthread_arch.h"
|
||||
|
||||
#ifndef CANARY
|
||||
#define CANARY canary
|
||||
#endif
|
||||
|
||||
#ifndef TP_OFFSET
|
||||
#define TP_OFFSET 0
|
||||
#endif
|
||||
|
@ -314,7 +314,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
|
||||
new->detach_state = DT_JOINABLE;
|
||||
}
|
||||
new->robust_list.head = &new->robust_list.head;
|
||||
new->CANARY = self->CANARY;
|
||||
new->canary = self->canary;
|
||||
new->sysinfo = self->sysinfo;
|
||||
|
||||
/* Setup argument structure for the new thread on its stack.
|
||||
|
Loading…
Reference in New Issue
Block a user