|
Packit Service |
82fcde |
/* Set up a context to call a function.
|
|
Packit Service |
82fcde |
Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sysdep.h>
|
|
Packit Service |
82fcde |
#include <shlib-compat.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define __ASSEMBLY__
|
|
Packit Service |
82fcde |
#include <asm/ptrace.h>
|
|
Packit Service |
82fcde |
#include "ucontext_i.h"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ENTRY(__makecontext)
|
|
Packit Service |
82fcde |
/* Set up the first 7 args to the function in its registers */
|
|
Packit Service |
82fcde |
lwz r11,_UC_REGS_PTR(r3)
|
|
Packit Service |
82fcde |
stw r6,_UC_GREGS+(PT_R3*4)(r11)
|
|
Packit Service |
82fcde |
stw r7,_UC_GREGS+(PT_R4*4)(r11)
|
|
Packit Service |
82fcde |
stw r8,_UC_GREGS+(PT_R5*4)(r11)
|
|
Packit Service |
82fcde |
stw r9,_UC_GREGS+(PT_R6*4)(r11)
|
|
Packit Service |
82fcde |
stw r10,_UC_GREGS+(PT_R7*4)(r11)
|
|
Packit Service |
82fcde |
lwz r8,8(r1)
|
|
Packit Service |
82fcde |
lwz r9,12(r1)
|
|
Packit Service |
82fcde |
stw r8,_UC_GREGS+(PT_R8*4)(r11)
|
|
Packit Service |
82fcde |
stw r9,_UC_GREGS+(PT_R9*4)(r11)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Set the NIP to the start of the function */
|
|
Packit Service |
82fcde |
stw r4,_UC_GREGS+(PT_NIP*4)(r11)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Set the function's r31 to ucp->uc_link for the exitcode below. */
|
|
Packit Service |
82fcde |
lwz r7,_UC_LINK(r3)
|
|
Packit Service |
82fcde |
stw r7,_UC_GREGS+(PT_R31*4)(r11)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Set the function's LR to point to the exitcode below. */
|
|
Packit Service |
82fcde |
#ifdef PIC
|
|
Packit Service |
82fcde |
mflr r0
|
|
Packit Service |
82fcde |
cfi_register(lr,r0)
|
|
Packit Service |
82fcde |
/* Use this conditional form of branch and link to avoid destroying
|
|
Packit Service |
82fcde |
the cpu link stack used to predict blr return addresses. */
|
|
Packit Service |
82fcde |
bcl 20,31,1f
|
|
Packit Service |
82fcde |
1: mflr r6
|
|
Packit Service |
82fcde |
addi r6,r6,L(exitcode)-1b
|
|
Packit Service |
82fcde |
mtlr r0
|
|
Packit Service |
82fcde |
cfi_same_value (lr)
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
lis r6,L(exitcode)@ha
|
|
Packit Service |
82fcde |
addi r6,r6,L(exitcode)@l
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
stw r6,_UC_GREGS+(PT_LNK*4)(r11)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
* Set up the stack frame for the function.
|
|
Packit Service |
82fcde |
* If we have more than 5 args to the function (8 args to makecontext),
|
|
Packit Service |
82fcde |
* there will be some arguments on the stack which have to end up
|
|
Packit Service |
82fcde |
* in registers. If there are more than 8 args to the function,
|
|
Packit Service |
82fcde |
* we have to copy (argc - 8) args from our stack to the functions'
|
|
Packit Service |
82fcde |
* stack (and allow space for them in the frame).
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
lwz r4,_UC_STACK_SP(r3)
|
|
Packit Service |
82fcde |
lwz r8,_UC_STACK_SIZE(r3)
|
|
Packit Service |
82fcde |
add r4,r4,r8
|
|
Packit Service |
82fcde |
rlwinm r4,r4,0,0,27 /* round down to 16-byte boundary */
|
|
Packit Service |
82fcde |
addi r7,r4,-16 /* stack frame for fn's caller */
|
|
Packit Service |
82fcde |
cmpwi r5,8
|
|
Packit Service |
82fcde |
blt 2f /* less than 8 args is easy */
|
|
Packit Service |
82fcde |
lwz r10,16(r1)
|
|
Packit Service |
82fcde |
stw r10,_UC_GREGS+(PT_R10*4)(r11)
|
|
Packit Service |
82fcde |
beq 2f /* if exactly 8 args */
|
|
Packit Service |
82fcde |
subi r9,r5,3
|
|
Packit Service |
82fcde |
subi r5,r5,8
|
|
Packit Service |
82fcde |
rlwinm r9,r9,2,0,27
|
|
Packit Service |
82fcde |
subf r7,r9,r4
|
|
Packit Service |
82fcde |
mtctr r5 /* copy the 9th and following args */
|
|
Packit Service |
82fcde |
addi r6,r1,16
|
|
Packit Service |
82fcde |
addi r8,r7,4
|
|
Packit Service |
82fcde |
3: lwzu r10,4(r6)
|
|
Packit Service |
82fcde |
stwu r10,4(r8)
|
|
Packit Service |
82fcde |
bdnz 3b
|
|
Packit Service |
82fcde |
2: stw r7,_UC_GREGS+(PT_R1*4)(r11)
|
|
Packit Service |
82fcde |
li r6,0
|
|
Packit Service |
82fcde |
stw r6,0(r7)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
blr
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
cfi_endproc
|
|
Packit Service |
82fcde |
nop
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
* If the function returns, it comes here. We put ucp->uc_link in
|
|
Packit Service |
82fcde |
* r31, which is a callee-saved register. We have to continue with
|
|
Packit Service |
82fcde |
* the context that r31 points to, or exit if it is 0.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
L(exitcode):
|
|
Packit Service |
82fcde |
mr. r3,r31
|
|
Packit Service |
82fcde |
beq 4f
|
|
Packit Service |
82fcde |
bl __setcontext@local
|
|
Packit Service |
82fcde |
4: bl HIDDEN_JUMPTARGET(exit)
|
|
Packit Service |
82fcde |
b 4b
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
cfi_startproc
|
|
Packit Service |
82fcde |
END(__makecontext)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
versioned_symbol (libc, __makecontext, makecontext, GLIBC_2_3_4)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
compat_text_section
|
|
Packit Service |
82fcde |
ENTRY(__novec_makecontext)
|
|
Packit Service |
82fcde |
/* Set up the first 7 args to the function in its registers */
|
|
Packit Service |
82fcde |
addi r11,r3,_UC_REG_SPACE
|
|
Packit Service |
82fcde |
stw r11,_UC_REGS_PTR(r3)
|
|
Packit Service |
82fcde |
stw r6,_UC_GREGS+(PT_R3*4)(r11)
|
|
Packit Service |
82fcde |
stw r7,_UC_GREGS+(PT_R4*4)(r11)
|
|
Packit Service |
82fcde |
stw r8,_UC_GREGS+(PT_R5*4)(r11)
|
|
Packit Service |
82fcde |
stw r9,_UC_GREGS+(PT_R6*4)(r11)
|
|
Packit Service |
82fcde |
stw r10,_UC_GREGS+(PT_R7*4)(r11)
|
|
Packit Service |
82fcde |
lwz r8,8(r1)
|
|
Packit Service |
82fcde |
lwz r9,12(r1)
|
|
Packit Service |
82fcde |
stw r8,_UC_GREGS+(PT_R8*4)(r11)
|
|
Packit Service |
82fcde |
stw r9,_UC_GREGS+(PT_R9*4)(r11)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Set the NIP to the start of the function */
|
|
Packit Service |
82fcde |
stw r4,_UC_GREGS+(PT_NIP*4)(r11)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Set the function's r31 to ucp->uc_link for the exitcode below. */
|
|
Packit Service |
82fcde |
lwz r7,_UC_LINK(r3)
|
|
Packit Service |
82fcde |
stw r7,_UC_GREGS+(PT_R31*4)(r11)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Set the function's LR to point to the exitcode below. */
|
|
Packit Service |
82fcde |
#ifdef PIC
|
|
Packit Service |
82fcde |
mflr r0
|
|
Packit Service |
82fcde |
cfi_register(lr,r0)
|
|
Packit Service |
82fcde |
/* Use this conditional form of branch and link to avoid destroying
|
|
Packit Service |
82fcde |
the cpu link stack used to predict blr return addresses. */
|
|
Packit Service |
82fcde |
bcl 20,31,1f
|
|
Packit Service |
82fcde |
1: mflr r6
|
|
Packit Service |
82fcde |
addi r6,r6,L(novec_exitcode)-1b
|
|
Packit Service |
82fcde |
mtlr r0
|
|
Packit Service |
82fcde |
cfi_same_value (lr)
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
lis r6,L(novec_exitcode)@ha
|
|
Packit Service |
82fcde |
addi r6,r6,L(novec_exitcode)@l
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
stw r6,_UC_GREGS+(PT_LNK*4)(r11)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
* Set up the stack frame for the function.
|
|
Packit Service |
82fcde |
* If we have more than 5 args to the function (8 args to makecontext),
|
|
Packit Service |
82fcde |
* there will be some arguments on the stack which have to end up
|
|
Packit Service |
82fcde |
* in registers. If there are more than 8 args to the function,
|
|
Packit Service |
82fcde |
* we have to copy (argc - 8) args from our stack to the functions'
|
|
Packit Service |
82fcde |
* stack (and allow space for them in the frame).
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
lwz r4,_UC_STACK_SP(r3)
|
|
Packit Service |
82fcde |
lwz r8,_UC_STACK_SIZE(r3)
|
|
Packit Service |
82fcde |
add r4,r4,r8
|
|
Packit Service |
82fcde |
rlwinm r4,r4,0,0,27 /* round down to 16-byte boundary */
|
|
Packit Service |
82fcde |
addi r7,r4,-16 /* stack frame for fn's caller */
|
|
Packit Service |
82fcde |
cmpwi r5,8
|
|
Packit Service |
82fcde |
blt 2f /* less than 8 args is easy */
|
|
Packit Service |
82fcde |
lwz r10,16(r1)
|
|
Packit Service |
82fcde |
stw r10,_UC_GREGS+(PT_R10*4)(r11)
|
|
Packit Service |
82fcde |
beq 2f /* if exactly 8 args */
|
|
Packit Service |
82fcde |
subi r9,r5,3
|
|
Packit Service |
82fcde |
subi r5,r5,8
|
|
Packit Service |
82fcde |
rlwinm r9,r9,2,0,27
|
|
Packit Service |
82fcde |
subf r7,r9,r4
|
|
Packit Service |
82fcde |
mtctr r5 /* copy the 9th and following args */
|
|
Packit Service |
82fcde |
addi r6,r1,16
|
|
Packit Service |
82fcde |
addi r8,r7,4
|
|
Packit Service |
82fcde |
3: lwzu r10,4(r6)
|
|
Packit Service |
82fcde |
stwu r10,4(r8)
|
|
Packit Service |
82fcde |
bdnz 3b
|
|
Packit Service |
82fcde |
2: stw r7,_UC_GREGS+(PT_R1*4)(r11)
|
|
Packit Service |
82fcde |
li r6,0
|
|
Packit Service |
82fcde |
stw r6,0(r7)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
blr
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
cfi_endproc
|
|
Packit Service |
82fcde |
nop
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
* If the function returns, it comes here. We put ucp->uc_link in
|
|
Packit Service |
82fcde |
* r31, which is a callee-saved register. We have to continue with
|
|
Packit Service |
82fcde |
* the context that r31 points to, or exit if it is 0.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
L(novec_exitcode):
|
|
Packit Service |
82fcde |
mr. r3,r31
|
|
Packit Service |
82fcde |
beq 4f
|
|
Packit Service |
82fcde |
bl __novec_setcontext@local
|
|
Packit Service |
82fcde |
4: bl HIDDEN_JUMPTARGET(exit)
|
|
Packit Service |
82fcde |
b 4b
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
cfi_startproc
|
|
Packit Service |
82fcde |
END(__novec_makecontext)
|
|
Packit Service |
82fcde |
.previous
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
compat_symbol (libc, __novec_makecontext, makecontext, GLIBC_2_3_3)
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_3_3)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define _ERRNO_H 1
|
|
Packit Service |
82fcde |
#include <bits/errno.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
compat_text_section
|
|
Packit Service |
82fcde |
ENTRY (__makecontext_stub)
|
|
Packit Service |
82fcde |
li r3,ENOSYS
|
|
Packit Service |
82fcde |
b __syscall_error@local
|
|
Packit Service |
82fcde |
END (__makecontext_stub)
|
|
Packit Service |
82fcde |
.previous
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
compat_symbol (libc, __makecontext_stub, makecontext, GLIBC_2_1)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif
|