mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 16:28:30 +00:00
Get MbedTLS and its unit tests passing AARCH64
This commit is contained in:
parent
5e2f7f7ced
commit
4edbc98811
37 changed files with 632 additions and 725 deletions
|
@ -68,7 +68,13 @@ _start:
|
|||
lea 8(%rsp),%rsi // argv
|
||||
lea 16(%rsp,%rbx,8),%rdx // envp
|
||||
mov %rsp,__oldstack(%rip)
|
||||
and $-16,%rsp
|
||||
|
||||
// setup a stack frame
|
||||
// align stack to GetStackSize() so GetStackAddr() is fast
|
||||
.weak ape_stack_memsz
|
||||
mov $ape_stack_memsz,%r8d
|
||||
neg %r8
|
||||
and %r8,%rsp
|
||||
xor %ebp,%ebp
|
||||
// bofram 9f
|
||||
|
||||
|
@ -107,10 +113,23 @@ _start:
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
#elif defined(__aarch64__)
|
||||
|
||||
// save original stack pointer
|
||||
// this is the first argument to cosmo() below
|
||||
mov x0,sp
|
||||
|
||||
// setup stack frame
|
||||
mov x29,#0
|
||||
mov x30,#0
|
||||
mov x0,sp
|
||||
and sp,x0,#-16
|
||||
|
||||
// align stack to GetStackSize() so GetStackAddr() is fast
|
||||
mov x1,sp
|
||||
.weak ape_stack_memsz
|
||||
ldr x2,=ape_stack_memsz
|
||||
neg x2,x2
|
||||
and x1,x2,x1
|
||||
mov sp,x1
|
||||
|
||||
// switch to c start function
|
||||
b cosmo
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -125,8 +125,7 @@ extern char ape_stack_align[] __attribute__((__weak__));
|
|||
* Returns true if at least `n` bytes of stack are available.
|
||||
*/
|
||||
#define HaveStackMemory(n) \
|
||||
(IsTiny() || \
|
||||
(intptr_t)__builtin_frame_address(0) >= GetStackAddr() + GUARDSIZE + (n))
|
||||
((intptr_t)__builtin_frame_address(0) >= GetStackAddr() + GUARDSIZE + (n))
|
||||
|
||||
forceinline void CheckLargeStackAllocation(void *p, ssize_t n) {
|
||||
for (; n > 0; n -= 4096) {
|
||||
|
|
|
@ -79,7 +79,6 @@ static textexit void LogStackUse(void) {
|
|||
}
|
||||
|
||||
static textstartup void LogStackUseInit(void) {
|
||||
if (IsTiny()) return;
|
||||
if (!PLEDGED(WPATH)) return;
|
||||
if (isdirectory("o/" MODE) &&
|
||||
getcwd(stacklog, sizeof(stacklog) - strlen("/o/" MODE "/stack.log"))) {
|
||||
|
|
|
@ -218,3 +218,18 @@ void testlib_showerror_expect_false(int line, //
|
|||
testlib_showerror_(line, wantcode, gotcode, FREED_want, FREED_got, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void testlib_showerror_expect_matrixeq(int line, //
|
||||
const char *wantcode, //
|
||||
const char *gotcode, //
|
||||
char *FREED_want, //
|
||||
char *FREED_got, //
|
||||
const char *fmt, //
|
||||
...) {
|
||||
va_list va;
|
||||
testlib_showerror_macro = "EXPECT_MATRIXEQ";
|
||||
testlib_showerror_symbol = "=";
|
||||
va_start(va, fmt);
|
||||
testlib_showerror_(line, wantcode, gotcode, FREED_want, FREED_got, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
|
|
@ -62,11 +62,19 @@ COSMOPOLITAN_C_START_
|
|||
#define EXPECT_LE(C, X) _TEST2("EXPECT_LE", C, <=, (X), #C, " ≤ ", #X, 0)
|
||||
#define EXPECT_LT(C, X) _TEST2("EXPECT_LT", C, <, (X), #C, " < ", #X, 0)
|
||||
|
||||
#define __TEST_ARRAY(S) \
|
||||
_Section(".piro.relo.sort.testcase.2." #S ",\"aw\",@init_array #")
|
||||
#ifdef __aarch64__
|
||||
#define _TESTLIB_ASM_COMMENT "//"
|
||||
#else
|
||||
#define _TESTLIB_ASM_COMMENT "#"
|
||||
#endif
|
||||
|
||||
#define __BENCH_ARRAY(S) \
|
||||
_Section(".piro.relo.sort.bench.2." #S ",\"aw\",@init_array #")
|
||||
#define __TEST_ARRAY(S) \
|
||||
_Section(".piro.relo.sort.testcase.2." #S \
|
||||
",\"aw\",@init_array "_TESTLIB_ASM_COMMENT)
|
||||
|
||||
#define __BENCH_ARRAY(S) \
|
||||
_Section(".piro.relo.sort.bench.2." #S \
|
||||
",\"aw\",@init_array "_TESTLIB_ASM_COMMENT)
|
||||
|
||||
#define __TEST_PROTOTYPE(S, N, A, K) \
|
||||
void S##_##N(void); \
|
||||
|
|
12
libc/x/x.mk
12
libc/x/x.mk
|
@ -17,16 +17,8 @@ LIBC_X = $(LIBC_X_A_DEPS) $(LIBC_X_A)
|
|||
LIBC_X_A = o/$(MODE)/libc/x/x.a
|
||||
LIBC_X_A_FILES := $(wildcard libc/x/*)
|
||||
LIBC_X_A_HDRS = $(filter %.h,$(LIBC_X_A_FILES))
|
||||
LIBC_X_A_SRCS_S = $(filter %.S,$(LIBC_X_A_FILES))
|
||||
LIBC_X_A_SRCS_C = $(filter %.c,$(LIBC_X_A_FILES))
|
||||
|
||||
LIBC_X_A_SRCS = \
|
||||
$(LIBC_X_A_SRCS_S) \
|
||||
$(LIBC_X_A_SRCS_C)
|
||||
|
||||
LIBC_X_A_OBJS = \
|
||||
$(LIBC_X_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(LIBC_X_A_SRCS_C:%.c=o/$(MODE)/%.o)
|
||||
LIBC_X_A_SRCS = $(filter %.c,$(LIBC_X_A_FILES))
|
||||
LIBC_X_A_OBJS = $(LIBC_X_A_SRCS:%.c=o/$(MODE)/%.o)
|
||||
|
||||
LIBC_X_A_CHECKS = \
|
||||
$(LIBC_X_A).pkg \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue