native: add support for Linux on ARM
This commit is contained in:
parent
942ce1b29d
commit
3d29a9e3d3
@ -25,7 +25,10 @@ export CGANNOTATE ?= cg_annotate
|
|||||||
export GPROF ?= gprof
|
export GPROF ?= gprof
|
||||||
|
|
||||||
# basic cflags:
|
# basic cflags:
|
||||||
export CFLAGS += -Wall -Wextra -pedantic -m32
|
export CFLAGS += -Wall -Wextra -pedantic
|
||||||
|
ifeq ($(shell uname -m),x86_64)
|
||||||
|
export CFLAGS += -m32
|
||||||
|
endif
|
||||||
ifneq (,$(filter -DDEVELHELP,$(CFLAGS)))
|
ifneq (,$(filter -DDEVELHELP,$(CFLAGS)))
|
||||||
export CFLAGS += -fstack-protector-all
|
export CFLAGS += -fstack-protector-all
|
||||||
endif
|
endif
|
||||||
@ -39,7 +42,9 @@ endif
|
|||||||
export CXXUWFLAGS +=
|
export CXXUWFLAGS +=
|
||||||
export CXXEXFLAGS +=
|
export CXXEXFLAGS +=
|
||||||
|
|
||||||
|
ifeq ($(shell uname -m),x86_64)
|
||||||
export LINKFLAGS += -m32
|
export LINKFLAGS += -m32
|
||||||
|
endif
|
||||||
ifeq ($(shell uname -s),FreeBSD)
|
ifeq ($(shell uname -s),FreeBSD)
|
||||||
ifeq ($(shell uname -m),amd64)
|
ifeq ($(shell uname -m),amd64)
|
||||||
export LINKFLAGS += -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
|
export LINKFLAGS += -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
#define VALGRIND_DEBUG(...)
|
#define VALGRIND_DEBUG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// __USE_GNU for gregs[REG_EIP] access under Linux
|
/* __USE_GNU for gregs[REG_EIP] access under Linux */
|
||||||
#define __USE_GNU
|
#define __USE_GNU
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#undef __USE_GNU
|
#undef __USE_GNU
|
||||||
@ -331,17 +331,27 @@ void native_isr_entry(int sig, siginfo_t *info, void *context)
|
|||||||
/* disable interrupts in context */
|
/* disable interrupts in context */
|
||||||
isr_set_sigmask((ucontext_t *)context);
|
isr_set_sigmask((ucontext_t *)context);
|
||||||
_native_in_isr = 1;
|
_native_in_isr = 1;
|
||||||
|
/*
|
||||||
|
* For register access on new platforms see:
|
||||||
|
* http://google-glog.googlecode.com/svn/trunk/m4/pc_from_ucontext.m4
|
||||||
|
* (URL added on Fri Aug 29 17:17:45 CEST 2014)
|
||||||
|
*/
|
||||||
#ifdef __MACH__
|
#ifdef __MACH__
|
||||||
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext->__ss.__eip;
|
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext->__ss.__eip;
|
||||||
((ucontext_t *)context)->uc_mcontext->__ss.__eip = (unsigned int)&_native_sig_leave_tramp;
|
((ucontext_t *)context)->uc_mcontext->__ss.__eip = (unsigned int)&_native_sig_leave_tramp;
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
_native_saved_eip = ((struct sigcontext *)context)->sc_eip;
|
_native_saved_eip = ((struct sigcontext *)context)->sc_eip;
|
||||||
((struct sigcontext *)context)->sc_eip = (unsigned int)&_native_sig_leave_tramp;
|
((struct sigcontext *)context)->sc_eip = (unsigned int)&_native_sig_leave_tramp;
|
||||||
|
#else
|
||||||
|
#ifdef __arm__
|
||||||
|
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext.arm_pc;
|
||||||
|
((ucontext_t *)context)->uc_mcontext.arm_pc = (unsigned int)&_native_sig_leave_tramp;
|
||||||
#else
|
#else
|
||||||
//printf("\n\033[31mEIP:\t%p\ngo switching\n\n\033[0m", (void*)((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP]);
|
//printf("\n\033[31mEIP:\t%p\ngo switching\n\n\033[0m", (void*)((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP]);
|
||||||
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP];
|
_native_saved_eip = ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP];
|
||||||
((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP] = (unsigned int)&_native_sig_leave_tramp;
|
((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP] = (unsigned int)&_native_sig_leave_tramp;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
* Copyright (C) 2013, 2014 Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
||||||
|
* Copyright (C) 2014 Thomas Eichinger <thomas.eichinger1@gmail.com>
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
* General Public License v2.1. See the file LICENSE in the top level
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
@ -27,6 +28,47 @@ __native_sig_leave_tramp:
|
|||||||
popfl
|
popfl
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
#elif __arm__
|
||||||
|
.extern _native_saved_eip
|
||||||
|
.extern _native_isr_ctx
|
||||||
|
.extern _native_cur_ctx
|
||||||
|
.extern _native_in_isr
|
||||||
|
|
||||||
|
.globl _native_sig_leave_tramp
|
||||||
|
_native_sig_leave_tramp:
|
||||||
|
/* save _native_saved_eip and registers */
|
||||||
|
stmdb sp!, {r0}
|
||||||
|
ldr r0, =_native_saved_eip
|
||||||
|
ldr r0, [r0]
|
||||||
|
stmdb sp!, {r0-r12}
|
||||||
|
stmdb sp!, {lr}
|
||||||
|
|
||||||
|
/* exchange r0 and _native_saved_eip */
|
||||||
|
ldr r0, [sp,#56]
|
||||||
|
ldr r1, [sp,#4 ]
|
||||||
|
str r0, [sp,#4 ]
|
||||||
|
str r1, [sp,#56]
|
||||||
|
|
||||||
|
/* call swapcontext ( _native_cur_ctx, _native_isr_ctx ) */
|
||||||
|
ldr r2, =_native_cur_ctx
|
||||||
|
ldr r0, [r2]
|
||||||
|
ldr r2, =_native_isr_ctx
|
||||||
|
ldr r1, [r2]
|
||||||
|
bl swapcontext
|
||||||
|
|
||||||
|
/* reeanble interrupts */
|
||||||
|
bl eINT
|
||||||
|
|
||||||
|
/* _native_in_isr = 0 */
|
||||||
|
eor r0, r0, r0
|
||||||
|
ldr r2, =_native_in_isr
|
||||||
|
str r0, [r2]
|
||||||
|
|
||||||
|
/* restore registers, jump to (saved) _native_saved_eip */
|
||||||
|
ldmia sp!, {lr}
|
||||||
|
ldmia sp!, {r0-r12}
|
||||||
|
ldmia sp!, {pc}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
.extern $_native_saved_eip
|
.extern $_native_saved_eip
|
||||||
.extern $_native_isr_ctx
|
.extern $_native_isr_ctx
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user