Permalink
Browse files

Add field to tls_tcb to support segmented stacks in LLVM

When segmented stack support is enabled, LLVM adds code in front of
every function to check if the stack is already exhausted, in which
case it calls __morestack. For this reason LLVM needs to know the lower
boundary of the stack to check against the stack pointer.
The stack boundary can be stored in this per-thread field (tcb_segstack)
and accessed via %fs:32 (x86_64) or %fs:16 (i386) from the code generated
by LLVM.
  • Loading branch information...
mneumann committed Jul 22, 2014
1 parent b22bdff commit 166bae116c2735bbfd353b135de67878e1e5744b
Showing with 6 additions and 2 deletions.
  1. +3 −1 sys/cpu/i386/include/tls.h
  2. +3 −1 sys/cpu/x86_64/include/tls.h
@@ -54,7 +54,9 @@ struct tls_tcb {
void *tcb_dtv; /* Dynamic Thread Vector */
void *tcb_pthread; /* thread library's data*/
int *tcb_errno_p; /* pointer to per-thread errno */
void *tcb_unused[4];
void *tcb_segstack; /* used for segmented stacks */
/* e.g. by LLVM to store stack bound */
void *tcb_unused[3];
};

struct tls_dtv {
@@ -52,7 +52,9 @@ struct tls_tcb {
void *tcb_dtv; /* Dynamic Thread Vector */
void *tcb_pthread; /* thread library's data*/
int *tcb_errno_p; /* pointer to per-thread errno */
void *tcb_unused[4];
void *tcb_segstack; /* used for segmented stacks */
/* e.g. by LLVM to store stack bound */
void *tcb_unused[3];
};

struct tls_dtv {

0 comments on commit 166bae1

Please sign in to comment.