Ticket #9445: boost-x32-context.patch

File boost-x32-context.patch, 4.0 KB (added by Mike Frysinger <vapier@…>, 9 years ago)

x32 support for context module

  • libs/context/src/asm/jump_x86_64_sysv_elf_gas.S

     
    3838 *                                                                                      *
    3939 * **************************************************************************************/
    4040
     41#ifdef __ILP32__
     42# define SIZEOF_FCONTEXT_T 0x50
     43#else
     44# define SIZEOF_FCONTEXT_T 0x58
     45#endif
     46
    4147.text
    4248.globl jump_fcontext
    4349.type jump_fcontext,@function
    jump_fcontext:  
    5359    cmp      $0,         %rcx
    5460    je       1f
    5561
    56     stmxcsr  0x50(%rdi)             /* save MMX control and status word */
    57     fnstcw   0x54(%rdi)             /* save x87 control word */
     62    stmxcsr  (SIZEOF_FCONTEXT_T - 8)(%rdi)             /* save MMX control and status word */
     63    fnstcw   (SIZEOF_FCONTEXT_T - 4)(%rdi)             /* save x87 control word */
    5864
    59     ldmxcsr  0x50(%rsi)             /* restore MMX control and status word */
    60     fldcw    0x54(%rsi)             /* restore x87 control word */
     65    ldmxcsr  (SIZEOF_FCONTEXT_T - 8)(%rsi)             /* restore MMX control and status word */
     66    fldcw    (SIZEOF_FCONTEXT_T - 4)(%rsi)             /* restore x87 control word */
    61671:
    6268
    6369    leaq     0x8(%rsp),  %rax       /* exclude the return address and save as stack pointer */
  • libs/context/src/asm/make_x86_64_sysv_elf_gas.S

     
    3838 *                                                                                      *
    3939 * **************************************************************************************/
    4040
     41#ifdef __ILP32__
     42# define SIZEOF_FCONTEXT_T 0x50
     43#else
     44# define SIZEOF_FCONTEXT_T 0x58
     45#endif
     46
    4147.text
    4248.globl make_fcontext
    4349.type make_fcontext,@function
    4450.align 16
    45 make_fcontext:
    46     leaq   -0x58(%rdi),    %rax        /* reserve space for fcontext_t at top of context stack */
     51make_fcontext: // (rax, rsi, rdx)
     52    leaq   -SIZEOF_FCONTEXT_T(%rdi), %rax /* reserve space for fcontext_t at top of context stack */
    4753
    4854    /* shift address in RAX to lower 16 byte boundary */
    4955    /* == pointer to fcontext_t and address of context stack */
    5056    andq   $-16,           %rax
    5157
     58#ifdef __ILP32__
     59    mov    %edi,           0x40(%rax) /* save address of context stack pointer (base) in fcontext_t */
     60    mov    %esi,           0x44(%rax) /* save context stack size in fcontext_t */
     61    mov    %edx,           0x38(%rax) /* save address of context function in fcontext_t */
     62#else
    5263    movq   %rdi,           0x40(%rax) /* save address of context stack pointer (base) in fcontext_t */
    5364    movq   %rsi,           0x48(%rax) /* save context stack size in fcontext_t */
    5465    movq   %rdx,           0x38(%rax) /* save address of context function in fcontext_t */
     66#endif
    5567
    56     stmxcsr  0x50(%rax)                /* save MMX control and status word */
    57     fnstcw   0x54(%rax)                /* save x87 control word */
     68    stmxcsr  (SIZEOF_FCONTEXT_T - 8)(%rax)                /* save MMX control and status word */
     69    fnstcw   (SIZEOF_FCONTEXT_T - 4)(%rax)                /* save x87 control word */
    5870
     71#ifdef __ILP32__
     72    leaq   -0x10(%rax),     %rdx       /* reserve space for the return address on context stack, (RSP - 0x8) % 16 == 0 */
     73    mov    %edx,            0x30(%rax) /* save address in RDX as stack pointer for context function */
     74#else
    5975    leaq   -0x8(%rax),      %rdx       /* reserve space for the return address on context stack, (RSP - 0x8) % 16 == 0 */
    6076    movq   %rdx,            0x30(%rax) /* save address in RDX as stack pointer for context function */
     77#endif
    6178
    6279    leaq   finish(%rip),    %rcx       /* compute abs address of label finish */
    6380    movq   %rcx,            (%rdx)     /* save address of finish as return address for context function */