Improved debug info emit

This commit is contained in:
nub31
2025-10-17 23:22:04 +02:00
parent e703a2ca25
commit 1fdeb60eb5
5 changed files with 20 additions and 27 deletions

View File

@@ -91,10 +91,10 @@ if (moduleRepository.Modules().TryGetValue("main", out var mainModule))
.text
.globl _start
_start:
mov rdi, rsp # Pass stack pointer to main (argv-like)
mov rdi, [rsp + 8] # Pass stack pointer to main (argv-like)
call {mainFunction.ExternSymbol}
mov rdi, rax # Move return value into rdi
mov rax, 60 # syscall: exit
mov rdi, rax # Move return value into rdi
mov rax, 60 # syscall: exit
syscall
""";
@@ -102,8 +102,9 @@ if (moduleRepository.Modules().TryGetValue("main", out var mainModule))
var runtimePath = Path.Combine(".build", "runtime.s");
File.WriteAllText(runtimePath, runtime);
using var assembleProcess = Process.Start(new ProcessStartInfo("as", ["-c", runtimePath, "-o", Path.Combine(".build", "runtime.o")]));
using var assembleProcess = Process.Start(new ProcessStartInfo("as", ["-g", "-c", runtimePath, "-o", Path.Combine(".build", "runtime.o")]));
if (assembleProcess == null) return 1;
assembleProcess.WaitForExit();
if (assembleProcess.ExitCode != 0)
{