Merge pull request #27 from utmapp/qemu-support-v2

Remaining fixes for Apple Silicon and QEMU
arm_linker_fix
Ariadne Conill 2021-03-08 20:48:30 -06:00 committed by GitHub
commit 464f98a01b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 91 additions and 13 deletions

View File

@ -23,7 +23,7 @@ EXPORT_UNPREFIXED := yes
FREESTANDING := no
ifeq ($(FREESTANDING),yes)
CFLAGS += -DFREESTANDING -isystem arch/${ARCH}/freestanding
CFLAGS += -DFREESTANDING
EXPORT_UNPREFIXED = no
endif
@ -215,13 +215,13 @@ examples/cooperative_threading: examples/cooperative_threading.c ${LIBUCONTEXT_N
ifeq ($(FREESTANDING),no)
include/libucontext/bits.h: arch/common/bits.h
cp arch/common/bits.h $@
include/libucontext/bits.h: arch/common/include/libucontext/bits.h
cp $< $@
else
include/libucontext/bits.h: arch/${ARCH}/freestanding/bits.h
cp arch/${ARCH}/freestanding/bits.h $@
include/libucontext/bits.h: arch/${ARCH}/include/libucontext/bits.h
cp $< $@
endif

View File

@ -15,7 +15,11 @@
ALIAS(getcontext, libucontext_getcontext)
ALIAS(__getcontext, libucontext_getcontext)
FUNC(libucontext_getcontext)
.global PROC_NAME(libucontext_getcontext);
.align 2;
TYPE(libucontext_getcontext)
ENT(libucontext_getcontext)
PROC_NAME(libucontext_getcontext):
str xzr, [x0, #REG_OFFSET(0)]
/* save GPRs */

View File

@ -15,7 +15,11 @@
ALIAS(setcontext, libucontext_setcontext)
ALIAS(__setcontext, libucontext_setcontext)
FUNC(libucontext_setcontext)
.global PROC_NAME(libucontext_setcontext);
.align 2;
TYPE(libucontext_setcontext)
ENT(libucontext_setcontext)
PROC_NAME(libucontext_setcontext):
/* restore GPRs */
ldp x18, x19, [x0, #REG_OFFSET(18)]
ldp x20, x21, [x0, #REG_OFFSET(20)]

View File

@ -15,7 +15,11 @@
ALIAS(swapcontext, libucontext_swapcontext)
ALIAS(__swapcontext, libucontext_swapcontext)
FUNC(libucontext_swapcontext)
.global PROC_NAME(libucontext_swapcontext);
.align 2;
TYPE(libucontext_swapcontext)
ENT(libucontext_swapcontext)
PROC_NAME(libucontext_swapcontext):
str xzr, [x0, #REG_OFFSET(0)]
/* save GPRs */

View File

@ -1,7 +1,6 @@
#ifndef __ARCH_X86_DEFS_H
#define __ARCH_X86_DEFS_H
#ifndef _GNU_SOURCE
#ifndef REG_GS
# define REG_GS (0)
#endif
@ -53,7 +52,6 @@
#ifndef REG_EIP
# define REG_EIP (14)
#endif
#endif
#define REG_SZ (4)

View File

@ -1,29 +1,95 @@
#ifndef __ARCH_X86_64_DEFS_H
#define __ARCH_X86_64_DEFS_H
#ifndef _GNU_SOURCE
#ifndef REG_R8
# define REG_R8 (0)
#endif
#ifndef REG_R9
# define REG_R9 (1)
#endif
#ifndef REG_R10
# define REG_R10 (2)
#endif
#ifndef REG_R11
# define REG_R11 (3)
#endif
#ifndef REG_R12
# define REG_R12 (4)
#endif
#ifndef REG_R13
# define REG_R13 (5)
#endif
#ifndef REG_R14
# define REG_R14 (6)
#endif
#ifndef REG_R15
# define REG_R15 (7)
#endif
#ifndef REG_RDI
# define REG_RDI (8)
#endif
#ifndef REG_RSI
# define REG_RSI (9)
#endif
#ifndef REG_RBP
# define REG_RBP (10)
#endif
#ifndef REG_RBX
# define REG_RBX (11)
#endif
#ifndef REG_RDX
# define REG_RDX (12)
#endif
#ifndef REG_RAX
# define REG_RAX (13)
#endif
#ifndef REG_RCX
# define REG_RCX (14)
#endif
#ifndef REG_RSP
# define REG_RSP (15)
#endif
#ifndef REG_RIP
# define REG_RIP (16)
#endif
#ifndef REG_EFL
# define REG_EFL (17)
#endif
#ifndef REG_CSGSFS
# define REG_CSGSFS (18)
#endif
#ifndef REG_ERR
# define REG_ERR (19)
#endif
#ifndef REG_TRAPNO
# define REG_TRAPNO (20)
#endif
#ifndef REG_OLDMASK
# define REG_OLDMASK (21)
#endif
#ifndef REG_CR2
# define REG_CR2 (22)
#endif

View File

@ -70,9 +70,11 @@ if freestanding
build_args += '-DFREESTANDING'
build_posix = false
export_unprefixed = false
project_headers += ['arch' / cpu / 'freestanding/bits.h']
project_headers += ['arch' / cpu / 'include/libucontext/bits.h']
project_includes += ['arch' / cpu / 'include']
else
project_headers += ['arch/common/bits.h']
project_headers += ['arch/common/include/libucontext/bits.h']
project_includes += ['arch/common/include']
endif
if export_unprefixed