code wiki / _hdl_build / _nxasm_bisect.nx
_nxasm_bisect.nx source
↩ module page · 76 lines · 2868 B
1// _nxasm_bisect.nx -- R1-T1-004 dimension bisect: nxasm from a SOVEREIGN
2// parent across the env x output-path x input-path matrix on the md5-pinned
3// good .s. The lane combination (PATH env + lane paths) reproduces rc=6;
4// the old probe combination (empty env + alt paths) gave rc=0 -- this matrix
5// isolates WHICH dimension flips it. Rows: BISECT case=<n> env=<e> out=<o>
6// in=<i> rc=<rc>. license_tier: ORIGINAL
7import "nx_syscalls.nx"
8
9func bs_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
10func bs_n(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
11
12// spawn nxasm: envmode 0=empty 1=PATH-row; returns rc/128+sig
13func bs_spawn(a1: *u8, a2: *u8, envmode: i64) -> i64 {
14 let pid: i64 = sys_fork()
15 if pid == 0 {
16 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4)
17 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
18 let argv: *i64 = sys_mmap(40) as *i64
19 argv[0] = "_offc/nxasm_x86_main.elf" as *u8 as i64
20 argv[1] = a1 as i64
21 argv[2] = a2 as i64
22 argv[3] = 0
23 let envp: *i64 = sys_mmap(32) as *i64
24 if envmode == 1 {
25 envp[0] = "PATH=/usr/bin:/bin" as *u8 as i64
26 envp[1] = 0
27 } else {
28 envp[0] = 0
29 }
30 sys_execve("_offc/nxasm_x86_main.elf" as *u8, argv, envp)
31 sys_exit(127)
32 }
33 let st: *i64 = sys_mmap(16) as *i64
34 sys_wait4(pid, st, 0)
35 let sig: i64 = st[0] & 0x7f
36 if sig != 0 { return 128 + sig }
37 return (st[0] >> 8) & 0xff
38}
39
40func bs_case(idx: i64, a1: *u8, a2: *u8, envmode: i64) -> i64 {
41 let rc: i64 = bs_spawn(a1, a2, envmode)
42 bs_w("BISECT case=" as *u8)
43 bs_n(idx)
44 bs_w(" env=" as *u8)
45 bs_n(envmode)
46 bs_w(" in=" as *u8)
47 bs_w(a1)
48 bs_w(" out=" as *u8)
49 bs_w(a2)
50 bs_w(" rc=" as *u8)
51 bs_n(rc)
52 bs_w("\n" as *u8)
53 return rc
54}
55
56func main() -> i64 {
57 let lane_in: *u8 = "/tmp/nx_autorun_daemon.s" as *u8
58 let lane_out: *u8 = "/tmp/nx_autorun_daemon.sov.elf" as *u8
59 let alt_in: *u8 = "/tmp/_adm.s" as *u8
60 let alt_out: *u8 = "/tmp/_bs_alt.elf" as *u8
61
62 // 1 = full lane replica (expect 6 if replica is faithful)
63 bs_case(1, lane_in, lane_out, 1)
64 // 2 = drop env only
65 bs_case(2, lane_in, lane_out, 0)
66 // 3 = alt output only
67 bs_case(3, lane_in, alt_out, 1)
68 // 4 = alt input only
69 bs_case(4, alt_in, lane_out, 1)
70 // 5 = old probe combination (expect 0)
71 bs_case(5, alt_in, alt_out, 0)
72 // 6 = repeat case 1 (stability of the repro within one parent)
73 bs_case(6, lane_in, lane_out, 1)
74 sys_exit(0)
75 return 0
76}