CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
| 1 | om2 |
| 2 | note Generated by om/core/native.sh from canonical local Omega sources. |
| 3 | note cubin_elf.om: explicitly selected sm_86/sm_121 cubin ELF packer. |
| 4 | note It replaces the body of omega_cubin_pack in src/omega_cubin.c, which stays compiled only behind |
| 5 | note CUDAPP_MIGRATION_PENDING_C_CORE as the explicit legacy oracle. |
| 6 | note |
| 7 | note Input (omega_cubin.c packs it): |
| 8 | note m: 0 strlen of the name 1 text_len 2 nparams 3 cbank_size 4 gpr_count 5 shared_reserved |
| 9 | note 6 target SM (86 or 121; 0 retains historical 121) 7 unused; from 8 parameter triples |
| 10 | note nm: the name's first 64 bytes; tx: the text (16777216 bytes, the C limit 1 shl 24) |
| 11 | note o: the output image, little-endian words; byte p is bits 8 (p rem 8) of word p / 8 |
| 12 | note Result: the image's byte count, or the refusal 1..7 of OMEGA_CUBIN_E_* (an image is never below 8 |
| 13 | note bytes). On a refusal o 0 holds the detail (PARAMS 0 count, 1 overlap, 2 size, 3 pointer size, |
| 14 | note 4 alignment; CBANK 5 end, 6 range; MEM 7 over the output bound), o 1 the parameter, o 2 the end |
| 15 | note or the image size, so the C caller prints the oracle's exact message. |
| 16 | note Bound: the output view holds 134217728 bytes; an image above it (the in-file shared reservation plus the |
| 17 | note text plus a few KiB of headers over 128 MiB) |
| 18 | note is refused with 7 where the C oracle would allocate it. Arrays stop at 16777216 elements (error 23). |
| 19 | note Every constant is the decimal form of the C writer's hex or text (conversions by Wolfram, |
| 20 | note evidence/CUDAPP-OM-CUBIN/wolfram-constants.txt). |
| 21 | |
| 22 | const TXN ulong 16777216 |
| 23 | const OWN ulong 16777216 |
| 24 | const OBYTES ulong 134217728 |
| 25 | const MLEN ulong 104 |
| 26 | const PBASE ulong 896 |
| 27 | |
| 28 | fn parbase m view ulong MLEN to ulong |
| 29 | if eq get m 6 86 |
| 30 | ret 352 |
| 31 | end |
| 32 | ret PBASE |
| 33 | end |
| 34 | |
| 35 | fn smtarget m view ulong MLEN to ulong |
| 36 | if eq get m 6 0 |
| 37 | ret 121 |
| 38 | end |
| 39 | ret get m 6 |
| 40 | end |
| 41 | |
| 42 | note 1 when the image carries .note.nv.tkinfo (sm_121 only: its strings name sm_121; sm_86 has none) |
| 43 | fn tkon m view ulong MLEN to ulong |
| 44 | if eq smtarget m 121 |
| 45 | ret 1 |
| 46 | end |
| 47 | ret 0 |
| 48 | end |
| 49 | |
| 50 | note one byte into the word image |
| 51 | fn pb o edit ulong OWN p ulong v ulong to void |
| 52 | k = shr p 3 |
| 53 | s = shl and p 7 3 |
| 54 | w = and get o k not shl 255 s |
| 55 | put o k or w shl and v 255 s |
| 56 | end |
| 57 | |
| 58 | fn p16 o edit ulong OWN p ulong v ulong to void |
| 59 | pb o p v |
| 60 | pb o add p 1 shr v 8 |
| 61 | end |
| 62 | |
| 63 | fn p32 o edit ulong OWN p ulong v ulong to void |
| 64 | p16 o p v |
| 65 | p16 o add p 2 shr v 16 |
| 66 | end |
| 67 | |
| 68 | fn p64 o edit ulong OWN p ulong v ulong to void |
| 69 | p32 o p v |
| 70 | p32 o add p 4 shr v 32 |
| 71 | end |
| 72 | |
| 73 | note the k low bytes of v at p; gives p + k |
| 74 | fn ps o edit ulong OWN p ulong v ulong k ulong to ulong |
| 75 | for i ulong k |
| 76 | pb o add p i shr v mul i 8 |
| 77 | end |
| 78 | ret add p k |
| 79 | end |
| 80 | |
| 81 | note the n name bytes at p; gives p + n |
| 82 | fn pn o edit ulong OWN p ulong nm view uchar 64 n ulong to ulong |
| 83 | for i ulong n |
| 84 | pb o add p i ulong get nm i |
| 85 | end |
| 86 | ret add p n |
| 87 | end |
| 88 | |
| 89 | fn al x ulong a ulong to ulong |
| 90 | ret mul div add x sub a 1 a a |
| 91 | end |
| 92 | |
| 93 | fn isal c uchar to ulong |
| 94 | if or or and ge c 65 le c 90 and ge c 97 le c 122 eq c 95 |
| 95 | ret 1 |
| 96 | end |
| 97 | ret 0 |
| 98 | end |
| 99 | |
| 100 | fn isan c uchar to ulong |
| 101 | if or ne isal c 0 and ge c 48 le c 57 |
| 102 | ret 1 |
| 103 | end |
| 104 | ret 0 |
| 105 | end |
| 106 | |
| 107 | note name_ok of the C writer: 1..64 bytes, [A-Za-z_][A-Za-z0-9_]* |
| 108 | fn nmok nm view uchar 64 n ulong to ulong |
| 109 | if or eq n 0 gt n 64 |
| 110 | ret 0 |
| 111 | end |
| 112 | if eq isal get nm 0 0 |
| 113 | ret 0 |
| 114 | end |
| 115 | for i ulong n |
| 116 | if eq isan get nm i 0 |
| 117 | ret 0 |
| 118 | end |
| 119 | end |
| 120 | ret 1 |
| 121 | end |
| 122 | |
| 123 | fn pfail o edit ulong OWN d ulong i ulong to ulong |
| 124 | put o 0 d |
| 125 | put o 1 i |
| 126 | ret 3 |
| 127 | end |
| 128 | |
| 129 | note one parameter against the running end e: 0 good, else the detail 1..4 of the C order |
| 130 | fn pbad of ulong sz ulong pt ulong e ulong to ulong |
| 131 | if lt of e |
| 132 | ret 1 |
| 133 | end |
| 134 | if not or or or eq sz 8 eq sz 4 eq sz 2 eq sz 1 |
| 135 | ret 2 |
| 136 | end |
| 137 | if and ne pt 0 ne sz 8 |
| 138 | ret 3 |
| 139 | end |
| 140 | if and eq sz 8 ne and of 7 0 |
| 141 | ret 4 |
| 142 | end |
| 143 | if and eq sz 4 ne and of 3 0 |
| 144 | ret 4 |
| 145 | end |
| 146 | if and eq sz 2 ne and of 1 0 |
| 147 | ret 4 |
| 148 | end |
| 149 | ret 0 |
| 150 | end |
| 151 | |
| 152 | note the parameter walk and the bank checks, in the C order |
| 153 | fn pchk m view ulong MLEN o edit ulong OWN to ulong |
| 154 | e = parbase m |
| 155 | np = get m 2 |
| 156 | for i ulong np |
| 157 | b = add 8 mul i 3 |
| 158 | d = pbad get m b get m add b 1 get m add b 2 e |
| 159 | if ne d 0 |
| 160 | ret pfail o d i |
| 161 | end |
| 162 | e = add get m b get m add b 1 |
| 163 | end |
| 164 | cb = get m 3 |
| 165 | if gt e cb |
| 166 | put o 0 5 |
| 167 | put o 2 e |
| 168 | ret 4 |
| 169 | end |
| 170 | if or gt cb 1024 lt cb parbase m |
| 171 | put o 0 6 |
| 172 | ret 4 |
| 173 | end |
| 174 | ret 0 |
| 175 | end |
| 176 | |
| 177 | fn chk m view ulong MLEN nm view uchar 64 o edit ulong OWN to ulong |
| 178 | if not or eq smtarget m 86 eq smtarget m 121 |
| 179 | ret 1 |
| 180 | end |
| 181 | if eq nmok nm get m 0 0 |
| 182 | ret 1 |
| 183 | end |
| 184 | tl = get m 1 |
| 185 | if or or eq tl 0 ne and tl 15 0 gt tl TXN |
| 186 | ret 2 |
| 187 | end |
| 188 | if gt get m 2 32 |
| 189 | ret pfail o 0 0 |
| 190 | end |
| 191 | if gt get m 4 255 |
| 192 | ret 5 |
| 193 | end |
| 194 | if ne and get m 5 3 0 |
| 195 | ret 6 |
| 196 | end |
| 197 | ret pchk m o |
| 198 | end |
| 199 | |
| 200 | note L: 1..10 section offsets, 11 shoff, 12 phoff, 13 total, 14 .nv.info.<fn> size, |
| 201 | note 15 the offset of section 11 (.note.nv.tkinfo, sm_121 only) |
| 202 | fn lay m view ulong MLEN l edit ulong 16 to void |
| 203 | n = get m 0 |
| 204 | f = ulong 64 |
| 205 | put l 1 f |
| 206 | f = add f add add 117 mul 16 tkon m mul 3 n |
| 207 | put l 2 f |
| 208 | f = add f add n 2 |
| 209 | f = al f 8 |
| 210 | put l 3 f |
| 211 | f = add f 96 |
| 212 | f = al f 128 |
| 213 | put l 4 f |
| 214 | f = add f get m 1 |
| 215 | f = al f 16 |
| 216 | put l 5 f |
| 217 | f = add f get m 3 |
| 218 | f = al f 4 |
| 219 | put l 6 f |
| 220 | f = add f 36 |
| 221 | f = al f 4 |
| 222 | put l 7 f |
| 223 | f = add f 36 |
| 224 | il = add 48 mul 16 get m 2 |
| 225 | put l 14 il |
| 226 | f = al f 4 |
| 227 | put l 8 f |
| 228 | f = add f il |
| 229 | put l 9 f |
| 230 | f = add f get m 5 |
| 231 | f = al f 4 |
| 232 | put l 10 f |
| 233 | f = add f 32 |
| 234 | if eq tkon m 1 |
| 235 | f = al f 4 |
| 236 | put l 15 f |
| 237 | f = add f 120 |
| 238 | end |
| 239 | f = al f 8 |
| 240 | put l 11 f |
| 241 | put l 12 add f add 704 mul 64 tkon m |
| 242 | put l 13 add f add 984 mul 64 tkon m |
| 243 | end |
| 244 | |
| 245 | note zero words 0 .. ceil(total / 8) - 1, in parts of 4096 (a loop stops at 1000000 passes) |
| 246 | fn wzero o edit ulong OWN total ulong to void |
| 247 | nw = shr add total 7 3 |
| 248 | nc = shr add nw 4095 12 |
| 249 | for c ulong nc |
| 250 | for j ulong 4096 |
| 251 | k = add shl c 12 j |
| 252 | if lt k nw |
| 253 | put o k 0 |
| 254 | end |
| 255 | end |
| 256 | end |
| 257 | end |
| 258 | |
| 259 | fn txw tx view uchar TXN q ulong to ulong |
| 260 | w = ulong 0 |
| 261 | for i ulong 8 |
| 262 | w = or w shl ulong get tx add q i mul i 8 |
| 263 | end |
| 264 | ret w |
| 265 | end |
| 266 | |
| 267 | note the text at p (a multiple of 128), whole words: text_len is a multiple of 16 |
| 268 | fn wtext o edit ulong OWN tx view uchar TXN p ulong tl ulong to void |
| 269 | nw = shr tl 3 |
| 270 | nc = shr add nw 4095 12 |
| 271 | b = shr p 3 |
| 272 | for c ulong nc |
| 273 | for j ulong 4096 |
| 274 | k = add shl c 12 j |
| 275 | if lt k nw |
| 276 | put o add b k txw tx shl k 3 |
| 277 | end |
| 278 | end |
| 279 | end |
| 280 | end |
| 281 | |
| 282 | note ELF header: 0x7f E L F, ELFCLASS64, LSB, version 1, ELFOSABI_NV 0x41 as one word; ABI version 8 |
| 283 | fn whdr o edit ulong OWN l view ulong 16 m view ulong MLEN to void |
| 284 | p64 o 0 4684026196722992511 |
| 285 | if eq smtarget m 86 |
| 286 | pb o 7 51 |
| 287 | end |
| 288 | if eq smtarget m 86 |
| 289 | pb o 8 7 |
| 290 | else |
| 291 | pb o 8 8 |
| 292 | end |
| 293 | p16 o 16 2 |
| 294 | p16 o 18 190 |
| 295 | if eq smtarget m 86 |
| 296 | p32 o 20 130 |
| 297 | else |
| 298 | p32 o 20 1 |
| 299 | end |
| 300 | p64 o 32 get l 12 |
| 301 | p64 o 40 get l 11 |
| 302 | if eq smtarget m 86 |
| 303 | note ELF EF_CUDA_SM86 | EF_CUDA_VIRTUAL_SM86 | 64-bit addressing and unified texture mode. |
| 304 | p32 o 48 or shl ulong 86 16 or shl ulong 5 8 ulong 86 |
| 305 | else |
| 306 | p32 o 48 100694274 |
| 307 | end |
| 308 | p16 o 52 64 |
| 309 | p16 o 54 56 |
| 310 | p16 o 56 5 |
| 311 | p16 o 58 64 |
| 312 | p16 o 60 add 11 tkon m |
| 313 | p16 o 62 1 |
| 314 | end |
| 315 | |
| 316 | note .shstrtab from p (its first byte is the 0 already there) |
| 317 | fn wshs o edit ulong OWN p ulong nm view uchar 64 n ulong tk ulong to void |
| 318 | q = add p 1 |
| 319 | q = ps o q 7022363563455443758 8 |
| 320 | q = add ps o q 98 1 1 |
| 321 | q = add ps o q 27691700481979182 7 1 |
| 322 | q = add ps o q 27691700398420782 7 1 |
| 323 | q = ps o q 51077770998830 6 |
| 324 | q = add pn o q nm n 1 |
| 325 | q = ps o q 8317708033571843630 8 |
| 326 | q = ps o q 50785646698868 6 |
| 327 | q = add pn o q nm n 1 |
| 328 | q = add ps o q 8027224783864622638 8 1 |
| 329 | q = ps o q 8101253776481349166 8 |
| 330 | q = add ps o q 29793 2 1 |
| 331 | q = ps o q 8027224783864622638 8 |
| 332 | q = ps o q 46 1 |
| 333 | q = add pn o q nm n 1 |
| 334 | q = ps o q 8241983636974759470 8 |
| 335 | q = ps o q 8243121572516095077 8 |
| 336 | q = add ps o q 206936761718 5 1 |
| 337 | q = ps o q 8533809357193702958 8 |
| 338 | if eq tk 1 |
| 339 | q = add ps o q 31356346816619310 7 1 |
| 340 | q = ps o q 8533809357193702958 8 |
| 341 | q = ps o q 31356346815968302 7 |
| 342 | else |
| 343 | q = ps o q 31356346816619310 7 |
| 344 | end |
| 345 | end |
| 346 | |
| 347 | note .symtab: null, the .text section symbol, the function, the .nv.constant0 section symbol |
| 348 | fn wsym o edit ulong OWN p ulong tl ulong to void |
| 349 | pb o add p 28 3 |
| 350 | p16 o add p 30 4 |
| 351 | p32 o add p 48 1 |
| 352 | pb o add p 52 18 |
| 353 | pb o add p 53 16 |
| 354 | p16 o add p 54 4 |
| 355 | p64 o add p 64 tl |
| 356 | pb o add p 76 3 |
| 357 | p16 o add p 78 5 |
| 358 | end |
| 359 | |
| 360 | note .nv.info: attributes 0x2f (registers), 0x11, 0x12 |
| 361 | fn wginfo o edit ulong OWN p ulong gpr ulong to void |
| 362 | p16 o p 12036 |
| 363 | p16 o add p 2 8 |
| 364 | p32 o add p 4 2 |
| 365 | p32 o add p 8 gpr |
| 366 | p16 o add p 12 4356 |
| 367 | p16 o add p 14 8 |
| 368 | p32 o add p 16 2 |
| 369 | p16 o add p 24 4612 |
| 370 | p16 o add p 26 8 |
| 371 | p32 o add p 28 2 |
| 372 | end |
| 373 | |
| 374 | note .nv.compat: nine little-endian words of the reference container |
| 375 | fn wcompat o edit ulong OWN p ulong to void |
| 376 | p32 o p 2306 |
| 377 | p32 o add p 4 131586 |
| 378 | p32 o add p 8 328962 |
| 379 | p32 o add p 12 16844547 |
| 380 | p32 o add p 16 770 |
| 381 | p32 o add p 20 67074 |
| 382 | p32 o add p 24 527108 |
| 383 | end |
| 384 | |
| 385 | note attribute 0x37 then one 0x17 per parameter from p; gives the parameter end |
| 386 | fn wpar o edit ulong OWN p ulong m view ulong MLEN to ulong |
| 387 | p16 o p 14084 |
| 388 | p16 o add p 2 4 |
| 389 | p32 o add p 4 130 |
| 390 | q = add p 8 |
| 391 | e = parbase m |
| 392 | np = get m 2 |
| 393 | for i ulong np |
| 394 | b = add 8 mul i 3 |
| 395 | of = get m b |
| 396 | p16 o q 5892 |
| 397 | p16 o add q 2 12 |
| 398 | p32 o add q 8 or i shl sub of parbase m 16 |
| 399 | ty = ulong 1175552 |
| 400 | if ne get m add b 2 0 |
| 401 | ty = 2225408 |
| 402 | end |
| 403 | p32 o add q 12 ty |
| 404 | q = add q 16 |
| 405 | if gt add of get m add b 1 e |
| 406 | e = add of get m add b 1 |
| 407 | end |
| 408 | end |
| 409 | ret e |
| 410 | end |
| 411 | |
| 412 | note the attributes after the parameters, from q |
| 413 | fn wtail o edit ulong OWN q ulong e ulong gpr ulong base ulong to void |
| 414 | p16 o q 6403 |
| 415 | p16 o add q 2 sub e base |
| 416 | p16 o add q 4 2564 |
| 417 | p16 o add q 6 8 |
| 418 | p32 o add q 8 3 |
| 419 | p32 o add q 12 or base shl sub e base 16 |
| 420 | p16 o add q 16 20483 |
| 421 | p16 o add q 20 6915 |
| 422 | p16 o add q 22 gpr |
| 423 | p16 o add q 24 24323 |
| 424 | p16 o add q 26 257 |
| 425 | p16 o add q 28 18946 |
| 426 | p16 o add q 32 13828 |
| 427 | p16 o add q 34 4 |
| 428 | end |
| 429 | |
| 430 | note .note.nv.cuinfo: namesz 12, descsz 8, type 0x3e8, "NVIDIA Corp", 2, sm 121, 130 |
| 431 | fn wnote o edit ulong OWN p ulong sm ulong to void |
| 432 | p32 o p 12 |
| 433 | p32 o add p 4 8 |
| 434 | p32 o add p 8 1000 |
| 435 | q = ps o add p 12 4836937782729987662 8 |
| 436 | q = ps o q 7369327 3 |
| 437 | p16 o add p 24 2 |
| 438 | p16 o add p 26 sm |
| 439 | p32 o add p 28 130 |
| 440 | end |
| 441 | |
| 442 | note .note.nv.tkinfo, which the sm_121 driver requires (CUDApp#68): namesz 12, descsz 96, type 2000, |
| 443 | note "NVIDIA Corp", then 2, 0 and the offsets 1 8 34 52 of the strings "cudapp", "CUDApp omega_cubin |
| 444 | note sm_121", "Build omega_cubin" and "-arch sm_121" in the blob from p + 48 (its bytes 64.. stay 0) |
| 445 | fn wtk o edit ulong OWN p ulong to void |
| 446 | p32 o p 12 |
| 447 | p32 o add p 4 96 |
| 448 | p32 o add p 8 2000 |
| 449 | q = ps o add p 12 4836937782729987662 8 |
| 450 | q = ps o q 7369327 3 |
| 451 | p32 o add p 24 2 |
| 452 | p32 o add p 32 1 |
| 453 | p32 o add p 36 8 |
| 454 | p32 o add p 40 34 |
| 455 | p32 o add p 44 52 |
| 456 | q = ps o add p 48 31648760991146752 8 |
| 457 | q = ps o q 8007523764898387267 8 |
| 458 | q = ps o q 7094686049299293549 8 |
| 459 | q = ps o q 3616776899442798185 8 |
| 460 | q = ps o q 2334109707079385137 8 |
| 461 | q = ps o q 8458709397083090287 8 |
| 462 | q = ps o q 7165896803008538978 8 |
| 463 | q = ps o q 3544950142621917288 8 |
| 464 | end |
| 465 | |
| 466 | fn sh1 o edit ulong OWN b ulong nm ulong ty ulong fl ulong to void |
| 467 | p32 o b nm |
| 468 | p32 o add b 4 ty |
| 469 | p64 o add b 8 fl |
| 470 | end |
| 471 | |
| 472 | fn sh2 o edit ulong OWN b ulong of ulong sz ulong lk ulong inf ulong to void |
| 473 | p64 o add b 24 of |
| 474 | p64 o add b 32 sz |
| 475 | p32 o add b 40 lk |
| 476 | p32 o add b 44 inf |
| 477 | end |
| 478 | |
| 479 | fn sh3 o edit ulong OWN b ulong a ulong es ulong to void |
| 480 | p64 o add b 48 a |
| 481 | p64 o add b 56 es |
| 482 | end |
| 483 | |
| 484 | note section headers 1..5 |
| 485 | fn wsha o edit ulong OWN l view ulong 16 m view ulong MLEN to void |
| 486 | n = get m 0 |
| 487 | b = add get l 11 64 |
| 488 | sh1 o b 1 3 0 |
| 489 | sh2 o b get l 1 add add 117 mul 16 tkon m mul 3 n 0 0 |
| 490 | sh3 o b 1 0 |
| 491 | b = add b 64 |
| 492 | sh1 o b 11 3 0 |
| 493 | sh2 o b get l 2 add n 2 0 0 |
| 494 | sh3 o b 1 0 |
| 495 | b = add b 64 |
| 496 | sh1 o b 19 2 0 |
| 497 | sh2 o b get l 3 96 2 2 |
| 498 | sh3 o b 8 24 |
| 499 | b = add b 64 |
| 500 | sh1 o b 27 1 6 |
| 501 | sh2 o b get l 4 get m 1 3 2 |
| 502 | sh3 o b 128 0 |
| 503 | b = add b 64 |
| 504 | sh1 o b add 34 n 1 66 |
| 505 | sh2 o b get l 5 get m 3 3 4 |
| 506 | sh3 o b 16 0 |
| 507 | end |
| 508 | |
| 509 | note section headers 6..11 |
| 510 | fn wshb o edit ulong OWN l view ulong 16 m view ulong MLEN to void |
| 511 | n = get m 0 |
| 512 | b = add get l 11 384 |
| 513 | sh1 o b add 49 mul 2 n 1879048192 0 |
| 514 | sh2 o b get l 6 36 3 0 |
| 515 | sh3 o b 4 0 |
| 516 | b = add b 64 |
| 517 | sh1 o b add 58 mul 2 n 1879048326 0 |
| 518 | sh2 o b get l 7 36 0 0 |
| 519 | sh3 o b 4 0 |
| 520 | b = add b 64 |
| 521 | sh1 o b add 69 mul 2 n 1879048192 64 |
| 522 | sh2 o b get l 8 get l 14 3 4 |
| 523 | sh3 o b 4 0 |
| 524 | b = add b 64 |
| 525 | sh1 o b add 79 mul 3 n 8 3 |
| 526 | sh2 o b get l 9 get m 5 0 0 |
| 527 | sh3 o b 1 0 |
| 528 | b = add b 64 |
| 529 | sh1 o b add 101 mul 3 n 7 16777280 |
| 530 | sh2 o b get l 10 32 mul 11 tkon m 2 |
| 531 | sh3 o b 4 0 |
| 532 | if eq tkon m 1 |
| 533 | b = add b 64 |
| 534 | sh1 o b add 117 mul 3 n 7 33554432 |
| 535 | sh2 o b get l 15 120 0 0 |
| 536 | sh3 o b 4 0 |
| 537 | end |
| 538 | end |
| 539 | |
| 540 | fn ph1 o edit ulong OWN b ulong ty ulong fl ulong of ulong to void |
| 541 | p32 o b ty |
| 542 | p32 o add b 4 fl |
| 543 | p64 o add b 8 of |
| 544 | p64 o add b 48 8 |
| 545 | end |
| 546 | |
| 547 | fn ph2 o edit ulong OWN b ulong fs ulong ms ulong to void |
| 548 | p64 o add b 32 fs |
| 549 | p64 o add b 40 ms |
| 550 | end |
| 551 | |
| 552 | note program headers: PHDR, LOAD R (the table), LOAD R|E (text), LOAD R|W (shared), LOAD R (bank) |
| 553 | fn wph o edit ulong OWN l view ulong 16 m view ulong MLEN to void |
| 554 | b = get l 12 |
| 555 | ph1 o b 6 4 b |
| 556 | ph2 o b 280 280 |
| 557 | ph1 o add b 56 1 4 b |
| 558 | ph2 o add b 56 280 280 |
| 559 | ph1 o add b 112 1 5 get l 4 |
| 560 | ph2 o add b 112 get m 1 get m 1 |
| 561 | ph1 o add b 168 1 6 get l 9 |
| 562 | ph2 o add b 168 0 get m 5 |
| 563 | ph1 o add b 224 1 4 get l 5 |
| 564 | ph2 o add b 224 get m 3 get m 3 |
| 565 | end |
| 566 | |
| 567 | note .nv.info.<fn>: attribute 0x37, the parameters, then the tail |
| 568 | fn winfo o edit ulong OWN l view ulong 16 m view ulong MLEN to void |
| 569 | p = get l 8 |
| 570 | e = wpar o p m |
| 571 | q = add add p 8 mul 16 get m 2 |
| 572 | wtail o q e get m 4 parbase m |
| 573 | end |
| 574 | |
| 575 | note every section payload and both header tables into the zeroed image |
| 576 | fn wbody o edit ulong OWN l view ulong 16 m view ulong MLEN nm view uchar 64 tx view uchar TXN to void |
| 577 | whdr o l m |
| 578 | n = get m 0 |
| 579 | wshs o get l 1 nm n tkon m |
| 580 | q = pn o add get l 2 1 nm n |
| 581 | wsym o get l 3 get m 1 |
| 582 | wtext o tx get l 4 get m 1 |
| 583 | wginfo o get l 6 get m 4 |
| 584 | wcompat o get l 7 |
| 585 | winfo o l m |
| 586 | wnote o get l 10 smtarget m |
| 587 | if eq tkon m 1 |
| 588 | wtk o get l 15 |
| 589 | end |
| 590 | wsha o l m |
| 591 | wshb o l m |
| 592 | wph o l m |
| 593 | end |
| 594 | |
| 595 | export fn cubin_elf m view ulong 104 nm view uchar 64 tx view uchar 16777216 o edit ulong 16777216 to ulong |
| 596 | l = new ulong 16 0 |
| 597 | rc = chk m nm o |
| 598 | if ne rc 0 |
| 599 | ret rc |
| 600 | end |
| 601 | lay m edit l |
| 602 | t = get l 13 |
| 603 | if gt t OBYTES |
| 604 | put o 0 7 |
| 605 | put o 2 t |
| 606 | ret 7 |
| 607 | end |
| 608 | wzero o t |
| 609 | wbody o view l m nm tx |
| 610 | ret t |
| 611 | end |
| 612 |