This commit is contained in:
static
2025-06-17 01:02:22 +00:00
parent e3ab187dea
commit c2b8d71e16
3 changed files with 1149 additions and 621 deletions

23
test-asmgen.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# 사용법 확인
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <path-to-c-file>"
echo "Example: $0 examples/c/unary.c"
exit 1
fi
INPUT_C_FILE="$1"
OUTPUT_S_FILE="hello.S"
OUTPUT_BIN="hello"
GDB_PORT=8888
# 1단계: Rust 바이너리 빌드 및 어셈블리 생성
cargo run --features=build-bin -- "$INPUT_C_FILE" > "$OUTPUT_S_FILE"
# 2단계: 리눅스용 RISC-V 정적 바이너리 생성
riscv64-linux-gnu-gcc -static "$OUTPUT_S_FILE" -o "$OUTPUT_BIN"
# 3단계: QEMU로 RISC-V 바이너리 실행
qemu-riscv64-static "$OUTPUT_BIN"
echo $?