CI tests for MACOS build (#46)

This commit is contained in:
Dmitry Stogov 2023-08-30 15:24:12 +03:00 committed by GitHub
parent 474a8a8d5a
commit 0dbb794399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 62 additions and 38 deletions

View File

@ -84,6 +84,17 @@ jobs:
# FIXME: For some reason some of the object files are rebuilt # FIXME: For some reason some of the object files are rebuilt
make CC=gcc CXX=g++-12 TARGET=aarch64 test-ci make CC=gcc CXX=g++-12 TARGET=aarch64 test-ci
MACOS_x86_64:
runs-on: macos-11
steps:
- uses: actions/checkout@v3
- name: brew
run: brew install capstone
- name: make
run: make TARGET=x86_64 all
- name: test
run: make CXX=g++-12 TARGET=x86_64 test-ci
Windows: Windows:
strategy: strategy:
matrix: matrix:

View File

@ -81,7 +81,7 @@ $(SRC_DIR)/ir_load.c: $(SRC_DIR)/ir.g
$(BUILD_DIR)/ir_fold_hash.h: $(BUILD_DIR)/gen_ir_fold_hash $(SRC_DIR)/ir_fold.h $(SRC_DIR)/ir.h $(BUILD_DIR)/ir_fold_hash.h: $(BUILD_DIR)/gen_ir_fold_hash $(SRC_DIR)/ir_fold.h $(SRC_DIR)/ir.h
$(BUILD_DIR)/gen_ir_fold_hash < $(SRC_DIR)/ir_fold.h > $(BUILD_DIR)/ir_fold_hash.h $(BUILD_DIR)/gen_ir_fold_hash < $(SRC_DIR)/ir_fold.h > $(BUILD_DIR)/ir_fold_hash.h
$(BUILD_DIR)/gen_ir_fold_hash: $(SRC_DIR)/gen_ir_fold_hash.c $(SRC_DIR)/ir_strtab.c $(SRC_DIR)/ir.h $(BUILD_DIR)/gen_ir_fold_hash: $(SRC_DIR)/gen_ir_fold_hash.c $(SRC_DIR)/ir_strtab.c $(SRC_DIR)/ir.h
$(BUILD_CC) $(CFLAGS) $(LDFALGS) -o $@ $^ $(BUILD_CC) $(CFLAGS) $(LDFALGS) -o $@ $<
$(BUILD_DIR)/minilua: $(SRC_DIR)/dynasm/minilua.c $(BUILD_DIR)/minilua: $(SRC_DIR)/dynasm/minilua.c
$(BUILD_CC) $(SRC_DIR)/dynasm/minilua.c -lm -o $@ $(BUILD_CC) $(SRC_DIR)/dynasm/minilua.c -lm -o $@

View File

@ -10,6 +10,8 @@
#include "ir.h" #include "ir.h"
#include <string.h> #include <string.h>
#include "ir_strtab.c"
#define MAX_RULES 2048 #define MAX_RULES 2048
#define MAX_SLOTS (MAX_RULES * 4) #define MAX_SLOTS (MAX_RULES * 4)

3
ir.h
View File

@ -714,6 +714,9 @@ int32_t ir_get_spill_slot_offset(ir_ctx *ctx, ir_ref ref);
int ir_match(ir_ctx *ctx); int ir_match(ir_ctx *ctx);
void *ir_emit_code(ir_ctx *ctx, size_t *size); void *ir_emit_code(ir_ctx *ctx, size_t *size);
/* Target address resolution (implementation in ir_emit.c) */
void *ir_resolve_sym_name(const char *name);
/* Target CPU disassembler (implementation in ir_disasm.c) */ /* Target CPU disassembler (implementation in ir_disasm.c) */
int ir_disasm_init(void); int ir_disasm_init(void);
void ir_disasm_free(void); void ir_disasm_free(void);

View File

@ -260,7 +260,7 @@ static bool ir_is_same_mem_var(const ir_ctx *ctx, ir_ref r1, int32_t offset)
return o1 == offset; return o1 == offset;
} }
static void *ir_resolve_sym_name(const char *name) void *ir_resolve_sym_name(const char *name)
{ {
void *handle = NULL; void *handle = NULL;
void *addr; void *addr;

View File

@ -453,12 +453,20 @@ int main(int argc, char **argv)
if (entry) { if (entry) {
if (dump_asm) { if (dump_asm) {
ir_ref i;
ir_insn *insn;
ir_disasm_add_symbol("test", (uintptr_t)entry, size); ir_disasm_add_symbol("test", (uintptr_t)entry, size);
#ifdef _WIN32
/* Quick workaraund to prevent *.irt tests failures */ for (i = IR_UNUSED + 1, insn = ctx.ir_base - i; i < ctx.consts_count; i++, insn--) {
// TODO: try to find a general solution ??? if (insn->op == IR_FUNC) {
ir_disasm_add_symbol("printf", (uintptr_t)(void*)printf, sizeof(void*)); const char *name = ir_get_str(&ctx, insn->val.i32);
#endif void *addr = ir_resolve_sym_name(name);
ir_disasm_add_symbol(name, (uintptr_t)addr, sizeof(void*));
}
}
ir_disasm("test", entry, size, 0, &ctx, stderr); ir_disasm("test", entry, size, 0, &ctx, stderr);
} }
if (dump_size) { if (dump_size) {

View File

@ -41,7 +41,7 @@ test:
str x16, [sp, #8] str x16, [sp, #8]
movz x16, #0x1, lsl #32 movz x16, #0x1, lsl #32
str x16, [sp, #0x10] str x16, [sp, #0x10]
bl _IO_printf bl printf
add sp, sp, #0x20 add sp, sp, #0x20
ldp x29, x30, [sp], #0x10 ldp x29, x30, [sp], #0x10
ret ret

View File

@ -40,7 +40,7 @@ test:
str d31, [sp] str d31, [sp]
fmov d31, xzr fmov d31, xzr
str d31, [sp, #8] str d31, [sp, #8]
bl _IO_printf bl printf
add sp, sp, #0x10 add sp, sp, #0x10
ldp x29, x30, [sp], #0x10 ldp x29, x30, [sp], #0x10
ret ret

View File

@ -22,7 +22,7 @@ test:
mov x29, sp mov x29, sp
adr x0, .L1 adr x0, .L1
movz w1, #0x2a movz w1, #0x2a
bl _IO_printf bl printf
str w0, [x29, #0x10] str w0, [x29, #0x10]
ldr w0, [x29, #0x10] ldr w0, [x29, #0x10]
ldp x29, x30, [sp], #0x20 ldp x29, x30, [sp], #0x20

View File

@ -22,7 +22,7 @@ test:
mov x29, sp mov x29, sp
adr x0, .L1 adr x0, .L1
movz w1, #0x2a movz w1, #0x2a
bl _IO_printf bl printf
ldp x29, x30, [sp], #0x10 ldp x29, x30, [sp], #0x10
ret ret
.rodata .rodata

View File

@ -32,7 +32,7 @@ test:
mov w2, w3 mov w2, w3
mov w3, w16 mov w3, w16
adr x0, .L1 adr x0, .L1
bl _IO_printf bl printf
add w0, w0, w19 add w0, w0, w19
ldr x19, [x29, #0x18] ldr x19, [x29, #0x18]
ldp x29, x30, [sp], #0x20 ldp x29, x30, [sp], #0x20

View File

@ -58,7 +58,7 @@ test:
strb w1, [x0, #5] strb w1, [x0, #5]
strb wzr, [x0, #6] strb wzr, [x0, #6]
movz w1, #0x2a movz w1, #0x2a
bl _IO_printf bl printf
mov sp, x29 mov sp, x29
ldp x29, x30, [sp], #0x10 ldp x29, x30, [sp], #0x10
ret ret

View File

@ -57,7 +57,7 @@ test:
strb w1, [x0, #5] strb w1, [x0, #5]
strb wzr, [x0, #6] strb wzr, [x0, #6]
movz w1, #0x2a movz w1, #0x2a
bl _IO_printf bl printf
ldp x29, x30, [sp], #0x20 ldp x29, x30, [sp], #0x20
ret ret

View File

@ -41,7 +41,7 @@ test:
str w16, [sp, #8] str w16, [sp, #8]
ldr w16, [x29, #0x28] ldr w16, [x29, #0x28]
str w16, [sp, #0x10] str w16, [sp, #0x10]
bl _IO_printf bl printf
add sp, sp, #0x20 add sp, sp, #0x20
ldp x29, x30, [sp], #0x10 ldp x29, x30, [sp], #0x10
ret ret

View File

@ -91,7 +91,7 @@ test:
fsub d0, d1, d0 fsub d0, d1, d0
str d0, [x29, #0x10] str d0, [x29, #0x10]
adr x0, .L5 adr x0, .L5
bl _IO_printf bl printf
b .L1 b .L1
.L2: .L2:
mov w0, wzr mov w0, wzr

View File

@ -91,10 +91,10 @@ test:
fsub d0, d1, d0 fsub d0, d1, d0
str d0, [x29, #0x10] str d0, [x29, #0x10]
adr x0, .L5 adr x0, .L5
bl _IO_printf bl printf
adr x0, .L5 adr x0, .L5
ldr d0, [x29, #0x10] ldr d0, [x29, #0x10]
bl _IO_printf bl printf
b .L1 b .L1
.L2: .L2:
mov w0, wzr mov w0, wzr

View File

@ -77,7 +77,7 @@ test:
add w20, w19, w0 add w20, w19, w0
mov w1, w19 mov w1, w19
adr x0, .L3 adr x0, .L3
bl _IO_printf bl printf
mov w0, w19 mov w0, w19
mov w19, w20 mov w19, w20
b .L1 b .L1

View File

@ -20,7 +20,7 @@ aarch64
test: test:
adr x0, .L1 adr x0, .L1
movz w1, #0x2a movz w1, #0x2a
b _IO_printf b printf
.rodata .rodata
.db 0x1f, 0x20, 0x03, 0xd5 .db 0x1f, 0x20, 0x03, 0xd5
.L1: .L1:

View File

@ -22,7 +22,7 @@ TAILCALL for functions with stack argumnts is not implemented
test: test:
leaq .L1(%rip), %rdi leaq .L1(%rip), %rdi
movl $0x2a, %esi movl $0x2a, %esi
movabsq $_IO_printf, %rax movabsq $printf, %rax
jmpq *%rax jmpq *%rax
.rodata .rodata
.L1: .L1:

View File

@ -37,7 +37,7 @@ test:
movq $9, 0x18(%rsp) movq $9, 0x18(%rsp)
movabsq $0x100000000, %rax movabsq $0x100000000, %rax
movq %rax, 0x20(%rsp) movq %rax, 0x20(%rsp)
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
addq $0x28, %rsp addq $0x28, %rsp
retq retq

View File

@ -37,7 +37,7 @@ test:
movabsq $0x3feccccccccccccd, %rax movabsq $0x3feccccccccccccd, %rax
movq %rax, (%rsp) movq %rax, (%rsp)
movq $0, 8(%rsp) movq $0, 8(%rsp)
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
addq $0x18, %rsp addq $0x18, %rsp
retq retq

View File

@ -21,7 +21,7 @@ test:
subq $8, %rsp subq $8, %rsp
leaq .L1(%rip), %rdi leaq .L1(%rip), %rdi
movl $0x2a, %esi movl $0x2a, %esi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
movl %eax, (%rsp) movl %eax, (%rsp)
movl (%rsp), %eax movl (%rsp), %eax

View File

@ -21,7 +21,7 @@ test:
subq $8, %rsp subq $8, %rsp
leaq .L1(%rip), %rdi leaq .L1(%rip), %rdi
movl $0x2a, %esi movl $0x2a, %esi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
addq $8, %rsp addq $8, %rsp
retq retq

View File

@ -31,7 +31,7 @@ test:
movl %edx, %esi movl %edx, %esi
movl %eax, %edx movl %eax, %edx
leaq .L1(%rip), %rdi leaq .L1(%rip), %rdi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
addl %ebx, %eax addl %ebx, %eax
movq (%rsp), %rbx movq (%rsp), %rbx

View File

@ -22,7 +22,7 @@ test:
movl %edi, %edx movl %edi, %edx
movl %edx, %esi movl %edx, %esi
leaq .L1(%rip), %rdi leaq .L1(%rip), %rdi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
addq $8, %rsp addq $8, %rsp
retq retq

View File

@ -52,7 +52,7 @@ test:
movb $0xa, 5(%rdi) movb $0xa, 5(%rdi)
movb $0, 6(%rdi) movb $0, 6(%rdi)
movl $0x2a, %esi movl $0x2a, %esi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
movq %rbp, %rsp movq %rbp, %rsp
popq %rbp popq %rbp

View File

@ -50,7 +50,7 @@ test:
movb $0xa, 5(%rdi) movb $0xa, 5(%rdi)
movb $0, 6(%rdi) movb $0, 6(%rdi)
movl $0x2a, %esi movl $0x2a, %esi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
addq $8, %rsp addq $8, %rsp
retq retq

View File

@ -41,7 +41,7 @@ test:
movl %eax, 0x18(%rsp) movl %eax, 0x18(%rsp)
movl 0x48(%rsp), %eax movl 0x48(%rsp), %eax
movl %eax, 0x20(%rsp) movl %eax, 0x20(%rsp)
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
addq $0x28, %rsp addq $0x28, %rsp
retq retq

View File

@ -25,7 +25,7 @@ test:
movsd %xmm1, 8(%rsp) movsd %xmm1, 8(%rsp)
movsd %xmm2, 0x10(%rsp) movsd %xmm2, 0x10(%rsp)
leaq .L1(%rip), %rdi leaq .L1(%rip), %rdi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
movsd (%rsp), %xmm1 movsd (%rsp), %xmm1
subsd 8(%rsp), %xmm1 subsd 8(%rsp), %xmm1

View File

@ -25,7 +25,7 @@ test:
movsd %xmm1, 8(%rsp) movsd %xmm1, 8(%rsp)
movsd %xmm2, 0x10(%rsp) movsd %xmm2, 0x10(%rsp)
leaq .L1(%rip), %rdi leaq .L1(%rip), %rdi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
movsd (%rsp), %xmm1 movsd (%rsp), %xmm1
addsd %xmm1, %xmm1 addsd %xmm1, %xmm1

View File

@ -88,7 +88,7 @@ test:
subsd %xmm1, %xmm0 subsd %xmm1, %xmm0
movsd %xmm0, 8(%rsp) movsd %xmm0, 8(%rsp)
leaq .L5(%rip), %rdi leaq .L5(%rip), %rdi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
movsd 8(%rsp), %xmm1 movsd 8(%rsp), %xmm1
jmp .L1 jmp .L1

View File

@ -88,11 +88,11 @@ test:
subsd %xmm1, %xmm0 subsd %xmm1, %xmm0
movsd %xmm0, 8(%rsp) movsd %xmm0, 8(%rsp)
leaq .L5(%rip), %rdi leaq .L5(%rip), %rdi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
leaq .L5(%rip), %rdi leaq .L5(%rip), %rdi
movsd 8(%rsp), %xmm0 movsd 8(%rsp), %xmm0
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
movsd 8(%rsp), %xmm1 movsd 8(%rsp), %xmm1
jmp .L1 jmp .L1

View File

@ -76,7 +76,7 @@ test:
leal (%rbx, %rax), %ebp leal (%rbx, %rax), %ebp
movl %ebx, %esi movl %ebx, %esi
leaq .L3(%rip), %rdi leaq .L3(%rip), %rdi
movabsq $_IO_printf, %rax movabsq $printf, %rax
callq *%rax callq *%rax
movl %ebx, %eax movl %ebx, %eax
movl %ebp, %ebx movl %ebp, %ebx

View File

@ -20,7 +20,7 @@ x86_64
test: test:
leaq .L1(%rip), %rdi leaq .L1(%rip), %rdi
movl $0x2a, %esi movl $0x2a, %esi
movabsq $_IO_printf, %rax movabsq $printf, %rax
jmpq *%rax jmpq *%rax
.rodata .rodata
.L1: .L1:

View File

@ -93,7 +93,7 @@ $(BUILD_DIR)\ir_test.exe: $(OBJS_IR_TEST) $(OBJS_COMMON) $(LIBCAPSTONE)
$(BUILD_DIR)\ir_fold_hash.h: $(BUILD_DIR)\gen_ir_fold_hash.exe $(SRC_DIR)\ir_fold.h $(SRC_DIR)\ir.h $(BUILD_DIR)\ir_fold_hash.h: $(BUILD_DIR)\gen_ir_fold_hash.exe $(SRC_DIR)\ir_fold.h $(SRC_DIR)\ir.h
$(BUILD_DIR)\gen_ir_fold_hash.exe < $(SRC_DIR)\ir_fold.h > $(BUILD_DIR)\ir_fold_hash.h $(BUILD_DIR)\gen_ir_fold_hash.exe < $(SRC_DIR)\ir_fold.h > $(BUILD_DIR)\ir_fold_hash.h
$(BUILD_DIR)\gen_ir_fold_hash.exe: $(SRC_DIR)\gen_ir_fold_hash.c $(SRC_DIR)\ir_strtab.c $(SRC_DIR)\ir.h $(BUILD_DIR)\gen_ir_fold_hash.exe: $(SRC_DIR)\gen_ir_fold_hash.c $(SRC_DIR)\ir_strtab.c $(SRC_DIR)\ir.h
"$(CC)" $(CFLAGS) /Fo$(BUILD_DIR)\ /Fe$@ $(SRC_DIR)\gen_ir_fold_hash.c $(SRC_DIR)\ir_strtab.c "$(CC)" $(CFLAGS) /Fo$(BUILD_DIR)\ /Fe$@ $(SRC_DIR)\gen_ir_fold_hash.c
$(BUILD_DIR)\minilua.exe: $(SRC_DIR)\dynasm\minilua.c $(BUILD_DIR)\minilua.exe: $(SRC_DIR)\dynasm\minilua.c
"$(CC)" /Fo$(BUILD_DIR)\ /Fe$@ $** "$(CC)" /Fo$(BUILD_DIR)\ /Fe$@ $**