Print this page
8609 want a position independent CRT

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/i386/threads/machdep.c
          +++ new/usr/src/lib/libc/i386/threads/machdep.c
↓ open down ↓ 28 lines elided ↑ open up ↑
  29   29  #include <setjmp.h>
  30   30  
  31   31  /*
  32   32   * The stack needs to be 16-byte aligned with a 4-byte bias.  See comment in
  33   33   * lib/libc/i386/gen/makectxt.c.
  34   34   *
  35   35   * Note: If you change it, you need to change it in the following files as
  36   36   * well:
  37   37   *
  38   38   *  - lib/libc/i386/gen/makectxt.c
  39      - *  - lib/common/i386/crti.s
  40      - *  - lib/common/i386/crt1.s
       39 + *  - lib/crt/i86/crti.s
       40 + *  - lib/crt/i86/crt1.s
  41   41   */
  42   42  #undef  STACK_ALIGN
  43   43  #define STACK_ALIGN     16
  44   44  
  45   45  extern int getlwpstatus(thread_t, lwpstatus_t *);
  46   46  extern int putlwpregs(thread_t, prgregset_t);
  47   47  
  48   48  void *
  49   49  setup_top_frame(void *stk, size_t stksize, ulwp_t *ulwp)
  50   50  {
↓ open down ↓ 28 lines elided ↑ open up ↑
  79   79          frame.pad = 0;
  80   80          frame.arg = (uint32_t)ulwp;
  81   81          frame.rpc = (uint32_t)_lwp_start;
  82   82          if (uucopy(&frame, (void *)stack, sizeof (frame)) == 0)
  83   83                  return (stack);
  84   84          return (NULL);
  85   85  }
  86   86  
  87   87  int
  88   88  setup_context(ucontext_t *ucp, void *(*func)(ulwp_t *),
  89      -        ulwp_t *ulwp, caddr_t stk, size_t stksize)
       89 +    ulwp_t *ulwp, caddr_t stk, size_t stksize)
  90   90  {
  91   91          static int initialized;
  92   92          static greg_t fs, es, ds, cs, ss;
  93   93  
  94   94          uint32_t *stack;
  95   95  
  96   96          if (!initialized) {
  97   97                  ucontext_t uc;
  98   98  
  99   99                  /* do this once to load the segment registers */
↓ open down ↓ 103 lines elided ↑ open up ↑
 203  203                  status.pr_reg[ESI] = rs[ESI];
 204  204                  status.pr_reg[EBP] = rs[EBP];
 205  205                  status.pr_reg[EBX] = rs[EBX];
 206  206                  status.pr_reg[UESP] = rs[UESP];
 207  207                  (void) putlwpregs(ulwp->ul_lwpid, status.pr_reg);
 208  208          }
 209  209  }
 210  210  
 211  211  int
 212  212  __csigsetjmp(greg_t cs, greg_t ss, greg_t gs,
 213      -        greg_t fs, greg_t es, greg_t ds,
 214      -        greg_t edi, greg_t esi, greg_t ebp, greg_t esp,
 215      -        greg_t ebx, greg_t edx, greg_t ecx, greg_t eax, greg_t eip,
 216      -        sigjmp_buf env, int savemask)
      213 +    greg_t fs, greg_t es, greg_t ds,
      214 +    greg_t edi, greg_t esi, greg_t ebp, greg_t esp,
      215 +    greg_t ebx, greg_t edx, greg_t ecx, greg_t eax, greg_t eip,
      216 +    sigjmp_buf env, int savemask)
 217  217  {
 218  218          ucontext_t *ucp = (ucontext_t *)env;
 219  219          ulwp_t *self = curthread;
 220  220  
 221  221          ucp->uc_link = self->ul_siglink;
 222  222          if (self->ul_ustack.ss_flags & SS_ONSTACK)
 223  223                  ucp->uc_stack = self->ul_ustack;
 224  224          else {
 225  225                  ucp->uc_stack.ss_sp =
 226  226                      (void *)(self->ul_stktop - self->ul_stksiz);
↓ open down ↓ 38 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX