From 6b614c4debb82931644e9c5cfaf93ee8b6840e2d Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Sun, 17 Jan 2021 20:43:15 +0100 Subject: [PATCH] OpenBSD: arm fix Disable warning softfloat. OpenBSD works fine. save/restore s0-s15 during memcpy call for structs update configure script. Works now on raspberry pi/All BSD Add eabi_mem.. functions in armeabi.c for OpenBSD Fix fp register in tccrun.c for OpenBSD --- arm-gen.c | 6 +++++- configure | 6 ++++-- lib/armeabi.c | 36 ++++++++++++++++++++++++++++++++++++ tccrun.c | 2 +- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/arm-gen.c b/arm-gen.c index c11d9474..38901c34 100644 --- a/arm-gen.c +++ b/arm-gen.c @@ -198,7 +198,8 @@ ST_FUNC void arm_init(struct TCCState *s) float_abi = s->float_abi; #ifndef TCC_ARM_HARDFLOAT -# warning "soft float ABI currently not supported: default to softfp" +// XXX: Works on OpenBSD +// # warning "soft float ABI currently not supported: default to softfp" #endif } #else @@ -1203,7 +1204,10 @@ again: o(0xE28D0000|(intr(r)<<12)|padding); /* add r, sp, padding */ vset(&vtop->type, r | VT_LVAL, 0); vswap(); + /* XXX: optimize. Save all register because memcpy can use them */ + o(0xED2D0A00|(0&1)<<22|(0>>1)<<12|16); /* vpush {s0-s15} */ vstore(); /* memcpy to current sp + potential padding */ + o(0xECBD0A00|(0&1)<<22|(0>>1)<<12|16); /* vpop {s0-s15} */ /* Homogeneous float aggregate are loaded to VFP registers immediately since there is no way of loading data in multiple diff --git a/configure b/configure index b71e1d2d..4050570b 100755 --- a/configure +++ b/configure @@ -360,9 +360,11 @@ if test -z "$cross_prefix" ; then if test "${triplet%eabihf}" != "$triplet" ; then confvars="$confvars arm_eabihf arm_vfp" elif test "${triplet%eabi}" != "$triplet" ; then - confvars="$confvars arm_eabi" - elif test "$targetos" = "NetBSD"; then + confvars="$confvars arm_eabi arm_vfp" + elif test "${_triplet%eabihf}" != "$_triplet" ; then confvars="$confvars arm_eabihf arm_vfp" + elif test "${_triplet%eabi}" != "$_triplet" ; then + confvars="$confvars arm_eabi arm_vfp" fi if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then confvars="$confvars arm_vfp" diff --git a/lib/armeabi.c b/lib/armeabi.c index a59640dd..1bccbd3b 100644 --- a/lib/armeabi.c +++ b/lib/armeabi.c @@ -499,3 +499,39 @@ void __aeabi_uidivmod(unsigned num, unsigned den) { uidiv_t_return(aeabi_uidivmod(num, den)); } + +/* Some targets do not have all eabi calls (OpenBSD) */ +typedef __SIZE_TYPE__ size_t; +extern void *memcpy(void *dest, const void *src, size_t n); +extern void *memmove(void *dest, const void *src, size_t n); +extern void *memset(void *s, int c, size_t n); + +void * +__aeabi_memcpy (void *dest, const void *src, size_t n) +{ + return memcpy (dest, src, n); +} + +void * +__aeabi_memmove (void *dest, const void *src, size_t n) +{ + return memmove (dest, src, n); +} + +void * +__aeabi_memmove4 (void *dest, const void *src, size_t n) +{ + return memmove (dest, src, n); +} + +void * +__aeabi_memmove8 (void *dest, const void *src, size_t n) +{ + return memmove (dest, src, n); +} + +void * +__aeabi_memset (void *s, size_t n, int c) +{ + return memset (s, c, n); +} diff --git a/tccrun.c b/tccrun.c index 318dd384..55b1cc46 100644 --- a/tccrun.c +++ b/tccrun.c @@ -665,7 +665,7 @@ static void rt_getcontext(ucontext_t *uc, rt_context *rc) rc->fp = uc->uc_mcontext.__gregs[_REG_FP]; #elif defined(__arm__) && defined(__OpenBSD__) rc->ip = uc->sc_pc; - rc->fp = uc->sc_fpreg[29]; + rc->fp = uc->sc_r11; #elif defined(__arm__) && defined(__FreeBSD__) rc->ip = uc->uc_mcontext.__gregs[_REG_PC]; rc->fp = uc->uc_mcontext.__gregs[_REG_FP];