code wiki / _hdl_build / nx_nxe_loader.nx
nx_nxe_loader.nx
buildroot/runtime/_hdl_build/nx_nxe_loader.nx
about
nx_nxe_loader.nx -- GATE: the NATIVE NXE LOADER that VERIFIES then EXECUTES (composes nx_nxe_lib, rule-15 DRY).
Closes the EXEC-FORMAT census gap ("emit organs AS .nxe + a native NXE loader/boot" -- organs were ELF-only, the
NXE format was write+header-check only). This loader actually RUNS the code section: mmap RWX -> copy the verified
code -> cast the entry to a function pointer -> CALL it on this machine (proven by nx_nxe_exec_probe).
THE EXCEED vs ELF/Mach-O/PE (grounded osb_elf/osb_loader): verify-BEFORE-execute BY CONSTRUCTION. An ELF loader
maps+jumps to whatever bytes are present; NXE refuses to even map-exec a binary that fails ANY of:
(1) INTEGRITY -- a FIPS-180-4 SHA-256 of the code section, baked in the header; a tampered byte -> refused.
(2) CAPABILITY -- the binary must DECLARE the EXEC capability to be executed (least-privilege manifest).
(3) NEVER-BRICK (cardinal 26 in the format) -- a HW_WRITE binary without a never-brick proof -> refused.
Only after all three pass does a single byte execute. Payload = a REAL function f(x)=x*x+1 in x86_64 machine code.
T1 write+load+EXECUTE (f(7)=50, f(12)=145). T2 tamper->SHA-256 fail->REFUSED(-2), never executes.
T3 no-EXEC-cap->REFUSED(-4). T4 HW_WRITE w/o never-brick->REFUSED(-3); with proof->runs. T5 disk .nxe round-trips+runs.
expect_exit: 0 Sovereign: nx_cc->nxasm via nx_syscalls + canonical nx_sha256. NEVER-BRICK: RAM + a file, 0 firmware.
dependencies 2 imports · 0 importers
imports: nx_nxe_lib.nxnx_itoa_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 17 | const K_MAGIC_4096: i64 = 4096 |
functions
| 19 | func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 24 | func g_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 25 | func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c } |
| 26 | func wlog(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } called by 1: main |
| 29 | func emit_payload(dst: *u8) -> i64 called by 1: main |
| 37 | func main() -> i64 |