Simplified executable file formats

This commit is contained in:
Eduard Urbach 2024-08-15 00:46:49 +02:00
parent 1cb93b39a7
commit 999e60e294
Signed by: eduard
GPG key ID: 49226B848C78F6C8
29 changed files with 236 additions and 218 deletions

View file

@ -10,11 +10,11 @@ import (
"git.akyoto.dev/cli/q/src/asm"
"git.akyoto.dev/cli/q/src/config"
"git.akyoto.dev/cli/q/src/core"
"git.akyoto.dev/cli/q/src/exe/elf"
"git.akyoto.dev/cli/q/src/exe/macho"
"git.akyoto.dev/cli/q/src/exe/pe"
"git.akyoto.dev/cli/q/src/os/linux"
"git.akyoto.dev/cli/q/src/os/linux/elf"
"git.akyoto.dev/cli/q/src/os/mac"
"git.akyoto.dev/cli/q/src/os/mac/macho"
"git.akyoto.dev/cli/q/src/os/windows/pe"
)
// Result contains all the compiled functions in a build.
@ -147,14 +147,11 @@ func write(writer io.Writer, code []byte, data []byte) error {
switch config.TargetOS {
case "linux":
exe := elf.New(code, data)
exe.Write(buffer)
elf.Write(buffer, code, data)
case "mac":
exe := macho.New(code, data)
exe.Write(buffer)
macho.Write(buffer, code, data)
case "windows":
exe := pe.New(code, data)
exe.Write(buffer)
pe.Write(buffer, code, data)
default:
return fmt.Errorf("unsupported platform '%s'", config.TargetOS)
}