fix arm run-time abi string functions
in arm rtabi these __aeabi_* functions have special abi (they are only allowed to clobber r0,r1,r2,r3,ip,lr,cpsr), so they cannot be simple wrappers around normal string functions (which may clobber other registers), the safest solution is to write them in asm, a minimalistic implementation works because these are not supposed to be emitted by compilers or used in general.
This commit is contained in:
committed by
Rich Felker
parent
91d34c4533
commit
e6def54435
@@ -1,9 +0,0 @@
|
||||
#include <string.h>
|
||||
#include "libc.h"
|
||||
|
||||
void __aeabi_memclr(void *dest, size_t n)
|
||||
{
|
||||
memset(dest, 0, n);
|
||||
}
|
||||
weak_alias(__aeabi_memclr, __aeabi_memclr4);
|
||||
weak_alias(__aeabi_memclr, __aeabi_memclr8);
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <string.h>
|
||||
#include "libc.h"
|
||||
|
||||
void __aeabi_memcpy(void *restrict dest, const void *restrict src, size_t n)
|
||||
{
|
||||
memcpy(dest, src, n);
|
||||
}
|
||||
weak_alias(__aeabi_memcpy, __aeabi_memcpy4);
|
||||
weak_alias(__aeabi_memcpy, __aeabi_memcpy8);
|
||||
@@ -0,0 +1,45 @@
|
||||
.syntax unified
|
||||
|
||||
.global __aeabi_memcpy8
|
||||
.global __aeabi_memcpy4
|
||||
.global __aeabi_memcpy
|
||||
.global __aeabi_memmove8
|
||||
.global __aeabi_memmove4
|
||||
.global __aeabi_memmove
|
||||
|
||||
.type __aeabi_memcpy8,%function
|
||||
.type __aeabi_memcpy4,%function
|
||||
.type __aeabi_memcpy,%function
|
||||
.type __aeabi_memmove8,%function
|
||||
.type __aeabi_memmove4,%function
|
||||
.type __aeabi_memmove,%function
|
||||
|
||||
__aeabi_memmove8:
|
||||
__aeabi_memmove4:
|
||||
__aeabi_memmove:
|
||||
cmp r0, r1
|
||||
bls 3f
|
||||
cmp r2, #0
|
||||
beq 2f
|
||||
adds r0, r0, r2
|
||||
adds r2, r1, r2
|
||||
1: subs r2, r2, #1
|
||||
ldrb r3, [r2]
|
||||
subs r0, r0, #1
|
||||
strb r3, [r0]
|
||||
cmp r1, r2
|
||||
bne 1b
|
||||
2: bx lr
|
||||
__aeabi_memcpy8:
|
||||
__aeabi_memcpy4:
|
||||
__aeabi_memcpy:
|
||||
3: cmp r2, #0
|
||||
beq 2f
|
||||
adds r2, r1, r2
|
||||
1: ldrb r3, [r1]
|
||||
adds r1, r1, #1
|
||||
strb r3, [r0]
|
||||
adds r0, r0, #1
|
||||
cmp r1, r2
|
||||
bne 1b
|
||||
2: bx lr
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <string.h>
|
||||
#include "libc.h"
|
||||
|
||||
void __aeabi_memmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
memmove(dest, src, n);
|
||||
}
|
||||
weak_alias(__aeabi_memmove, __aeabi_memmove4);
|
||||
weak_alias(__aeabi_memmove, __aeabi_memmove8);
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <string.h>
|
||||
#include "libc.h"
|
||||
|
||||
void __aeabi_memset(void *dest, size_t n, int c)
|
||||
{
|
||||
memset(dest, c, n);
|
||||
}
|
||||
weak_alias(__aeabi_memset, __aeabi_memset4);
|
||||
weak_alias(__aeabi_memset, __aeabi_memset8);
|
||||
@@ -0,0 +1,31 @@
|
||||
.syntax unified
|
||||
|
||||
.global __aeabi_memclr8
|
||||
.global __aeabi_memclr4
|
||||
.global __aeabi_memclr
|
||||
.global __aeabi_memset8
|
||||
.global __aeabi_memset4
|
||||
.global __aeabi_memset
|
||||
|
||||
.type __aeabi_memclr8,%function
|
||||
.type __aeabi_memclr4,%function
|
||||
.type __aeabi_memclr,%function
|
||||
.type __aeabi_memset8,%function
|
||||
.type __aeabi_memset4,%function
|
||||
.type __aeabi_memset,%function
|
||||
|
||||
__aeabi_memclr8:
|
||||
__aeabi_memclr4:
|
||||
__aeabi_memclr:
|
||||
movs r2, #0
|
||||
__aeabi_memset8:
|
||||
__aeabi_memset4:
|
||||
__aeabi_memset:
|
||||
cmp r1, #0
|
||||
beq 2f
|
||||
adds r1, r0, r1
|
||||
1: strb r2, [r0]
|
||||
adds r0, r0, #1
|
||||
cmp r1, r0
|
||||
bne 1b
|
||||
2: bx lr
|
||||
Reference in New Issue
Block a user