Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/bridge/shlib/gate.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / bridge / shlib / gate.om` 2365 lines ยท 54820 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note bridge/shlib/gate.om: OMEGA-SHLIB, the gate of bridge/shlib (shared libraries written by Omega alone), in 3 note seeded Omega (Linux AArch64). Build from the repository root (OM-2 program mode; seed/ng/sha256.om supplies 4 note sh_dat, sh_all, sh_dig, sh_hexd): 5 note { printf 'om2\n'; cat seed/ng/sha256.om bridge/shlib/gate.om; } | seed/out/omc > shlib-gate 6 note seed/out/omc < bridge/shlib/shlib.om > shlib 7 note Run from the repository root: shlib-gate OMC SHLIB SCRATCH 8 note OMC the compiler; its sha256 must equal the first word of seed/out/omc.sha256, or nothing runs (exit 69) 9 note SHLIB the generator built from bridge/shlib/shlib.om 10 note SCRATCH a new directory (created 0700); an existing one is refused (exit 2), and so is a path too long to hold 11 note its files within Linux's 4096-byte PATH_MAX 12 note Checks, each an exact exit status: OMC compiles, in object mode (0), bridge/shlib/test.om, dep.om and imp.om, 13 note the test transport (rmfake.om then nvrmfake.om), libnvidia-ml.so.1's unit (gpu/nvidia/native/nvml's 14 note nvml.om, query.om, step.om and errstr.om, then bridge/shlib/nvml.om; errstr.om in its OM-2 view: the 15 note whole-word token "at", a reserved word of OM-2 and a parameter name there, becomes "at_" outside note lines) 16 note and libomega-ampere-qmd.so.1's unit (gpu/nvidia/om/encoder/amp_runtime.om and amp_qmd.om, then 17 note bridge/shlib/ampqmd.om); SHLIB writes each library (test, nvrmfake, nvml, dep, imp, ampqmd) and its probe 18 note (0); each probe, run by the system's 19 note dynamic loader from the scratch directory (so nvml finds the transport and imp finds dep through $ORIGIN), 20 note makes every call row of its table and gets the expected results with x19..x27, x29, d8..d15 and sp 21 note preserved (0); 22 note /usr/bin/readelf -W -S -d --dyn-syms reads each library through its section headers without a warning, 23 note shows the table's soname, every needed library of its table and lists every export of its table (0; readelf 24 note is a read-only verification 25 note oracle); the test library's wrappers hold four stack probes covering 3, 5, 1 and 2 pages, each fully formed 26 note with the wrapper's BL after it (0); each wrapper holds the 10 STP words that save x19..x30 and d8..d15, and 27 note the matching LDPs appear outside the wrappers (0); a second build of the test library from the same object holds the 28 note same bytes. 29 note Controls, each must be caught with its exact status (and, where named, its text in stderr): 30 note row a malformed call row (EXPECT 7x) appended to test.tsv: SHLIB refuses it (1, "malformed number") 31 note float the export row of omega_shlib_fl (an f64 export in test.om, not in test.tsv) appended to test.tsv: 32 note SHLIB refuses it (1, "a float parameter or result") 33 note export omega_shlib_div's export row and its call rows removed from the library's table, the probe 34 note (built from the full table) still needs it: the loader refuses the probe 35 note (127, "undefined symbol: omega_shlib_div") 36 note hash every .hash bucket of the test library zeroed: no symbol resolves (127, "undefined symbol: ") 37 note expect the first call's EXPECT changed from 7 to 8: the probe reports call 0 (1) 38 note stack the shared return's ADD SP, SP, #192 turned into ADD SP, SP, #208, so every call returns with 39 note sp 16 bytes high: the probe's stack check reports it (250) 40 note extend the wrappers' SXTW X0, W0 and SXTW X1, W1 turned into NOP: omc's int add finds the sum of -3 (zero 41 note upper half) and 10 outside int and traps, so call 1 answers 999 for 7 (2) 42 note uextend every UXTW (UBFX X, X, #0, #32) turned into NOP: call 9 (a uint with a dirty upper half) fails (10) 43 note nextend every UXTB, UXTH, SXTB and SXTH turned into NOP: call 12 (a uchar with dirty upper bits) fails (13) 44 note restore the shared return's LDP X19, X20, [SP, #32] turned into [SP, #48]: x19 and x20 come back wrong (250) 45 note runtime one trap-entry load LDR X16, [X7, #16] in test.obj turned into [X7, #0], a runtime entry the 46 note library does not provide: SHLIB refuses the object (1, "runtime entry") 47 note need the private function deep's frame in test.obj made 32 bytes smaller: the export's settled need 48 note drops from 16400 to 16368 bytes, so its probe covers 4 pages, not 5: the stack probe check reports 49 note it (1); the generator must accept the object 50 note address omega_shlib_seven's address in test.obj moved by 2 bytes: SHLIB refuses the object 51 note (1, "a function address is outside the code") 52 note frestore the shared return's LDP D8, D9, [SP, #128] turned into [SP, #144]: d8 and d9 come back wrong (250) 53 note callrec the last call record (edge's) dropped from test.obj: SHLIB refuses it (1, "a BL word has no call 54 note record") 55 note callto the last call record's destination made omega_shlib_seven: SHLIB refuses it (1, "a call record's 56 note destination is not its BL's target") 57 note nosave the first wrapper's STP X19, X20, [SP, #32] turned into NOP: the save check reports it (1) 58 note readwarn .dynsym's section header sh_entsize made 25: readelf warns and still exits 0 (300) 59 note readname omega_shlib_seven renamed omega_shlib_seveN in .dynstr: an export readelf does not list (301) 60 note readsoname the soname's first byte in .dynstr made 'L': readelf shows another soname (302) 61 note differ a copy of the test library with its last byte changed: the same-bytes check finds a difference (1) 62 note x7use omega_shlib_seven's first word in test.obj made STR Q0, [X7]: SHLIB refuses the object 63 note (1, "through the per-call context (x7)") 64 note slot the first entry slot's B in test.obj one word further: SHLIB refuses the object (1, "an export's 65 note entry slot does not branch to its function") 66 note map imp.tsv's import row for omega_dep_sub without its swap (s0 s1): the dependency computes 3 - 5, so 67 note call 7 fails (8) 68 note noneed imp.tsv without its needed row for libomshdep.so.1, the file still beside it: nothing loads it 69 note (127, "undefined symbol: omega_dep_") 70 note unlock the import library's shared return without its UNLOCK call (its BLR X16 made NOP): the lock stays 71 note held, pthread_mutex_trylock refuses call 1, which answers its TRAP value 999 (2) 72 note improw an import row for omega_nope appended to imp.tsv: SHLIB refuses it (1, "an import row names no 73 note import") 74 note frame omega_imp_count's state ImpS dropped from its frame row (1, "a frame export's parameters do not 75 note match its row") 76 note lockexp omega_imp_live exported without frame in the locked imp.tsv (1, "an export of a locked library is 77 note not a frame export") 78 note transport libnvidia-ml.so.1 and its probe in a directory without libomega-nvrm.so.1 (127, 79 note "libomega-nvrm.so.1") 80 note nvinit the composed NVML source with nvmlInit_v2's body made nvmlShutdown's: nvmlInit_v2 (row 3) 81 note answers NVML_ERROR_UNINITIALIZED for 0 (4) 82 note readneed the import library's needed name in .dynstr made Libomshdep.so.1: readelf shows another needed 83 note library (303) 84 note stackarg the Ampere QMD library's frame word for the caller's stack arguments pointed at the frame instead 85 note (ADD X16, SP, #288 made #96): the accepted build's QMD differs at buf+64 (30) 86 note nvcopy the composed NVML source copying text answers from the step state instead of the step buffer: 87 note the name's first word differs (10) 88 note The extend, uextend, nextend and nosave controls change only the wrappers' words, found through .dynsym. 89 note Output: one line per check and control, then OMEGA-SHLIB PASS|FAIL checks=N controls=C caught=K. 90 note Exit 0 PASS, 1 FAIL, 2 bad usage or setup, 69 compiler digest refused. 91 global g_pin uchar 64 92 global g_hx uchar 64 93 global g_stb uchar 4 94 global g_n ulong 32 95 global g_pa uchar 4096 96 global g_scr uchar 4096 97 global g_omc uchar 4096 98 global g_gen uchar 4096 99 global g_av uchar 16384 100 global g_o uchar 8192 101 global g_b uchar * 102 global g_c uchar * 103 note g_n: 0 path length, 1 omc length, 2 scratch length (with '/'), 3 argv bytes, 4 argc, 5 output length, 104 note 6 buffer length, 7 generator length, 8 checks, 11 failures, 12 controls, 13 caught, 14 and 15 the 105 note wrappers' range, 16 probe loops found, 17 a probe loop with the wrong page count, 18 wrappers (.dynsym 106 note symbols), 19 the composed source's length in g_c 107 text t_pin "seed/out/omc.sha256" 108 text t_null "/dev/null" 109 text t_ttab "bridge/shlib/test.tsv" 110 text t_tunit "bridge/shlib/test.om" 111 text t_ntab "bridge/shlib/nvml.tsv" 112 text t_nunit "bridge/shlib/nvml.om" 113 text t_obj "object\n" 114 text t_tsrc "test.src" 115 text t_tobj "test.obj" 116 text t_nsrc "nvml.src" 117 text t_nobj "nvml.obj" 118 text t_tlib "libomshlib.so.1" 119 text t_nlib "libnvidia-ml.so.1" 120 text t_tprb "probe" 121 text t_nprb "nvprobe" 122 text t_again "again.so" 123 text t_c1 "c1.tsv" 124 text t_c1so "c1.so" 125 text t_c2 "c2.tsv" 126 text t_d2 "c2" 127 text t_c2lib "c2/libomshlib.so.1" 128 text t_c2prb "c2/probe" 129 text t_d3 "c3" 130 text t_c3lib "c3/libomshlib.so.1" 131 text t_c3prb "c3/probe" 132 text t_c4 "c4.tsv" 133 text t_c4prb "probe4" 134 text t_d5 "c5" 135 text t_c5lib "c5/libomshlib.so.1" 136 text t_c5prb "c5/probe" 137 text t_d6 "c6" 138 text t_c6lib "c6/libomshlib.so.1" 139 text t_c6prb "c6/probe" 140 text t_d8 "c8" 141 text t_c8lib "c8/libomshlib.so.1" 142 text t_c8prb "c8/probe" 143 text t_d9 "c9" 144 text t_c9lib "c9/libomshlib.so.1" 145 text t_c9prb "c9/probe" 146 text t_c7obj "c7.obj" 147 text t_c7so "c7.so" 148 text t_relf "/usr/bin/readelf" 149 text t_aw "-W" 150 text t_as "-S" 151 text t_ad "--dyn-syms" 152 text t_add "-d" 153 text t_exp "export\t" 154 text t_son "soname\t" 155 text t_lsn "Library soname: [" 156 text t_mnum "malformed number" 157 text t_udiv "undefined symbol: omega_shlib_div" 158 text t_usym "undefined symbol: " 159 text t_mrt "runtime entry" 160 text t_mobj "not an OMOBJ001" 161 text t_maddr "a function address is outside the code" 162 text t_mbl "a BL word has no call record" 163 text t_mcdst "a call record's destination is not its BL's target" 164 text t_mrtw "through the per-call context (x7)" 165 text t_mslot "an export's entry slot does not branch to its function" 166 text t_tn7 "omega_shlib_seven" 167 text t_c14obj "c14.obj" 168 text t_c14so "c14.so" 169 text t_c15obj "c15.obj" 170 text t_c15so "c15.so" 171 text t_d16 "c16" 172 text t_c16lib "c16/libomshlib.so.1" 173 text t_c17so "c17.so" 174 text t_c18so "c18.so" 175 text t_c19so "c19.so" 176 text t_c20so "c20.so" 177 text t_c21obj "c21.obj" 178 text t_c21so "c21.so" 179 text t_c22obj "c22.obj" 180 text t_c22so "c22.so" 181 text t_c23 "c23.tsv" 182 text t_c23so "c23.so" 183 text t_flrow "export\tomega_shlib_fl\t0\n" 184 text t_mflt "a float parameter or result" 185 text t_fgl "FUNC GLOBAL DEFAULT" 186 text t_c10obj "c10.obj" 187 text t_c10so "c10.so" 188 text t_c11obj "c11.obj" 189 text t_c11so "c11.so" 190 text t_d12 "c12" 191 text t_c12lib "c12/libomshlib.so.1" 192 text t_c12prb "c12/probe" 193 text t_d13 "c13" 194 text t_c13lib "c13/libomshlib.so.1" 195 text t_c13prb "c13/probe" 196 text t_lout "log.out" 197 text t_lerr "log.err" 198 text t_lib "lib" 199 text t_call "call" 200 text t_bad "call\tomega_shlib_seven\t7x\n" 201 text t_div "export\tomega_shlib_div\t999\n" 202 text t_divc "call\tomega_shlib_div\t" 203 text t_seven "call\tomega_shlib_seven\t7\n" 204 text t_k1 "compile test.om" 205 text t_k2 "compile nvml.om" 206 text t_k3 "lib test" 207 text t_k4 "probe test" 208 text t_k5 "run test probe" 209 text t_k6 "lib nvml" 210 text t_k7 "probe nvml" 211 text t_k8 "run nvml probe" 212 text t_k9 "lib test again" 213 text t_k10 "same bytes" 214 text t_k11 "readelf test" 215 text t_k12 "readelf nvml" 216 text t_k13 "stack probe words" 217 text t_k14 "save words" 218 text t_x1 "row" 219 text t_x2 "export" 220 text t_x3 "hash" 221 text t_x4 "expect" 222 text t_x5 "stack" 223 text t_x6 "extend" 224 text t_x7 "runtime" 225 text t_x8 "uextend" 226 text t_x9 "restore" 227 text t_x10 "need" 228 text t_x11 "address" 229 text t_x12 "frestore" 230 text t_x13 "nextend" 231 text t_x14 "callrec" 232 text t_x15 "callto" 233 text t_x16 "nosave" 234 text t_x17 "readwarn" 235 text t_x18 "readname" 236 text t_x19 "readsoname" 237 text t_x20 "differ" 238 text t_x21 "x7use" 239 text t_x22 "slot" 240 text t_x23 "float" 241 text t_x24 "map" 242 text t_x25 "noneed" 243 text t_x26 "unlock" 244 text t_x27 "improw" 245 text t_x28 "frame" 246 text t_x29 "lockexp" 247 text t_x30 "transport" 248 text t_x31 "nvinit" 249 text t_x32 "readneed" 250 text t_c32so "c32.so" 251 text t_x33 "stackarg" 252 text t_d33 "c33" 253 text t_c33lib "c33/libomega-ampere-qmd.so.1" 254 text t_c33prb "c33/aqprobe" 255 text t_x34 "nvcopy" 256 text t_mcr "z = memcpy p add get fr 9 OO n\n" 257 text t_c34src "c34.src" 258 text t_c34obj "c34.obj" 259 text t_d34 "c34" 260 text t_c34lib "c34/libnvidia-ml.so.1" 261 text t_c34tr "c34/libomega-nvrm.so.1" 262 text t_c34prb "c34/nvprobe" 263 text t_om2 "om2\n" 264 text t_note "note" 265 text t_atu "at_" 266 text t_nv1 "gpu/nvidia/native/nvml/nvml.om" 267 text t_nv2 "gpu/nvidia/native/nvml/query.om" 268 text t_nv3 "gpu/nvidia/native/nvml/step.om" 269 text t_nv4 "gpu/nvidia/native/nvml/errstr.om" 270 text t_fk1 "bridge/shlib/rmfake.om" 271 text t_fk2 "bridge/shlib/nvrmfake.om" 272 text t_ftab "bridge/shlib/nvrmfake.tsv" 273 text t_fsrc "fake.src" 274 text t_fobj "fake.obj" 275 text t_flib "libomega-nvrm.so.1" 276 text t_fprb "fprobe" 277 text t_dunit "bridge/shlib/dep.om" 278 text t_dtab "bridge/shlib/dep.tsv" 279 text t_dsrc "dep.src" 280 text t_dobj "dep.obj" 281 text t_dlib "libomshdep.so.1" 282 text t_dprb "dprobe" 283 text t_iunit "bridge/shlib/imp.om" 284 text t_itab "bridge/shlib/imp.tsv" 285 text t_isrc "imp.src" 286 text t_iobj "imp.obj" 287 text t_ilib "libomshimp.so.1" 288 text t_iprb "iprobe" 289 text t_need "needed\t" 290 text t_lsl "Shared library: [" 291 text t_k15 "compile nvrmfake" 292 text t_k16 "compile dep.om" 293 text t_k17 "compile imp.om" 294 text t_k18 "lib nvrmfake" 295 text t_k19 "probe nvrmfake" 296 text t_k20 "run nvrmfake probe" 297 text t_k21 "lib dep" 298 text t_k22 "probe dep" 299 text t_k23 "run dep probe" 300 text t_k24 "lib imp" 301 text t_k25 "probe imp" 302 text t_k26 "run imp probe" 303 text t_k27 "readelf nvrmfake" 304 text t_k28 "readelf dep" 305 text t_k29 "readelf imp" 306 text t_k30 "compile ampqmd" 307 text t_k31 "lib ampqmd" 308 text t_k32 "probe ampqmd" 309 text t_k33 "run ampqmd probe" 310 text t_k34 "readelf ampqmd" 311 text t_aq1 "gpu/nvidia/om/encoder/amp_runtime.om" 312 text t_aq2 "gpu/nvidia/om/encoder/amp_qmd.om" 313 text t_aunit "bridge/shlib/ampqmd.om" 314 text t_atab "bridge/shlib/ampqmd.tsv" 315 text t_asrc "ampqmd.src" 316 text t_aobj "ampqmd.obj" 317 text t_alib "libomega-ampere-qmd.so.1" 318 text t_aprb "aqprobe" 319 text t_mapr "import\tomega_dep_sub\ts1\ts0\n" 320 text t_mapw "import\tomega_dep_sub\ts0\ts1\n" 321 text t_needr "needed\tlibomshdep.so.1\n" 322 text t_nope "import\tomega_nope\ts0\n" 323 text t_cntr "export\tomega_imp_count\t999\tframe\tImpS\n" 324 text t_cntw "export\tomega_imp_count\t999\tframe\n" 325 text t_liver "export\tomega_imp_live\t999\tframe\n" 326 text t_livew "export\tomega_imp_live\t999\n" 327 text t_initr "ret ap_bare s b r fr 1\n" 328 text t_mimp "an import row names no import" 329 text t_mfrm "a frame export's parameters do not match its row" 330 text t_mlck "an export of a locked library is not a frame export" 331 text t_udep "undefined symbol: omega_dep_" 332 text t_c24 "c24.tsv" 333 text t_d24 "c24" 334 text t_c24lib "c24/libomshimp.so.1" 335 text t_c24dep "c24/libomshdep.so.1" 336 text t_c24prb "c24/iprobe" 337 text t_c25 "c25.tsv" 338 text t_d25 "c25" 339 text t_c25lib "c25/libomshimp.so.1" 340 text t_c25dep "c25/libomshdep.so.1" 341 text t_c25prb "c25/iprobe" 342 text t_d26 "c26" 343 text t_c26lib "c26/libomshimp.so.1" 344 text t_c26dep "c26/libomshdep.so.1" 345 text t_c26prb "c26/iprobe" 346 text t_c27 "c27.tsv" 347 text t_c27so "c27.so" 348 text t_c28 "c28.tsv" 349 text t_c28so "c28.so" 350 text t_c29 "c29.tsv" 351 text t_c29so "c29.so" 352 text t_d30 "c30" 353 text t_c30lib "c30/libnvidia-ml.so.1" 354 text t_c30prb "c30/nvprobe" 355 text t_c31src "c31.src" 356 text t_c31obj "c31.obj" 357 text t_d31 "c31" 358 text t_c31lib "c31/libnvidia-ml.so.1" 359 text t_c31tr "c31/libomega-nvrm.so.1" 360 text t_c31prb "c31/nvprobe" 361 text t_ok "ok " 362 text t_fail "FAIL " 363 text t_ctl "control " 364 text t_exit " exit=" 365 text t_want " expected=" 366 text t_caught " caught" 367 text t_esc " ESCAPED" 368 text t_setup " setup failed" 369 text t_sum "OMEGA-SHLIB " 370 text t_pass "PASS" 371 text t_fl "FAIL" 372 text t_sk " checks=" 373 text t_sc " controls=" 374 text t_scc " caught=" 375 text t_usage "usage: shlib-gate OMC SHLIB SCRATCH (run from the omega-mv repository root)\n" 376 text t_refd "OMEGA-SHLIB REFUSED: compiler digest differs from seed/out/omc.sha256 (exit 69)\n" 377 text t_nopin "OMEGA-SHLIB INVALID: cannot read a 64-hex digest from seed/out/omc.sha256\n" 378 text t_noscr "OMEGA-SHLIB INVALID: SCRATCH exists or cannot be made\n" 379 text t_long "OMEGA-SHLIB INVALID: SCRATCH path too long for its files within PATH_MAX (4096 bytes)\n" 380 note ---- output 381 fn oc c ulong to void 382 n = get g_n 5 383 if ge n len g_o 384 r = write 1 g_o 0 n 385 n = 0 386 end 387 put g_o n uchar c 388 put g_n 5 add n 1 389 end 390 fn ot t view uchar * to void 391 for i ulong len t bound 4096 392 oc ulong get t i 393 end 394 end 395 fn onum v ulong to void 396 if ge v 10 397 onum div v 10 398 end 399 oc add 48 rem v 10 400 end 401 fn oflush to void 402 r = write 1 g_o 0 get g_n 5 403 put g_n 5 0 404 end 405 note ---- paths: g_pa[0, g_n 0) 406 fn pclr to void 407 put g_n 0 0 408 end 409 fn pc c ulong to void 410 n = get g_n 0 411 put g_pa n uchar c 412 put g_n 0 add n 1 413 end 414 fn pt t view uchar * to void 415 for i ulong len t bound 4096 416 pc ulong get t i 417 end 418 end 419 note a file in SCRATCH 420 fn psc t view uchar * to void 421 pclr 422 for j ulong get g_n 2 bound 4096 423 pc ulong get g_scr j 424 end 425 pt t 426 end 427 note a path relative to the repository root 428 fn prp t view uchar * to void 429 pclr 430 pt t 431 end 432 note ---- files 433 fn fopn fl ulong mode ulong to int 434 r = fopen g_pa 0 get g_n 0 int fl int mode 435 if lt r 0 436 ret -1 437 end 438 ret int r 439 end 440 fn frd to int 441 ret fopn 524288 0 442 end 443 fn fwr to int 444 ret fopn 524865 420 445 end 446 fn fexe to int 447 r = unlink g_pa 0 get g_n 0 448 ret fopn 524865 448 449 end 450 fn fclo fd int to void 451 if ge fd 0 452 r = fclose fd 453 end 454 end 455 note g_b holds at least n bytes; false when the host refuses the growth 456 fn bgrow n ulong to bool 457 if le n len g_b 458 ret true 459 end 460 m = mul len g_b 2 461 if lt m n 462 m = n 463 end 464 r = enlarge g_b m 465 ret ge r 0 466 end 467 note append the file at g_pa to g_b; false when unreadable or the buffer cannot grow 468 fn bload to bool 469 fd = frd 470 if lt fd 0 471 ret false 472 end 473 n = get g_n 6 474 ok = true 475 while true bound `9223372036854775807` 476 if not bgrow add n 65536 477 ok = false 478 break 479 end 480 x = read fd g_b n sub len g_b n 481 if lt x 0 482 ok = false 483 break 484 end 485 if eq x 0 486 break 487 end 488 n = add n ulong x 489 end 490 fclo fd 491 put g_n 6 n 492 ret ok 493 end 494 note write g_b[0, g_n 6) to the file at g_pa (0644, or 0700 when exe) 495 fn bsave exe bool to bool 496 fd = int -1 497 if exe 498 fd = fexe 499 else 500 fd = fwr 501 end 502 if lt fd 0 503 ret false 504 end 505 n = get g_n 6 506 o = ulong 0 507 ok = true 508 while lt o n bound `9223372036854775807` 509 x = write fd g_b o sub n o 510 if le x 0 511 ok = false 512 break 513 end 514 o = add o ulong x 515 end 516 fclo fd 517 ret ok 518 end 519 note append text t to g_b 520 fn bapp t view uchar * to bool 521 n = get g_n 6 522 if not bgrow add n len t 523 ret false 524 end 525 for i ulong len t bound 4096 526 put g_b add n i get t i 527 end 528 put g_n 6 add n len t 529 ret true 530 end 531 note the first offset of text t in g_b[0, g_n 6), or 2^63 when absent 532 fn bfind t view uchar * to ulong 533 n = get g_n 6 534 if lt n len t 535 ret shl ulong 1 63 536 end 537 for o ulong add sub n len t 1 bound `9223372036854775807` 538 if bat o t 539 ret o 540 end 541 end 542 ret shl ulong 1 63 543 end 544 fn bat o ulong t view uchar * to bool 545 for i ulong len t bound 4096 546 if ne get g_b add o i get t i 547 ret false 548 end 549 end 550 ret true 551 end 552 note remove g_b[o, o + k) 553 fn bcut o ulong k ulong to void 554 n = get g_n 6 555 for i ulong sub sub n o k bound `9223372036854775807` 556 put g_b add o i get g_b add add o k i 557 end 558 put g_n 6 sub n k 559 end 560 note the offset just past the newline at or after o in g_b (the buffer's end when there is none) 561 fn bnl o ulong to ulong 562 n = get g_n 6 563 for i ulong sub n o bound `9223372036854775807` 564 if eq get g_b add o i 10 565 ret add add o i 1 566 end 567 end 568 ret n 569 end 570 note load the file named by the scratch text t into g_b alone; false when unreadable 571 fn sload t view uchar * to bool 572 put g_n 6 0 573 psc t 574 ret bload 575 end 576 fn rload t view uchar * to bool 577 put g_n 6 0 578 prp t 579 ret bload 580 end 581 note ---- the compiler digest 582 fn pinread to bool 583 if not rload t_pin 584 ret false 585 end 586 if lt get g_n 6 64 587 ret false 588 end 589 for j ulong 64 590 c = get g_b j 591 ok = or and ge c 48 le c 57 and ge c 97 le c 102 592 if not ok 593 ret false 594 end 595 put g_pin j c 596 end 597 ret true 598 end 599 note the sha256 of the file at g_pa, streamed through sh_dat in whole 64-byte blocks (no size limit), equals g_pin 600 fn pinok to bool 601 fd = frd 602 if lt fd 0 603 ret false 604 end 605 sh_init 606 for j ulong 8 607 put sh_h j get sh_k add j 64 608 end 609 t = ulong 0 610 r = ulong 0 611 ok = true 612 while true bound `9223372036854775807` 613 x = read fd sh_dat r sub len sh_dat r 614 if lt x 0 615 ok = false 616 break 617 end 618 if eq x 0 619 break 620 end 621 t = add t ulong x 622 r = gblks add r ulong x 623 end 624 fclo fd 625 if not ok 626 ret false 627 end 628 gfin t r 629 for j ulong 32 630 b = get sh_dig j 631 if ne get g_pin mul j 2 sh_hexd uint shr b 4 632 ret false 633 end 634 if ne get g_pin add mul j 2 1 sh_hexd uint and b 15 635 ret false 636 end 637 end 638 ret true 639 end 640 note hash the whole blocks of sh_dat[0, m), move the rest to the front; its length 641 fn gblks m ulong to ulong 642 nb = div m 64 643 for b ulong nb bound 262144 644 sh_blk 0 mul b 64 645 end 646 r = rem m 64 647 o = mul nb 64 648 for j ulong r bound 64 649 put sh_dat j get sh_dat add o j 650 end 651 ret r 652 end 653 note the padding of FIPS 180-4 for a message of n bytes whose last r bytes are sh_dat[0, r); digest into sh_dig 654 fn gfin n ulong r ulong to void 655 for j ulong 128 656 put sh_pad j 0 657 end 658 for j ulong r bound 64 659 put sh_pad j get sh_dat j 660 end 661 put sh_pad r 128 662 e = ulong 64 663 if ge r 56 664 e = 128 665 end 666 bits = mul n 8 667 for j ulong 8 668 put sh_pad sub sub e 1 j uchar and shr bits mul j 8 255 669 end 670 sh_blk 1 0 671 if eq e 128 672 sh_blk 1 64 673 end 674 sh_out 675 end 676 note ---- processes 677 fn aclr to void 678 put g_n 3 2 679 put g_n 4 0 680 put g_av 0 0 681 put g_av 1 0 682 end 683 note append g_pa as one argument 684 fn apa to void 685 p = get g_n 3 686 n = get g_n 0 687 for j ulong n bound 4096 688 put g_av add add p 2 j get g_pa j 689 end 690 put g_av p uchar and n 255 691 put g_av add p 1 uchar shr n 8 692 put g_n 3 add p add n 2 693 c = add get g_n 4 1 694 put g_n 4 c 695 put g_av 0 uchar and c 255 696 put g_av 1 uchar shr c 8 697 end 698 fn atx t view uchar * to void 699 prp t 700 apa 701 end 702 fn asc t view uchar * to void 703 psc t 704 apa 705 end 706 fn agen to void 707 pclr 708 for j ulong get g_n 7 bound 4096 709 pc ulong get g_gen j 710 end 711 apa 712 end 713 fn redir s int d int to void 714 if ne dupfd s d 0 long d 715 exit 127 716 end 717 end 718 note run the argument list with stdin fi and stdout, stderr in SCRATCH/log.out, log.err: the exit code, 719 note 256 + the signal, 512 when a file could not be opened, 1000 when the child passed the 600 s deadline 720 fn spawn fi int to ulong 721 psc t_lout 722 fo = fwr 723 psc t_lerr 724 fe = fwr 725 if or lt fi 0 or lt fo 0 lt fe 0 726 fclo fi 727 fclo fo 728 fclo fe 729 ret 512 730 end 731 pid = fork 732 if lt pid 0 733 exit 2 734 end 735 if eq pid 0 736 redir fi 0 737 redir fo 1 738 redir fe 2 739 r = execprog g_av 0 get g_n 3 740 exit 127 741 end 742 fclo fi 743 fclo fo 744 fclo fe 745 ret reap pid 746 end 747 note wait for the child pid: its exit code, 256 + the signal, or 1000 after the 600 s deadline (killed) 748 fn reap pid long to ulong 749 t0 = monons 750 while true bound `1000000000` 751 r = waitpid int pid g_stb 0 len g_stb 1 752 if eq r pid 753 x = ulong get g_stb 0 754 if ne x 0 755 ret add 256 x 756 end 757 ret ulong get g_stb 1 758 end 759 if lt r 0 760 exit 2 761 end 762 if gt sub monons t0 `600000000000` 763 r = killpid int pid 9 764 r = waitpid int pid g_stb 0 len g_stb 0 765 ret 1000 766 end 767 q = sleepns 200000 768 end 769 exit 2 770 end 771 fn run to ulong 772 prp t_null 773 ret spawn frd 774 end 775 note OMC < SCRATCH/src > SCRATCH/obj, src being "object" then the unit u 776 fn mkobj u view uchar * src view uchar * obj view uchar * to ulong 777 put g_n 6 0 778 if not bapp t_obj 779 ret 512 780 end 781 prp u 782 if not bload 783 ret 512 784 end 785 psc src 786 if not bsave false 787 ret 512 788 end 789 ret omcsrc src obj 790 end 791 note OMC < SCRATCH/src > SCRATCH/obj 792 fn omcsrc src view uchar * obj view uchar * to ulong 793 psc src 794 fi = frd 795 aclr 796 pclr 797 for j ulong get g_n 1 bound 4096 798 pc ulong get g_omc j 799 end 800 apa 801 ret spawnto fi obj 802 end 803 note ---- composed units: g_c[0, g_n 19) is "object", "om2", then each unit in order 804 fn cstart to bool 805 put g_n 19 0 806 ok = cput t_obj 807 ret and ok cput t_om2 808 end 809 fn cbyte c ulong to bool 810 n = get g_n 19 811 if ge n len g_c 812 m = mul len g_c 2 813 if lt m 65536 814 m = 65536 815 end 816 r = enlarge g_c m 817 if lt r 0 818 ret false 819 end 820 end 821 put g_c n uchar c 822 put g_n 19 add n 1 823 ret true 824 end 825 fn cput t view uchar * to bool 826 for i ulong len t bound 4096 827 if not cbyte ulong get t i 828 ret false 829 end 830 end 831 ret true 832 end 833 note append the repository file u; with ren, its om2 view: in each line that is not a note, the whole-word token 834 note "at" (a parameter name in errstr.om, a reserved word of OM-2) becomes "at_" 835 fn cfile u view uchar * ren bool to bool 836 put g_n 6 0 837 prp u 838 if not bload 839 ret false 840 end 841 n = get g_n 6 842 i = ulong 0 843 isn = false 844 bol = true 845 while lt i n bound `9223372036854775807` 846 if bol 847 isn = and le add i len t_note n bat i t_note 848 bol = false 849 end 850 c = ulong get g_b i 851 if and not isn attok i n 852 if not cput t_atu 853 ret false 854 end 855 i = add i 2 856 else 857 if not cbyte c 858 ret false 859 end 860 bol = eq c 10 861 i = add i 1 862 end 863 end 864 ret true 865 end 866 note g_b[i, i + 2) is "at" with a space, a newline or the buffer's edge on each side 867 fn attok i ulong n ulong to bool 868 if or ge add i 1 n or ne get g_b i 97 ne get g_b add i 1 116 869 ret false 870 end 871 if gt i 0 872 p = get g_b sub i 1 873 if and ne p 32 ne p 10 874 ret false 875 end 876 end 877 if lt add i 2 n 878 q = get g_b add i 2 879 if and ne q 32 ne q 10 880 ret false 881 end 882 end 883 ret true 884 end 885 note g_c saved as the scratch file src, then OMC < src > obj 886 fn cdone src view uchar * obj view uchar * to ulong 887 n = get g_n 19 888 if not bgrow n 889 ret 512 890 end 891 for i ulong n bound `9223372036854775807` 892 put g_b i get g_c i 893 end 894 put g_n 6 n 895 psc src 896 if not bsave false 897 ret 512 898 end 899 ret omcsrc src obj 900 end 901 note libnvidia-ml.so.1's object: native/nvml's nvml.om, query.om, step.om, errstr.om (its om2 view) and 902 note bridge/shlib/nvml.om 903 fn mknvml to ulong 904 ok = cstart 905 ok = and ok cfile t_nv1 false 906 ok = and ok cfile t_nv2 false 907 ok = and ok cfile t_nv3 false 908 ok = and ok cfile t_nv4 true 909 ok = and ok cfile t_nunit false 910 if not ok 911 ret 512 912 end 913 ret cdone t_nsrc t_nobj 914 end 915 note the test transport's object: rmfake.om and nvrmfake.om 916 fn mkfake to ulong 917 ok = cstart 918 ok = and ok cfile t_fk1 false 919 ok = and ok cfile t_fk2 false 920 if not ok 921 ret 512 922 end 923 ret cdone t_fsrc t_fobj 924 end 925 note the Ampere QMD library's object: amp_runtime.om, amp_qmd.om and bridge/shlib/ampqmd.om 926 fn mkampq to ulong 927 ok = cstart 928 ok = and ok cfile t_aq1 false 929 ok = and ok cfile t_aq2 false 930 ok = and ok cfile t_aunit false 931 if not ok 932 ret 512 933 end 934 ret cdone t_asrc t_aobj 935 end 936 note as spawn, but stdout into the scratch file obj 937 fn spawnto fi int obj view uchar * to ulong 938 psc obj 939 fo = fwr 940 psc t_lerr 941 fe = fwr 942 if or lt fi 0 or lt fo 0 lt fe 0 943 fclo fi 944 fclo fo 945 fclo fe 946 ret 512 947 end 948 pid = fork 949 if lt pid 0 950 exit 2 951 end 952 if eq pid 0 953 redir fi 0 954 redir fo 1 955 redir fe 2 956 r = execprog g_av 0 get g_n 3 957 exit 127 958 end 959 fclo fi 960 fclo fo 961 fclo fe 962 ret reap pid 963 end 964 note SHLIB lib TABLE OBJ OUT; tr is TABLE relative to the repository root, else to SCRATCH; OBJ is test.obj 965 note when ob is 0, nvml.obj when 1, the controls' c7.obj (runtime), c10.obj (need) or c11.obj (address) for 2..4 966 fn genlib tab view uchar * tr bool ob ulong dst view uchar * to ulong 967 aclr 968 agen 969 atx t_lib 970 if tr 971 atx tab 972 else 973 asc tab 974 end 975 obsel ob 976 asc dst 977 ret run 978 end 979 note the object genlib names: test.obj for 0, nvml.obj for 1, the controls' c7, c10, c11, c14, c15 for 2..6 980 fn obsel ob ulong to void 981 if eq ob 1 982 asc t_nobj 983 ret 984 end 985 if eq ob 2 986 asc t_c7obj 987 ret 988 end 989 if eq ob 3 990 asc t_c10obj 991 ret 992 end 993 if eq ob 4 994 asc t_c11obj 995 ret 996 end 997 if eq ob 5 998 asc t_c14obj 999 ret 1000 end 1001 if eq ob 6 1002 asc t_c15obj 1003 ret 1004 end 1005 if eq ob 7 1006 asc t_c21obj 1007 ret 1008 end 1009 if eq ob 8 1010 asc t_c22obj 1011 ret 1012 end 1013 if eq ob 9 1014 asc t_fobj 1015 ret 1016 end 1017 if eq ob 10 1018 asc t_dobj 1019 ret 1020 end 1021 if eq ob 11 1022 asc t_iobj 1023 ret 1024 end 1025 if eq ob 12 1026 asc t_c31obj 1027 ret 1028 end 1029 if eq ob 13 1030 asc t_aobj 1031 ret 1032 end 1033 if eq ob 14 1034 asc t_c34obj 1035 ret 1036 end 1037 asc t_tobj 1038 end 1039 fn gencall tab view uchar * tr bool dst view uchar * to ulong 1040 aclr 1041 agen 1042 atx t_call 1043 if tr 1044 atx tab 1045 else 1046 asc tab 1047 end 1048 asc dst 1049 ret run 1050 end 1051 fn runprb prb view uchar * to ulong 1052 aclr 1053 asc prb 1054 ret run 1055 end 1056 note ---- results 1057 fn check what view uchar * got ulong want ulong to void 1058 put g_n 8 add get g_n 8 1 1059 if eq got want 1060 ot t_ok 1061 else 1062 put g_n 11 add get g_n 11 1 1063 ot t_fail 1064 end 1065 ot what 1066 ot t_exit 1067 onum got 1068 if ne got want 1069 ot t_want 1070 onum want 1071 end 1072 oc 10 1073 end 1074 fn ctl what view uchar * got ulong want ulong to void 1075 ctlx what got want eq got want 1076 end 1077 note a control caught when its status is want and the scratch log.err holds t 1078 fn ctle what view uchar * got ulong want ulong t view uchar * to void 1079 ok = and eq got want errhas t 1080 ctlx what got want ok 1081 end 1082 fn errhas t view uchar * to bool 1083 if not sload t_lerr 1084 ret false 1085 end 1086 ret lt bfind t shl ulong 1 63 1087 end 1088 fn ctlx what view uchar * got ulong want ulong ok bool to void 1089 put g_n 12 add get g_n 12 1 1090 ot t_ctl 1091 ot what 1092 if ok 1093 put g_n 13 add get g_n 13 1 1094 ot t_caught 1095 else 1096 ot t_esc 1097 end 1098 ot t_exit 1099 onum got 1100 if ne got want 1101 ot t_want 1102 onum want 1103 end 1104 oc 10 1105 end 1106 note a control whose setup failed: counted, never caught 1107 fn csetup what view uchar * to void 1108 put g_n 12 add get g_n 12 1 1109 ot t_ctl 1110 ot what 1111 ot t_setup 1112 oc 10 1113 end 1114 fn mkd t view uchar * to bool 1115 psc t 1116 ret eq makedir g_pa 0 get g_n 0 448 0 1117 end 1118 note copy the scratch file a to the scratch file b (0700) 1119 fn cpexe a view uchar * b view uchar * to bool 1120 if not sload a 1121 ret false 1122 end 1123 psc b 1124 ret bsave true 1125 end 1126 note ---- the checks 1127 fn checks to void 1128 check t_k1 mkobj t_tunit t_tsrc t_tobj 0 1129 check t_k2 mknvml 0 1130 check t_k15 mkfake 0 1131 check t_k16 mkobj t_dunit t_dsrc t_dobj 0 1132 check t_k17 mkobj t_iunit t_isrc t_iobj 0 1133 check t_k30 mkampq 0 1134 check t_k3 genlib t_ttab true 0 t_tlib 0 1135 check t_k4 gencall t_ttab true t_tprb 0 1136 check t_k5 runprb t_tprb 0 1137 check t_k18 genlib t_ftab true 9 t_flib 0 1138 check t_k19 gencall t_ftab true t_fprb 0 1139 check t_k20 runprb t_fprb 0 1140 check t_k6 genlib t_ntab true 1 t_nlib 0 1141 check t_k7 gencall t_ntab true t_nprb 0 1142 check t_k8 runprb t_nprb 0 1143 check t_k21 genlib t_dtab true 10 t_dlib 0 1144 check t_k22 gencall t_dtab true t_dprb 0 1145 check t_k23 runprb t_dprb 0 1146 check t_k24 genlib t_itab true 11 t_ilib 0 1147 check t_k25 gencall t_itab true t_iprb 0 1148 check t_k26 runprb t_iprb 0 1149 check t_k31 genlib t_atab true 13 t_alib 0 1150 check t_k32 gencall t_atab true t_aprb 0 1151 check t_k33 runprb t_aprb 0 1152 check t_k11 relf t_ttab t_tlib 0 1153 check t_k12 relf t_ntab t_nlib 0 1154 check t_k27 relf t_ftab t_flib 0 1155 check t_k28 relf t_dtab t_dlib 0 1156 check t_k29 relf t_itab t_ilib 0 1157 check t_k34 relf t_atab t_alib 0 1158 check t_k13 pchk t_tlib 0 1159 check t_k14 schk t_tlib 0 1160 check t_k9 genlib t_ttab true 0 t_again 0 1161 s = ulong 1 1162 if same2 t_tlib t_again 1163 s = 0 1164 end 1165 check t_k10 s 0 1166 end 1167 note readelf -W -S -d --dyn-syms on the scratch library lib: 0 when it exits 0 with nothing on stderr, lists 1168 note every export of the table tab (at least one), shows its soname and every needed library; else its status, 1169 note 300 (stderr not empty), 301 (an export not listed), 302 (soname) or 303 (a needed library) 1170 fn relf tab view uchar * lib view uchar * to ulong 1171 aclr 1172 prp t_relf 1173 apa 1174 prp t_aw 1175 apa 1176 prp t_as 1177 apa 1178 prp t_ad 1179 apa 1180 prp t_add 1181 apa 1182 asc lib 1183 r = run 1184 if ne r 0 1185 ret r 1186 end 1187 if not sload t_lerr 1188 ret 300 1189 end 1190 if ne get g_n 6 0 1191 ret 300 1192 end 1193 if not sload t_lout 1194 ret 301 1195 end 1196 m = get g_n 6 1197 prp tab 1198 if not bload 1199 ret 301 1200 end 1201 if not allexp m 1202 ret 301 1203 end 1204 if not sonok m 1205 ret 302 1206 end 1207 if not needok m 1208 ret 303 1209 end 1210 ret 0 1211 end 1212 note the table in g_b[m, g_n 6) has a "soname\tNAME" line and g_b[0, m) has "Library soname: [NAME]" 1213 fn sonok m ulong to bool 1214 o = m 1215 while lt o get g_n 6 bound `9223372036854775807` 1216 e = bnl o 1217 if bat o t_son 1218 s = add o len t_son 1219 l = ulong 0 1220 while gt get g_b add s l 32 bound `9223372036854775807` 1221 l = add l 1 1222 end 1223 ret sfind s l m t_lsn 1224 end 1225 o = e 1226 end 1227 ret false 1228 end 1229 fn sfind s ulong l ulong m ulong p view uchar * to bool 1230 for i ulong m bound `9223372036854775807` 1231 if bat i p 1232 a = add i len p 1233 if and bsame a s l eq get g_b add a l 93 1234 ret true 1235 end 1236 end 1237 end 1238 ret false 1239 end 1240 note every "needed\tNAME" line of the table in g_b[m, g_n 6) has "Shared library: [NAME]" in g_b[0, m) 1241 fn needok m ulong to bool 1242 o = m 1243 while lt o get g_n 6 bound `9223372036854775807` 1244 e = bnl o 1245 if and le add o len t_need get g_n 6 bat o t_need 1246 s = add o len t_need 1247 l = ulong 0 1248 while gt get g_b add s l 32 bound `9223372036854775807` 1249 l = add l 1 1250 end 1251 if not sfind s l m t_lsl 1252 ret false 1253 end 1254 end 1255 o = e 1256 end 1257 ret true 1258 end 1259 note every "export\tNAME\t" line of the table in g_b[m, g_n 6) has NAME then a newline in g_b[0, m), and there 1260 note is at least one such line 1261 fn allexp m ulong to bool 1262 o = m 1263 n = ulong 0 1264 while lt o get g_n 6 bound `9223372036854775807` 1265 e = bnl o 1266 if expat o 1267 s = add o len t_exp 1268 l = ulong 0 1269 while ne get g_b add s l 9 bound `9223372036854775807` 1270 l = add l 1 1271 end 1272 if not bline s l m 1273 ret false 1274 end 1275 n = add n 1 1276 end 1277 o = e 1278 end 1279 ret gt n 0 1280 end 1281 fn expat o ulong to bool 1282 if gt add o len t_exp get g_n 6 1283 ret false 1284 end 1285 ret bat o t_exp 1286 end 1287 note g_b[s, s + l) occurs in g_b[0, m) as a whole readelf symbol line's name: a space before it, a newline after 1288 note it, and "FUNC GLOBAL DEFAULT" earlier on its line 1289 fn bline s ulong l ulong m ulong to bool 1290 if lt m add l 2 1291 ret false 1292 end 1293 for i ulong sub sub m l 1 bound `9223372036854775807` 1294 o = add i 1 1295 if and bsame o s l eq get g_b add o l 10 1296 if and eq get g_b i 32 fglob o 1297 ret true 1298 end 1299 end 1300 end 1301 ret false 1302 end 1303 note the line holding g_b[o] has "FUNC GLOBAL DEFAULT" before o 1304 fn fglob o ulong to bool 1305 a = o 1306 while and gt a 0 ne get g_b sub a 1 10 bound `9223372036854775807` 1307 a = sub a 1 1308 end 1309 if lt sub o a len t_fgl 1310 ret false 1311 end 1312 for i ulong add sub sub o a len t_fgl 1 bound `9223372036854775807` 1313 if bat add a i t_fgl 1314 ret true 1315 end 1316 end 1317 ret false 1318 end 1319 fn bsame a ulong s ulong l ulong to bool 1320 for i ulong l bound `9223372036854775807` 1321 if ne get g_b add a i get g_b add s i 1322 ret false 1323 end 1324 end 1325 ret true 1326 end 1327 note the scratch files a and b hold the same bytes 1328 fn same2 a view uchar * b view uchar * to bool 1329 if not sload a 1330 ret false 1331 end 1332 n = get g_n 6 1333 psc b 1334 if not bload 1335 ret false 1336 end 1337 if ne sub get g_n 6 n n 1338 ret false 1339 end 1340 for i ulong n bound `9223372036854775807` 1341 if ne get g_b i get g_b add n i 1342 ret false 1343 end 1344 end 1345 ret true 1346 end 1347 note ---- the controls 1348 fn crow to void 1349 if not rload t_ttab 1350 csetup t_x1 1351 ret 1352 end 1353 if not bapp t_bad 1354 csetup t_x1 1355 ret 1356 end 1357 psc t_c1 1358 if not bsave false 1359 csetup t_x1 1360 ret 1361 end 1362 r = genlib t_c1 false 0 t_c1so 1363 ctle t_x1 r 1 t_mnum 1364 end 1365 note the table with the float export omega_shlib_fl (in test.om, not in test.tsv) appended: SHLIB refuses it 1366 fn cfloat to void 1367 if not rload t_ttab 1368 csetup t_x23 1369 ret 1370 end 1371 if not bapp t_flrow 1372 csetup t_x23 1373 ret 1374 end 1375 psc t_c23 1376 if not bsave false 1377 csetup t_x23 1378 ret 1379 end 1380 r = genlib t_c23 false 0 t_c23so 1381 ctle t_x23 r 1 t_mflt 1382 end 1383 fn cexport to void 1384 if not rload t_ttab 1385 csetup t_x2 1386 ret 1387 end 1388 o = bfind t_div 1389 if ge o shl ulong 1 63 1390 csetup t_x2 1391 ret 1392 end 1393 bcut o len t_div 1394 o = bfind t_divc 1395 while lt o shl ulong 1 63 bound 4096 1396 bcut o sub bnl o o 1397 o = bfind t_divc 1398 end 1399 psc t_c2 1400 ok = bsave false 1401 ok = and ok mkd t_d2 1402 ok = and ok eq genlib t_c2 false 0 t_c2lib 0 1403 ok = and ok eq gencall t_ttab true t_c2prb 0 1404 if not ok 1405 csetup t_x2 1406 ret 1407 end 1408 r = runprb t_c2prb 1409 ctle t_x2 r 127 t_udiv 1410 end 1411 fn chash to void 1412 ok = mkd t_d3 1413 ok = and ok sload t_tlib 1414 if not ok 1415 csetup t_x3 1416 ret 1417 end 1418 note SysV .hash at 288: nbucket (u32), nchain (u32), then the buckets 1419 nb = or ulong get g_b 288 shl ulong get g_b 289 8 1420 for i ulong mul nb 4 bound 65536 1421 put g_b add 296 i 0 1422 end 1423 psc t_c3lib 1424 ok = bsave false 1425 ok = and ok cpexe t_tprb t_c3prb 1426 if not ok 1427 csetup t_x3 1428 ret 1429 end 1430 r = runprb t_c3prb 1431 ctle t_x3 r 127 t_usym 1432 end 1433 fn cexpect to void 1434 if not rload t_ttab 1435 csetup t_x4 1436 ret 1437 end 1438 o = bfind t_seven 1439 if ge o shl ulong 1 63 1440 csetup t_x4 1441 ret 1442 end 1443 put g_b sub add o len t_seven 2 56 1444 psc t_c4 1445 ok = bsave false 1446 ok = and ok eq gencall t_c4 false t_c4prb 0 1447 if not ok 1448 csetup t_x4 1449 ret 1450 end 1451 ctl t_x4 runprb t_c4prb 1 1452 end 1453 fn cstack to void 1454 ok = mkd t_d5 1455 ok = and ok sload t_tlib 1456 if not ok 1457 csetup t_x5 1458 ret 1459 end 1460 note the first ADD SP, SP, #192 (0x910303ff, bytes ff 03 03 91) is the shared return's; byte 1 0x43 makes 1461 note the immediate 208 1462 o = bfind4 255 3 3 145 1463 if ge o shl ulong 1 63 1464 csetup t_x5 1465 ret 1466 end 1467 put g_b add o 1 67 1468 psc t_c5lib 1469 ok = bsave false 1470 ok = and ok cpexe t_tprb t_c5prb 1471 if not ok 1472 csetup t_x5 1473 ret 1474 end 1475 ctl t_x5 runprb t_c5prb 250 1476 end 1477 note make the scratch directory dir and load the test library into g_b 1478 fn tload dir view uchar * to bool 1479 ok = mkd dir 1480 ret and ok sload t_tlib 1481 end 1482 note the wrappers' range of the library in g_b, from its .dynsym (the lowest symbol value, the highest value plus 1483 note size) into g_n 14 and 15; false when there is no .dynsym 1484 fn wrange to bool 1485 so = bq 40 1486 put g_n 14 shl ulong 1 63 1487 put g_n 15 0 1488 put g_n 18 0 1489 for i ulong bh 60 bound 65536 1490 h = add so mul i 64 1491 if eq bh add h 4 11 1492 symr bq add h 24 bq add h 32 1493 end 1494 end 1495 ret and gt get g_n 15 0 le get g_n 15 get g_n 6 1496 end 1497 fn symr o ulong n ulong to void 1498 for k ulong div n 24 bound `9223372036854775807` 1499 e = add o mul k 24 1500 v = bq add e 8 1501 if ne v 0 1502 put g_n 18 add get g_n 18 1 1503 if lt v get g_n 14 1504 put g_n 14 v 1505 end 1506 if gt add v bq add e 16 get g_n 15 1507 put g_n 15 add v bq add e 16 1508 end 1509 end 1510 end 1511 end 1512 note the u64 and the u16 of g_b at o; 0 when they reach past the loaded bytes (g_n 6), so a damaged or missing 1513 note library makes a check fail instead of reading stale bytes or past the buffer 1514 fn bq o ulong to ulong 1515 if or gt o get g_n 6 gt add o 8 get g_n 6 1516 ret 0 1517 end 1518 v = ulong 0 1519 for i ulong 8 1520 v = or v shl ulong get g_b add o i mul i 8 1521 end 1522 ret v 1523 end 1524 fn bh o ulong to ulong 1525 if or gt o get g_n 6 gt add o 2 get g_n 6 1526 ret 0 1527 end 1528 ret or ulong get g_b o shl ulong get g_b add o 1 8 1529 end 1530 note turn every 4-aligned word w inside the wrappers into NOP (0xd503201f); how many 1531 fn nopw w ulong to ulong 1532 k = ulong 0 1533 if not wrange 1534 ret 0 1535 end 1536 for i ulong div sub get g_n 15 get g_n 14 4 bound `9223372036854775807` 1537 o = add get g_n 14 mul i 4 1538 if eq bw o w 1539 put g_b o 31 1540 put g_b add o 1 32 1541 put g_b add o 2 3 1542 put g_b add o 3 213 1543 k = add k 1 1544 end 1545 end 1546 ret k 1547 end 1548 note save g_b as the scratch library lib, copy the probe to prb and run it: its status, or 512 on a setup failure 1549 fn tsave lib view uchar * prb view uchar * to ulong 1550 psc lib 1551 ok = bsave false 1552 ok = and ok cpexe t_tprb prb 1553 if not ok 1554 ret 512 1555 end 1556 ret runprb prb 1557 end 1558 fn cext to void 1559 note SXTW X0, W0 is 0x93407c00 (bytes 00 7c 40 93) and SXTW X1, W1 0x93407c21: add's and div's arguments 1560 ok = tload t_d6 1561 k = nopw `2470476800` 1562 k = add k nopw `2470476833` 1563 if or not ok eq k 0 1564 csetup t_x6 1565 ret 1566 end 1567 ctl t_x6 tsave t_c6lib t_c6prb 2 1568 end 1569 fn cuext to void 1570 note UXTW X0, W0 (UBFX X0, X0, #0, #32) is 0xd3407c00 (bytes 00 7c 40 d3): hi's argument 1571 ok = tload t_d8 1572 k = nopw `3544218624` 1573 if or not ok eq k 0 1574 csetup t_x8 1575 ret 1576 end 1577 ctl t_x8 tsave t_c8lib t_c8prb 10 1578 end 1579 fn cnext to void 1580 note UXTB X0 0xd3401c00, UXTH X0 0xd3403c00, SXTB X0 0x93401c00, SXTH X0 0x93403c00: the narrow calls' arguments 1581 ok = tload t_d13 1582 k = nopw `3544194048` 1583 k = add k nopw `3544202240` 1584 k = add k nopw `2470452224` 1585 k = add k nopw `2470460416` 1586 if or not ok ne k 4 1587 csetup t_x13 1588 ret 1589 end 1590 ctl t_x13 tsave t_c13lib t_c13prb 13 1591 end 1592 fn cnosave to void 1593 note STP X19, X20, [SP, #32] is 0xa90253f3 (bytes f3 53 02 a9); its first occurrence (the first wrapper's) turned 1594 note into NOP: the save check reports it 1595 ok = tload t_d16 1596 o = bfind4 243 83 2 169 1597 if or not ok ge o shl ulong 1 63 1598 csetup t_x16 1599 ret 1600 end 1601 put g_b o 31 1602 put g_b add o 1 32 1603 put g_b add o 2 3 1604 put g_b add o 3 213 1605 psc t_c16lib 1606 if not bsave false 1607 csetup t_x16 1608 ret 1609 end 1610 ctl t_x16 schk t_c16lib 1 1611 end 1612 fn crestore to void 1613 ok = mkd t_d9 1614 ok = and ok sload t_tlib 1615 if not ok 1616 csetup t_x9 1617 ret 1618 end 1619 note LDP X19, X20, [SP, #32] is 0xa94253f3 (bytes f3 53 42 a9), first in the shared return; byte 2 0x43 1620 note makes the offset 48 1621 o = bfind4 243 83 66 169 1622 if ge o shl ulong 1 63 1623 csetup t_x9 1624 ret 1625 end 1626 put g_b add o 2 67 1627 psc t_c9lib 1628 ok = bsave false 1629 ok = and ok cpexe t_tprb t_c9prb 1630 if not ok 1631 csetup t_x9 1632 ret 1633 end 1634 ctl t_x9 runprb t_c9prb 250 1635 end 1636 fn cruntime to void 1637 if not sload t_tobj 1638 csetup t_x7 1639 ret 1640 end 1641 note LDR X16, [X7, #16] is 0xf94008f0 (bytes f0 08 40 f9); byte 1 0 makes it [X7, #0] 1642 o = bfind4 240 8 64 249 1643 if ge o shl ulong 1 63 1644 csetup t_x7 1645 ret 1646 end 1647 put g_b add o 1 0 1648 psc t_c7obj 1649 if not bsave false 1650 csetup t_x7 1651 ret 1652 end 1653 r = genlib t_ttab true 2 t_c7so 1654 ctle t_x7 r 1 t_mrt 1655 end 1656 note the stack probe check on the scratch library lib: 0 when its wrappers hold exactly four probes, each 1657 note ADD X16, SP, #16; MOVZ X17, #pages; MOVK X17, #0, LSL #16; MOVK X17, #0, LSL #32; the loop, with the 1658 note wrapper's BL after it, covering 3, 5, 1 and 2 pages in that order (sum, deep, pdiv, edge: edge's 2 holds 1659 note only with the call cost counted); 1 otherwise, 512 unreadable 1660 fn pchk lib view uchar * to ulong 1661 if not sload lib 1662 ret 512 1663 end 1664 if not wrange 1665 ret 512 1666 end 1667 put g_n 16 0 1668 put g_n 17 0 1669 for i ulong div sub get g_n 15 get g_n 14 4 bound `9223372036854775807` 1670 pone add get g_n 14 mul i 4 1671 end 1672 if and eq get g_n 17 0 eq get g_n 16 4 1673 ret 0 1674 end 1675 ret 1 1676 end 1677 note one word of the wrappers: a probe loop at o counts in g_n 16; a wrong probe around it sets g_n 17 1678 fn pone o ulong to void 1679 if not ploop o 1680 ret 1681 end 1682 k = add get g_n 16 1 1683 put g_n 16 k 1684 if not pfix o k 1685 put g_n 17 1 1686 end 1687 end 1688 note the four words before the loop at o and a BL after it, for the k-th probe 1689 fn pfix o ulong k ulong to bool 1690 ok = and eq bw sub o 16 `2432713712` eq bw sub o 12 pwant k 1691 ok = and ok and eq bw sub o 8 `4070572049` eq bw sub o 4 `4072669201` 1692 ret and ok blafter add o 16 1693 end 1694 note a BL comes at or after o before the next wrapper (its SUB SP, SP, #192) or the wrappers' end 1695 fn blafter o ulong to bool 1696 for i ulong div sub get g_n 15 o 4 bound `9223372036854775807` 1697 w = bw add o mul i 4 1698 if eq shr w 26 37 1699 ret true 1700 end 1701 if eq w `3506635775` 1702 ret false 1703 end 1704 end 1705 ret false 1706 end 1707 note the MOVZ X17 the k-th probe must hold: #3, #5, #1, then #2 1708 fn pwant k ulong to ulong 1709 if eq k 1 1710 ret `3531604081` 1711 end 1712 if eq k 2 1713 ret `3531604145` 1714 end 1715 if eq k 3 1716 ret `3531604017` 1717 end 1718 ret `3531604049` 1719 end 1720 note g_b at o holds the probe loop SUB X16, X16, #1, LSL #12; LDR XZR, [X16]; SUBS X17, X17, #1; B.NE loop 1721 fn ploop o ulong to bool 1722 if gt add o 16 get g_n 6 1723 ret false 1724 end 1725 ok = and eq bw o `3510634000` eq bw add o 4 `4181721631` 1726 ret and ok and eq bw add o 8 `4043310641` eq bw add o 12 `1426063265` 1727 end 1728 note the u32 of g_b at o 1729 fn bw o ulong to ulong 1730 ret or bh o shl bh add o 2 16 1731 end 1732 note the save check on the scratch library lib: each of the 10 STP words that save x19..x30 and d8..d15 at 1733 note [sp, #32..176] occurs once per wrapper inside the wrappers, and each matching LDP occurs outside them 1734 note (the shared return); 0, 1 otherwise, 512 when unreadable 1735 fn schk lib view uchar * to ulong 1736 if not sload lib 1737 ret 512 1738 end 1739 if not wrange 1740 ret 512 1741 end 1742 for i ulong 10 1743 s = svw i 1744 if ne wcnt s get g_n 14 get g_n 15 get g_n 18 1745 ret 1 1746 end 1747 l = add s `4194304` 1748 if eq sub wcnt l 0 get g_n 6 wcnt l get g_n 14 get g_n 15 0 1749 ret 1 1750 end 1751 end 1752 ret 0 1753 end 1754 note STP X(19+2i), X(20+2i), [SP, #32+16i] for i 0..5, then STP D(8+2j), D(9+2j), [SP, #128+16j] 1755 fn svw i ulong to ulong 1756 if lt i 6 1757 ret add `2835502067` mul i 67586 1758 end 1759 ret add `1829251048` mul sub i 6 67586 1760 end 1761 note how many 4-aligned words in g_b[a, b) equal w 1762 fn wcnt w ulong a ulong b ulong to ulong 1763 n = ulong 0 1764 for i ulong div sub b a 4 bound `9223372036854775807` 1765 if eq bw add a mul i 4 w 1766 n = add n 1 1767 end 1768 end 1769 ret n 1770 end 1771 note write the u64 v at g_b[a] 1772 fn bput8 a ulong v ulong to void 1773 for i ulong 8 1774 put g_b add a i uchar and shr v mul i 8 255 1775 end 1776 end 1777 fn cneed to void 1778 if not sload t_tobj 1779 csetup t_x10 1780 ret 1781 end 1782 o = privf 1783 if ge o shl ulong 1 63 1784 csetup t_x10 1785 ret 1786 end 1787 a = add o 32 1788 bput8 a sub bq a 32 1789 psc t_c10obj 1790 if not bsave false 1791 csetup t_x10 1792 ret 1793 end 1794 if ne genlib t_ttab true 3 t_c10so 0 1795 csetup t_x10 1796 ret 1797 end 1798 ctl t_x10 pchk t_c10so 1 1799 end 1800 note the object offset of test.obj's one private function record (flags 0), or 2^63; a record is flags, 1801 note address, result, parameter count, stack, name length (u64 each), the name padded to 8 bytes, then 40 bytes 1802 note per parameter 1803 fn privf to ulong 1804 o = bq 40 1805 for i ulong bq 48 bound 65536 1806 if eq bq o 0 1807 ret o 1808 end 1809 o = add add o 48 add and add bq add o 40 7 not ulong 7 mul bq add o 24 40 1810 end 1811 ret shl ulong 1 63 1812 end 1813 fn caddr to void 1814 note the first function record sits at the code end C (object offset 40); its address is 8 bytes in 1815 if not sload t_tobj 1816 csetup t_x11 1817 ret 1818 end 1819 a = add bq 40 8 1820 put g_b a uchar add get g_b a 2 1821 psc t_c11obj 1822 if not bsave false 1823 csetup t_x11 1824 ret 1825 end 1826 r = genlib t_ttab true 4 t_c11so 1827 ctle t_x11 r 1 t_maddr 1828 end 1829 fn ccrec to void 1830 note the last call record (edge's) dropped: header word 56 one less, the object 32 bytes shorter 1831 if not sload t_tobj 1832 csetup t_x14 1833 ret 1834 end 1835 bput8 56 sub bq 56 1 1836 put g_n 6 sub get g_n 6 32 1837 psc t_c14obj 1838 if not bsave false 1839 csetup t_x14 1840 ret 1841 end 1842 r = genlib t_ttab true 5 t_c14so 1843 ctle t_x14 r 1 t_mbl 1844 end 1845 fn ccto to void 1846 note the last call record's destination (16 bytes before the end) made function 0, omega_shlib_seven 1847 if not sload t_tobj 1848 csetup t_x15 1849 ret 1850 end 1851 bput8 sub get g_n 6 16 0 1852 psc t_c15obj 1853 if not bsave false 1854 csetup t_x15 1855 ret 1856 end 1857 r = genlib t_ttab true 6 t_c15so 1858 ctle t_x15 r 1 t_mcdst 1859 end 1860 note readelf's three refusals, each from one change to the test library: .dynsym's sh_entsize made 25 (readelf 1861 note warns on stderr and still exits 0: 300), omega_shlib_seven renamed omega_shlib_seveN in .dynstr (an export 1862 note not listed: 301), the soname's first byte made 'L' (302) 1863 fn crelf to void 1864 ok = sload t_tlib 1865 so = bq 40 1866 h = ulong 0 1867 for i ulong bh 60 bound 65536 1868 if eq bh add add so mul i 64 4 11 1869 h = add so mul i 64 1870 end 1871 end 1872 if or not ok eq h 0 1873 csetup t_x17 1874 else 1875 put g_b add h 56 25 1876 psc t_c17so 1877 if bsave false 1878 ctl t_x17 relf t_ttab t_c17so 300 1879 else 1880 csetup t_x17 1881 end 1882 end 1883 cname 1884 csoname 1885 end 1886 fn cname to void 1887 o = rfind t_tn7 1888 if ge o shl ulong 1 63 1889 csetup t_x18 1890 ret 1891 end 1892 put g_b add o 16 78 1893 ctl t_x18 rsave t_c18so 301 1894 end 1895 fn csoname to void 1896 o = rfind t_tlib 1897 if ge o shl ulong 1 63 1898 csetup t_x19 1899 ret 1900 end 1901 put g_b o 76 1902 ctl t_x19 rsave t_c19so 302 1903 end 1904 note the import library with its needed name libomshdep.so.1 in .dynstr made Libomshdep.so.1: readelf shows 1905 note another needed library (303) 1906 fn cneedname to void 1907 o = shl ulong 1 63 1908 if sload t_ilib 1909 o = bfindt t_dlib 1910 end 1911 if ge o shl ulong 1 63 1912 csetup t_x32 1913 ret 1914 end 1915 put g_b o 76 1916 psc t_c32so 1917 if not bsave false 1918 csetup t_x32 1919 ret 1920 end 1921 ctl t_x32 relf t_itab t_c32so 303 1922 end 1923 note the test library loaded into g_b, then the first offset holding text t (2^63 when unreadable or absent) 1924 fn rfind t view uchar * to ulong 1925 if not sload t_tlib 1926 ret shl ulong 1 63 1927 end 1928 ret bfindt t 1929 end 1930 note g_b saved as the scratch file so, then readelf's answer on it (513 when it cannot be saved) 1931 fn rsave so view uchar * to ulong 1932 psc so 1933 if not bsave false 1934 ret 513 1935 end 1936 ret relf t_ttab so 1937 end 1938 note the first offset of g_b holding text t, or 2^63 1939 fn bfindt t view uchar * to ulong 1940 if lt get g_n 6 len t 1941 ret shl ulong 1 63 1942 end 1943 for i ulong add sub get g_n 6 len t 1 bound `9223372036854775807` 1944 if bat i t 1945 ret i 1946 end 1947 end 1948 ret shl ulong 1 63 1949 end 1950 note the same-bytes check against a copy of the test library with its last byte changed: it must differ 1951 fn cdiffer to void 1952 if not sload t_tlib 1953 csetup t_x20 1954 ret 1955 end 1956 n = sub get g_n 6 1 1957 put g_b n uchar and add get g_b n 1 255 1958 psc t_c20so 1959 if not bsave false 1960 csetup t_x20 1961 ret 1962 end 1963 s = ulong 1 1964 if same2 t_tlib t_c20so 1965 s = 0 1966 end 1967 ctl t_x20 s 1 1968 end 1969 note test.obj with omega_shlib_seven's first word made STR Q0, [X7] (0x3d8000e0, bytes e0 00 80 3d): the 1970 note generator refuses a base-register use of x7 1971 fn cx7use to void 1972 if not sload t_tobj 1973 csetup t_x21 1974 ret 1975 end 1976 a = bq add bq 40 8 1977 put g_b a 224 1978 put g_b add a 1 0 1979 put g_b add a 2 128 1980 put g_b add a 3 61 1981 ctle t_x21 osave t_c21obj 7 t_c21so 1 t_mrtw 1982 end 1983 note test.obj with the first entry slot's B one word further: its slot no longer branches to its function 1984 fn cslot to void 1985 if not sload t_tobj 1986 csetup t_x22 1987 ret 1988 end 1989 put g_b 176 uchar add get g_b 176 1 1990 ctle t_x22 osave t_c22obj 8 t_c22so 1 t_mslot 1991 end 1992 note g_b saved as the scratch object obj, then the generator's status on it (object k of genlib) into so; 513 1993 note when it cannot be saved 1994 fn osave obj view uchar * k ulong so view uchar * to ulong 1995 psc obj 1996 if not bsave false 1997 ret 513 1998 end 1999 ret genlib t_ttab true k so 2000 end 2001 fn cfrest to void 2002 note LDP D8, D9, [SP, #128] is 0x6d4827e8 (bytes e8 27 48 6d), first in the shared return; byte 2 0x49 2003 note makes the offset 144 2004 ok = tload t_d12 2005 o = bfind4 232 39 72 109 2006 if or not ok ge o shl ulong 1 63 2007 csetup t_x12 2008 ret 2009 end 2010 put g_b add o 2 73 2011 ctl t_x12 tsave t_c12lib t_c12prb 250 2012 end 2013 note g_b[o] is v 2014 fn bis o ulong v ulong to bool 2015 ret eq ulong get g_b o v 2016 end 2017 note the first 4-aligned offset of the bytes a b c d in g_b, or 2^63 2018 fn bfind4 a ulong b ulong c ulong d ulong to ulong 2019 n = div get g_n 6 4 2020 for i ulong n bound `9223372036854775807` 2021 o = mul i 4 2022 ok = and bis o a bis add o 1 b 2023 ok = and ok and bis add o 2 c bis add o 3 d 2024 if ok 2025 ret o 2026 end 2027 end 2028 ret shl ulong 1 63 2029 end 2030 note ---- import, lock and NVML controls 2031 note insert text t at g_b[o] 2032 fn bins o ulong t view uchar * to bool 2033 n = get g_n 6 2034 if not bgrow add n len t 2035 ret false 2036 end 2037 k = len t 2038 for i ulong sub n o bound `9223372036854775807` 2039 s = sub sub n i 1 2040 put g_b add s k get g_b s 2041 end 2042 for i ulong len t bound 4096 2043 put g_b add o i get t i 2044 end 2045 put g_n 6 add n len t 2046 ret true 2047 end 2048 note imp.tsv with the line a cut, saved as the scratch file f; false when a is absent 2049 fn tcut a view uchar * f view uchar * to bool 2050 if not rload t_itab 2051 ret false 2052 end 2053 o = bfind a 2054 if ge o shl ulong 1 63 2055 ret false 2056 end 2057 bcut o len a 2058 psc f 2059 ret bsave false 2060 end 2061 note imp.tsv with the line a replaced by b, saved as the scratch file f; false when a is absent 2062 fn tmut a view uchar * b view uchar * f view uchar * to bool 2063 if not rload t_itab 2064 ret false 2065 end 2066 o = bfind a 2067 if ge o shl ulong 1 63 2068 ret false 2069 end 2070 bcut o len a 2071 if not bins o b 2072 ret false 2073 end 2074 psc f 2075 ret bsave false 2076 end 2077 note the directory d with the import library from the scratch table tab and copies of the dependency library 2078 note and the import probe: the c24 set for k 24, else the c25 set 2079 fn ilay k ulong to bool 2080 if eq k 24 2081 ok = mkd t_d24 2082 ok = and ok eq genlib t_c24 false 11 t_c24lib 0 2083 ok = and ok cpexe t_dlib t_c24dep 2084 ret and ok cpexe t_iprb t_c24prb 2085 end 2086 ok = mkd t_d25 2087 ok = and ok eq genlib t_c25 false 11 t_c25lib 0 2088 ok = and ok cpexe t_dlib t_c25dep 2089 ret and ok cpexe t_iprb t_c25prb 2090 end 2091 note the import row of omega_dep_sub without its swap: the dependency computes 3 - 5, call 7 fails (8) 2092 fn cmap to void 2093 ok = tmut t_mapr t_mapw t_c24 2094 ok = and ok ilay 24 2095 if not ok 2096 csetup t_x24 2097 ret 2098 end 2099 ctl t_x24 runprb t_c24prb 8 2100 end 2101 note imp.tsv without its needed row for libomshdep.so.1 (the file still beside it): nothing loads it, the 2102 note loader refuses the import library's symbols (127, "undefined symbol: omega_dep_") 2103 fn cnoneed to void 2104 ok = tcut t_needr t_c25 2105 ok = and ok ilay 25 2106 if not ok 2107 csetup t_x25 2108 ret 2109 end 2110 ctle t_x25 runprb t_c25prb 127 t_udep 2111 end 2112 note the import library's shared return without its UNLOCK call (the BLR X16 24 bytes after the first 2113 note CBZ X16, +32, bytes 10 01 00 b4, made NOP, bytes 1f 20 03 d5): the lock stays held after call 0, so 2114 note pthread_mutex_trylock refuses call 1, which answers its TRAP value 999 (2) 2115 fn cunlock to void 2116 ok = mkd t_d26 2117 ok = and ok sload t_ilib 2118 o = bfind4 16 1 0 180 2119 if or not ok ge o shl ulong 1 63 2120 csetup t_x26 2121 ret 2122 end 2123 b = add o 24 2124 put g_b b 31 2125 put g_b add b 1 32 2126 put g_b add b 2 3 2127 put g_b add b 3 213 2128 psc t_c26lib 2129 ok = bsave false 2130 ok = and ok cpexe t_dlib t_c26dep 2131 ok = and ok cpexe t_iprb t_c26prb 2132 if not ok 2133 csetup t_x26 2134 ret 2135 end 2136 ctl t_x26 runprb t_c26prb 2 2137 end 2138 note imp.tsv with an import row for a name the object does not import: SHLIB refuses it (1) 2139 fn cimprow to void 2140 if not rload t_itab 2141 csetup t_x27 2142 ret 2143 end 2144 ok = bapp t_nope 2145 psc t_c27 2146 ok = and ok bsave false 2147 if not ok 2148 csetup t_x27 2149 ret 2150 end 2151 ctle t_x27 genlib t_c27 false 11 t_c27so 1 t_mimp 2152 end 2153 note imp.tsv with omega_imp_count's state ImpS dropped from its frame row: its parameters no longer match (1) 2154 fn cframe to void 2155 if not tmut t_cntr t_cntw t_c28 2156 csetup t_x28 2157 ret 2158 end 2159 ctle t_x28 genlib t_c28 false 11 t_c28so 1 t_mfrm 2160 end 2161 note imp.tsv with omega_imp_live exported without frame: a locked library refuses it (1) 2162 fn clockexp to void 2163 if not tmut t_liver t_livew t_c29 2164 csetup t_x29 2165 ret 2166 end 2167 ctle t_x29 genlib t_c29 false 11 t_c29so 1 t_mlck 2168 end 2169 note libnvidia-ml.so.1 and its probe without the transport library: the loader refuses (127) 2170 fn ctransport to void 2171 ok = mkd t_d30 2172 ok = and ok cpexe t_nlib t_c30lib 2173 ok = and ok cpexe t_nprb t_c30prb 2174 if not ok 2175 csetup t_x30 2176 ret 2177 end 2178 ctle t_x30 runprb t_c30prb 127 t_flib 2179 end 2180 note the composed NVML source with nvmlInit_v2's body made nvmlShutdown's: nvmlInit_v2 (row 3) answers 2181 note NVML_ERROR_UNINITIALIZED, not 0 (4) 2182 fn cnvinit to void 2183 if not sload t_nsrc 2184 csetup t_x31 2185 ret 2186 end 2187 o = bfind t_initr 2188 if ge o shl ulong 1 63 2189 csetup t_x31 2190 ret 2191 end 2192 put g_b add o sub len t_initr 2 50 2193 psc t_c31src 2194 ok = bsave false 2195 ok = and ok eq omcsrc t_c31src t_c31obj 0 2196 ok = and ok mkd t_d31 2197 ok = and ok eq genlib t_ntab true 12 t_c31lib 0 2198 ok = and ok cpexe t_flib t_c31tr 2199 ok = and ok cpexe t_nprb t_c31prb 2200 if not ok 2201 csetup t_x31 2202 ret 2203 end 2204 ctl t_x31 runprb t_c31prb 4 2205 end 2206 note the Ampere QMD library with each frame wrapper's ADD X16, SP, #288 (its frame of 96 bytes + 192: the 2207 note caller's stack arguments, bytes f0 83 04 91) made ADD X16, SP, #96 (bytes f0 83 01 91): the accepted build 2208 note (call row 3) reads registers and shared_bytes from the wrapper's saved registers, still in range, so it is 2209 note accepted with other QMD words, and the bufeq of buf+64 (row 29) fails (30) 2210 fn cstkarg to void 2211 ok = mkd t_d33 2212 ok = and ok sload t_alib 2213 if not ok 2214 csetup t_x33 2215 ret 2216 end 2217 c = ulong 0 2218 n = div get g_n 6 4 2219 for i ulong n bound `9223372036854775807` 2220 o = mul i 4 2221 ok = and bis o 240 bis add o 1 131 2222 ok = and ok and bis add o 2 4 bis add o 3 145 2223 if ok 2224 put g_b add o 2 1 2225 c = add c 1 2226 end 2227 end 2228 psc t_c33lib 2229 ok = and eq c 2 bsave false 2230 ok = and ok cpexe t_aprb t_c33prb 2231 if not ok 2232 csetup t_x33 2233 ret 2234 end 2235 ctl t_x33 runprb t_c33prb 30 2236 end 2237 note the composed NVML source with the output copy of name, UUID and the other text answers reading from the 2238 note step state (frame word 8) instead of the step buffer (word 9): the name's first word differs (bufeq row 9, 10) 2239 fn cnvcopy to void 2240 if not sload t_nsrc 2241 csetup t_x34 2242 ret 2243 end 2244 o = bfind t_mcr 2245 if ge o shl ulong 1 63 2246 csetup t_x34 2247 ret 2248 end 2249 put g_b add o 24 56 2250 psc t_c34src 2251 ok = bsave false 2252 ok = and ok eq omcsrc t_c34src t_c34obj 0 2253 ok = and ok mkd t_d34 2254 ok = and ok eq genlib t_ntab true 14 t_c34lib 0 2255 ok = and ok cpexe t_flib t_c34tr 2256 ok = and ok cpexe t_nprb t_c34prb 2257 if not ok 2258 csetup t_x34 2259 ret 2260 end 2261 ctl t_x34 runprb t_c34prb 10 2262 end 2263 note ---- main 2264 fn ausage to int 2265 r = write 2 t_usage 0 len t_usage 2266 ret 2 2267 end 2268 fn main to int 2269 if ne argcnt 4 2270 ret ausage 2271 end 2272 r = argread 1 g_omc 0 4095 2273 if lt r 1 2274 ret ausage 2275 end 2276 put g_n 1 ulong r 2277 if not pinread 2278 r = write 2 t_nopin 0 len t_nopin 2279 ret 2 2280 end 2281 pclr 2282 for j ulong get g_n 1 bound 4096 2283 pc ulong get g_omc j 2284 end 2285 if not pinok 2286 r = write 2 t_refd 0 len t_refd 2287 ret 69 2288 end 2289 r = argread 2 g_gen 0 4095 2290 if lt r 1 2291 ret ausage 2292 end 2293 put g_n 7 ulong r 2294 r = argread 3 g_scr 0 4094 2295 if lt r 1 2296 ret ausage 2297 end 2298 if gt r 4000 2299 r = write 2 t_long 0 len t_long 2300 ret 2 2301 end 2302 n = ulong r 2303 x = makedir g_scr 0 n 448 2304 if ne x 0 2305 r = write 2 t_noscr 0 len t_noscr 2306 ret 2 2307 end 2308 put g_scr n 47 2309 put g_n 2 add n 1 2310 checks 2311 crow 2312 cfloat 2313 cexport 2314 chash 2315 cexpect 2316 cstack 2317 cext 2318 cuext 2319 crestore 2320 cruntime 2321 cneed 2322 caddr 2323 cfrest 2324 cnext 2325 ccrec 2326 ccto 2327 cnosave 2328 crelf 2329 cdiffer 2330 cx7use 2331 cslot 2332 cmap 2333 cnoneed 2334 cunlock 2335 cimprow 2336 cframe 2337 clockexp 2338 ctransport 2339 cnvinit 2340 cneedname 2341 cstkarg 2342 cnvcopy 2343 f = get g_n 11 2344 ot t_sum 2345 if and eq f 0 eq get g_n 12 get g_n 13 2346 ot t_pass 2347 else 2348 ot t_fl 2349 end 2350 ot t_sk 2351 onum get g_n 8 2352 ot t_sc 2353 onum get g_n 12 2354 ot t_scc 2355 onum get g_n 13 2356 oc 10 2357 oflush 2358 if ne f 0 2359 ret 1 2360 end 2361 if ne get g_n 12 get g_n 13 2362 ret 1 2363 end 2364 ret 0 2365 end