mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-14 22:38:46 +00:00
HW7 (1)
This commit is contained in:
24
debug-asmgen.sh
Executable file
24
debug-asmgen.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/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 -ggdb -static "$OUTPUT_S_FILE" -o "$OUTPUT_BIN"
|
||||
|
||||
# 3단계: QEMU로 RISC-V 바이너리 실행 (GDB 포트 열림)
|
||||
qemu-riscv64-static -g "$GDB_PORT" "$OUTPUT_BIN" &
|
||||
echo "Ready!"
|
||||
wait
|
||||
Reference in New Issue
Block a user