Merge pull request #56 from riscv/config
[riscv-tests.git] / debug / programs / init.c
index 074bc2178de4ca96a0152186099d2d86339aa8de..a2b41b02d60e2eb51af3d9322dcedb2f72460c67 100644 (file)
@@ -6,9 +6,19 @@ void handle_trap(unsigned int mcause, unsigned int mepc, unsigned int sp)
         ;
 }
 
-void _init()
+void _exit(int status)
 {
-    main();
+    // Make sure gcc doesn't inline _exit, so we can actually set a breakpoint
+    // on it.
+    volatile int i = 42;
+    while (i)
+        ;
+    // _exit isn't supposed to return.
     while (1)
         ;
 }
+
+void _init()
+{
+    _exit(main());
+}