diff --git a/flake.nix b/flake.nix index 91369158c..33945b428 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,7 @@ go buddy-mlir rvv-codegen + rv32-gnu-toolchain ]; emulatorDeps = with pkgs; [ diff --git a/overlay.nix b/overlay.nix index e2b8e6f3e..b318fcfd0 100644 --- a/overlay.nix +++ b/overlay.nix @@ -79,6 +79,7 @@ in buddy-mlir = final.callPackage ./nix/buddy-mlir.nix { }; rvv-codegen = final.callPackage ./nix/rvv-codegen.nix { }; rvv-testcase = final.callPackage ./nix/rvv-testcase-unwrapped.nix { }; + rv32-gnu-toolchain = final.callPackage ./nix/riscv-gnu-toolchain.nix { }; inherit rv32-clang my-cc-wrapper; } diff --git a/tests/intrinsic/main.S b/tests/intrinsic/main.S index ca554a81c..c20d94483 100644 --- a/tests/intrinsic/main.S +++ b/tests/intrinsic/main.S @@ -1,4 +1,5 @@ .globl start + .globl heap_end start: li a0, 0x2200 # MSTATUS_VS & (MSTATUS_VS >> 1) csrs mstatus, a0 @@ -14,3 +15,8 @@ stack_start: .zero 0x10000 stack_end: + +heap_start: + .zero 0x100000 + +heap_end: diff --git a/tests/intrinsic/sys.c b/tests/intrinsic/sys.c new file mode 100644 index 000000000..8ac02e114 --- /dev/null +++ b/tests/intrinsic/sys.c @@ -0,0 +1,34 @@ +extern char* heap_end; +char *heap_ptr; + +char *_sbrk(int nbytes) { + char *base; + + if (!heap_ptr) + heap_ptr = (char *)&heap_end; + base = heap_ptr; + heap_ptr += nbytes; + + return base; +} + +void _exit(int code) { + __asm__("csrwi 0x7cc, 0"); + __builtin_unreachable(); +} + +int _close(int file) { + return -1; +} + +int _lseek(int file, int ptr, int dir) { + return -1; +} + +int _read(int file, char* ptr, int len) { + return -1; +} + +int _write(int file, char* ptr, int len) { + return -1; +}