import preliminary ppc work by rdp.
This commit is contained in:
committed by
rofl0r
parent
1e717ea3d2
commit
7669d1e334
@@ -0,0 +1,24 @@
|
||||
#include <bits/asm.h>
|
||||
.global __syscall
|
||||
.type __syscall,@function
|
||||
__syscall:
|
||||
mflr r0
|
||||
stw r0, -4(r1) // Save the return address.
|
||||
mr r0, r3 // Save the system call number
|
||||
mr r3, r4 // Shift the arguments: arg1
|
||||
mr r4, r5 // arg2
|
||||
mr r5, r6 // arg3
|
||||
mr r6, r7 // arg4
|
||||
mr r7, r8 // arg5
|
||||
mr r8, r9 // arg6
|
||||
sc
|
||||
mfcr r0 // Check for an error
|
||||
rlwinm r4, r0, r0, 3, 3 // by checking for bit 28.
|
||||
cmplwi r0, r4, 0 // It is an error if non-zero.
|
||||
beq r0, 1f // Jump if not an error.
|
||||
neg r3, r3 // Negate the error number.
|
||||
1: lwz r0, -4(r1) // Restore the return address.
|
||||
mtlr r0
|
||||
blr
|
||||
.end __syscall
|
||||
.size __syscall, .-__syscall
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <bits/asm.h>
|
||||
.text
|
||||
.global dlsym
|
||||
.type dlsym,@function
|
||||
dlsym:
|
||||
mflr r5 // The return address is arg3.
|
||||
b __dlsym
|
||||
.end dlsym
|
||||
.size dlsym, .-dlsym
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <bits/asm.h>
|
||||
.global _start
|
||||
.type _start,@function
|
||||
_start:
|
||||
mr r9, r1 // Save the original stack pointer.
|
||||
clrrwi r1, r1, 4 // Align the stack to 16 bytes.
|
||||
lis r13, _SDA_BASE_@ha // r13 points to the small data area.
|
||||
addi r13, r13, _SDA_BASE_@l //
|
||||
li r0, 0 // Zero the frame pointer.
|
||||
lwz r3, 0(r9) // and argc...
|
||||
addi r4, r9, 4 // and argv ...
|
||||
mtlr r0 // Clear the link register.
|
||||
// Go to the musl dynamic linker entry point.
|
||||
bl __dynlink
|
||||
cmpi r4, 0, r3, 1 // Check for a 1.
|
||||
bne r4, . // Stay here
|
||||
mtlr r3 // Set the link address...
|
||||
li r3, 0
|
||||
blr // and go.
|
||||
.end _start
|
||||
.size _start, .-_start
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <bits/asm.h>
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
cmpi 7, 0, r3, 0
|
||||
bne 7, 1f
|
||||
addi r3, r3, 1
|
||||
1: lmw r8, 4(r3) // load r8-r31
|
||||
mr r6, r4
|
||||
mtlr r11
|
||||
mtcr r12
|
||||
mr r2, r9
|
||||
mr r1, r10
|
||||
blr
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <bits/asm.h>
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
mflr r11
|
||||
mfcr r12
|
||||
mr r10, r1
|
||||
mr r9, r2
|
||||
stmw r8, 0(r3) // save r8-r31
|
||||
li r3,0
|
||||
blr
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <bits/asm.h>
|
||||
#include <bits/syscall.h>
|
||||
.global __restore
|
||||
.type __restore,@function
|
||||
__restore:
|
||||
li r0, __NR_sigreturn
|
||||
sc
|
||||
|
||||
.global __restore_rt
|
||||
.type __restore_rt,@function
|
||||
__restore_rt:
|
||||
li r0, __NR_rt_sigreturn
|
||||
sc
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <bits/asm.h>
|
||||
.global sigsetjmp
|
||||
.type sigsetjmp,@function
|
||||
sigsetjmp:
|
||||
lwz r4, 64*4-2*4(r3) // Second last long.
|
||||
cmpi r4, 0, r4, 0
|
||||
bne r4, 1f
|
||||
addi r5, r3, 64*4-1*4 // Address of last long.
|
||||
li r4, 0
|
||||
li r3, 2
|
||||
bl sigprocmask
|
||||
1: b setjmp
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <bits/asm.h>
|
||||
#include <bits/syscall.h>
|
||||
.text
|
||||
.global __unmapself
|
||||
.type __unmapself,%function
|
||||
__unmapself:
|
||||
li r0, __NR_munmap
|
||||
sc
|
||||
li r0, __NR_exit
|
||||
sc
|
||||
blr
|
||||
Reference in New Issue
Block a user