code wiki / (root) / nx_nxa_secdump_gate.nx

nx_nxa_secdump_gate.nx

buildroot/runtime/nx_nxa_secdump_gate.nx

13643 B294 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind gate/prooftopic nxa
docsdependenciesstructsconstsfunctions

about

nx_nxa_secdump_gate.nx -- THE GATE FOR THE NXA SECTION INSPECTOR. SUBJECT: the nx_nxa_secdump ELF, forked for real against NXA containers this gate BUILDS AT RUNTIME under /tmp/nx_nxa_secdump_gate/. Nothing here reads a production asset, so the gate cannot report on a fixture it shares with a beat (the gate-fixture law), and it cannot be silently re-baselined by someone re-baking ref9d. WHY EACH TOOTH EXISTS. The organ's whole value is that its NEGATIVE answers are trustworthy: a reader that says MATCH on a corrupt section, or OK on a container it could not parse, is worse than no reader at all -- it would launder a broken asset as verified. So every refusal path is bitten with a fixture built to trigger exactly that path, and the good fixture is carried alongside as the positive control, because A GUARD THAT REFUSES EVERYTHING PASSES EVERY NEGATIVE TEST. The fixtures are constructed with nxa_check2 -- the format's ONE checksum definition, the same one the subject uses -- so the gate cannot drift from the organ by re-implementing the rule it is testing. That is deliberate and it is a REAL limitation, stated rather than hidden: this gate proves the reader agrees with the format library, not that the format library is right. The checksum itself is nx_nxa's to prove. nx_nxa_secdump_gate [subject_elf] license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_tool_run.nx nx_nxa.nx nx_nxa_secdump_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_tool_run.nxnx_nxa.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ gv_puts ↻ sys_mkdir ng_build sys_mmap ↻ ng_wrw nxa_check2 ng_wrtag nxa_magic sys_openat_wr sys_write ↻ sys_close ng_exists sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close ↻

structs

none

consts

31const NG_SUBJECT_DEFAULT: *u8 = "/volume1/homes/elderwesto/nishihost/buildroot/_build/nx_nxa_secdump.sov.elf"
34const NG_OK: i64 = 0
35const NG_E_USAGE: i64 = 2
36const NG_E_BAD: i64 = 3
37const NG_E_NOTAG: i64 = 4
38const NG_E_CKSUM: i64 = 5
39const NG_E_EXEC: i64 = 127
41const NG_DIR: *u8 = "/tmp/nx_nxa_secdump_gate"
42const NG_GOOD: *u8 = "/tmp/nx_nxa_secdump_gate/good.nxa"
43const NG_CORRUPT: *u8 = "/tmp/nx_nxa_secdump_gate/corrupt.nxa"
44const NG_BADMAG: *u8 = "/tmp/nx_nxa_secdump_gate/badmagic.nxa"
46const NG_MODEDIR: i64 = 493
47const NG_CAPCAP: i64 = 262144
48const NG_ARGV_BYTES: i64 = 64
49const NG_SCRATCH: i64 = 16
52const NG_HDR: i64 = 32
53const NG_DIRENT: i64 = 32
54const NG_WORD: i64 = 8
55const NG_NSEC: i64 = 2
56const NG_A_WORDS: i64 = 3
57const NG_B_WORDS: i64 = 2
58const NG_OFF_A: i64 = 96 // NG_HDR + NG_NSEC*NG_DIRENT
59const NG_OFF_B: i64 = 120 // NG_OFF_A + NG_A_WORDS*NG_WORD
60const NG_FLEN: i64 = 136 // NG_OFF_B + NG_B_WORDS*NG_WORD
61const NG_A_W0: i64 = 11
62const NG_A_W1: i64 = 22
63const NG_A_W2: i64 = 33
64const NG_B_W0: i64 = 44
65const NG_B_W1: i64 = 55
66const NG_A_W0_MUT: i64 = 12 // one word changed -> the section checksum must stop matching
67const NG_MAGIC_MUT: i64 = 88 // 'X' -- breaks NXANIM01 at byte 0
68const NG_CHECK_SEED: i64 = 1
69const NG_DIR_WORDS: i64 = 8 // NG_NSEC * 4
70const NG_BYTE: i64 = 256
71const NG_BYTE_MASK: i64 = 255
72const NG_TOP_BYTE: i64 = 7
73const NG_VER: i64 = 1
75const NG_TAG_A: *u8 = "AAAA"
76const NG_TAG_B: *u8 = "BBBB"
77const NG_TAG_Z: *u8 = "ZZZZ"
78const NG_WORDS2: *u8 = "2"
79const NG_NONNUM: *u8 = "xx"

functions

81func ng_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: ng_has
82func ng_wr64(b: *u8, off: i64, v: i64) -> i64
89func ng_wrw(b: *u8, off: i64, v: i64) -> i64
called by 1: ng_build
94func ng_wrtag(b: *u8, off: i64, t: *u8) -> i64
called by 1: ng_build
101func ng_exists(path: *u8, want: i64) -> i64
called by 1: main calls 2: sys_mmapsys_read_file
110func ng_has(buf: *u8, n: i64, pat: *u8) -> i64
called by 1: main calls 1: ng_slen
127func ng_build(path: *u8, mutate_payload: i64, mutate_magic: i64) -> i64
165func ng_run(subject: *u8, a1: *u8, a2: *u8, a3: *u8, cap: *u8, olen: *i64) -> i64
called by 1: main calls 2: sys_mmaptr_run_capture
175func main(argc: i64, argv: *i64) -> i64