nx_elf_writer.nx
buildroot/runtime/nx_elf_writer.nx
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
imports: nx_syscalls_x86_64.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 32 | const NX_ELF_VERDICT_UNKNOWN: i64 = 0 |
| 33 | const NX_ELF_VERDICT_OK: i64 = 1 |
| 34 | const NX_ELF_VERDICT_WRITE_FAIL: i64 = 2 |
| 35 | const NX_ELF_VERDICT_N: i64 = 3 |
| 37 | const NX_ELF_BASE_VADDR_LO: i64 = 0x400000 |
| 38 | const NX_ELF_TEXT_OFFSET: i64 = 0x78 // sizeof(Ehdr=64) + sizeof(Phdr=56) |
| 106 | const NX_ELF_TEXT_LEN: i64 = 16 |
| 107 | const NX_ELF_FILE_SIZE: i64 = 136 |
functions
| 41 | func _wb(fd: i64, b: i64) -> i64 called by 1: nx_elf_emit_return_n |
| 48 | func _wn(fd: i64, buf: *u8, n: i64) -> i64 |
| 53 | func _w16(fd: i64, v: i64) -> i64 called by 1: nx_elf_emit_return_n |
| 61 | func _w32(fd: i64, v: i64) -> i64 called by 1: nx_elf_emit_return_n |
| 71 | func _w64(fd: i64, v: i64) -> i64 called by 1: nx_elf_emit_return_n |
| 92 | func _emit_text(fd: i64, exit_code: i64) -> i64 called by 1: nx_elf_emit_return_n |
| 111 | func nx_elf_emit_return_n(fd: i64, exit_code: i64) -> i64 |
| 155 | func nx_elf_verdict_is_valid(v: i64) -> i64 |