code wiki / (root) / nx_elf_writer.nx

nx_elf_writer.nx

buildroot/runtime/nx_elf_writer.nx

5444 B159 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind orphan librarytopic elf
docsdependenciesstructsconstsfunctions

about

nx_elf_writer.nx -- sovereign ELF64 binary writer. Pure NishiLang. Takes an exit-code integer; writes a complete static-linked x86_64 ELF binary to a file descriptor. No as. No ld. No gcc. No libc. The output is bytes that Linux execve loads and runs. Today: smallest credible binary -- `_start: mov rdi, N; mov rax, 231; syscall` (exit_group with code N). Total ELF size: 134 bytes. Tomorrow (L19b): take an IR snapshot (nxc2 --target ir > foo.ir), read it, emit the corresponding x86_64 bytes. That closes the "nxc2 emits ELF directly" loop without adding more C to nxc2. Cardinal alignment: feedback-nishilang-mission-displace-cuda-directx-via-patent-clean- absorption: every new substrate file is .nx. This file replaces the temptation to add an ELF emitter to x86_64.c. genealogy_id: elf_specification_v1_2 + linux_kernel_load_elf + sysv_abi lineage_id: sovereign_elf_emit_q10

dependencies 1 imports · 0 importers

nx_syscalls_x86_64.nx nx_elf_writer.nx

imports: nx_syscalls_x86_64.nx

imported by: nobody (leaf or entry point)

structs

none

consts

32const NX_ELF_VERDICT_UNKNOWN: i64 = 0
33const NX_ELF_VERDICT_OK: i64 = 1
34const NX_ELF_VERDICT_WRITE_FAIL: i64 = 2
35const NX_ELF_VERDICT_N: i64 = 3
37const NX_ELF_BASE_VADDR_LO: i64 = 0x400000
38const NX_ELF_TEXT_OFFSET: i64 = 0x78 // sizeof(Ehdr=64) + sizeof(Phdr=56)
106const NX_ELF_TEXT_LEN: i64 = 16
107const NX_ELF_FILE_SIZE: i64 = 136

functions

41func _wb(fd: i64, b: i64) -> i64
48func _wn(fd: i64, buf: *u8, n: i64) -> i64
53func _w16(fd: i64, v: i64) -> i64
61func _w32(fd: i64, v: i64) -> i64
71func _w64(fd: i64, v: i64) -> i64
92func _emit_text(fd: i64, exit_code: i64) -> i64
111func nx_elf_emit_return_n(fd: i64, exit_code: i64) -> i64
155func nx_elf_verdict_is_valid(v: i64) -> i64