I disassembled the StgRun symbol, but it lacked any brk, which I spotted at the end of the symbol before it while messing around, so I reran the disassembler with all symbols but just grepped with context for StgRun instead. I've attach a text file of that output showing where StgRun is used, and its definition along with 50 lines of context both ways. |
b52818: f9400109 ldr x9, [x8] b5281c: eb1b013f cmp x9, x27 b52820: 54000081 b.ne 0xb52830 <scheduleWaitThread+0x280> b52824: f9400908 ldr x8, [x8, #0x10] b52828: eb1b011f cmp x8, x27 b5282c: 54000040 b.eq 0xb52834 <scheduleWaitThread+0x284> b52830: b904aaf3 str w19, [x23, #0x4a8] b52834: f901c2f6 str x22, [x23, #0x380] b52838: 97fff543 bl 0xb4fd44 <resumeHeapProfTimer> b5283c: 794042d8 ldrh w24, [x22, #0x20] b52840: b94042d9 ldr w25, [x22, #0x40] b52844: 94013085 bl 0xb9ea58 <__errno@plt> b52848: b9000019 str w25, [x0] b5284c: aa1703e0 mov x0, x23 b52850: aa1603e1 mov x1, x22 b52854: b904aeff str wzr, [x23, #0x4ac] b52858: 390f02f3 strb w19, [x23, #0x3c0] b5285c: b903c6ff str wzr, [x23, #0x3c4] b52860: 9400a9d8 bl 0xb7cfc0 <dirty_TSO> b52864: f9400ec1 ldr x1, [x22, #0x18] b52868: aa1703e0 mov x0, x23 b5286c: 9400aa06 bl 0xb7d084 <dirty_STACK> b52870: f942afa8 ldr x8, [x29, #0x558] b52874: 7100091f cmp w8, #0x2 b52878: 540001a0 b.eq 0xb528ac <scheduleWaitThread+0x2fc> b5287c: 71000d1f cmp w8, #0x3 b52880: 54000101 b.ne 0xb528a0 <scheduleWaitThread+0x2f0> b52884: c85ffea8 ldaxr x8, [x21] b52888: c809febf stlxr w9, xzr, [x21] b5288c: 35ffffc9 cbnz w9, 0xb52884 <scheduleWaitThread+0x2d4> b52890: 71000d1f cmp w8, #0x3 b52894: 540000c1 b.ne 0xb528ac <scheduleWaitThread+0x2fc> b52898: 94001e91 bl 0xb5a2dc <startTimer> b5289c: 14000004 b 0xb528ac <scheduleWaitThread+0x2fc> b528a0: c85ffebf ldaxr xzr, [x21] b528a4: c808febf stlxr w8, xzr, [x21] b528a8: 35ffffc8 cbnz w8, 0xb528a0 <scheduleWaitThread+0x2f0> b528ac: 397a3288 ldrb w8, [x20, #0xe8c] b528b0: 35000d08 cbnz w8, 0xb52a50 <scheduleWaitThread+0x4a0> b528b4: 51000f08 sub w8, w24, #0x3 b528b8: 7100091f cmp w8, #0x2 b528bc: 540001c3 b.lo 0xb528f4 <scheduleWaitThread+0x344> b528c0: 71000b1f cmp w24, #0x2 b528c4: 540001c0 b.eq 0xb528fc <scheduleWaitThread+0x34c> b528c8: 7100071f cmp w24, #0x1 b528cc: 54003341 b.ne 0xb52f34 <scheduleWaitThread+0x984> b528d0: f9400fe8 ldr x8, [sp, #0x18] b528d4: b00001c0 adrp x0, 0xb8b000 <stg_NO_TREC_info+0x18> b528d8: 912bc000 add x0, x0, #0xaf0 b528dc: 91006101 add x1, x8, #0x18 b528e0: 940015a5 bl 0xb57f74 <StgRun> b528e4: d1006008 sub x8, x0, #0x18 b528e8: f9000fe8 str x8, [sp, #0x18] b528ec: 910e4008 add x8, x0, #0x390 b528f0: 14000007 b 0xb5290c <scheduleWaitThread+0x35c> b528f4: 528000b9 mov w25, #0x5 b528f8: 14000006 b 0xb52910 <scheduleWaitThread+0x360> b528fc: f9400fe0 ldr x0, [sp, #0x18] b52900: 97ffe8d8 bl 0xb4cc60 <interpretBCO> b52904: 910ea008 add x8, x0, #0x3a8 b52908: f9000fe0 str x0, [sp, #0x18] b5290c: b9400119 ldr w25, [x8] b52910: f9400ff7 ldr x23, [sp, #0x18] b52914: f941c2f6 ldr x22, [x23, #0x380] b52918: 390f02ff strb wzr, [x23, #0x3c0] b5291c: f901c2ff str xzr, [x23, #0x380] b52920: 9401304e bl 0xb9ea58 <__errno@plt> b52924: b9400008 ldr w8, [x0] b52928: 71000b3f cmp w25, #0x2 b5292c: b90042c8 str w8, [x22, #0x40] b52930: 540001e0 b.eq 0xb5296c <scheduleWaitThread+0x3bc> b52934: 7100133f cmp w25, #0x4 b52938: 54000261 b.ne 0xb52984 <scheduleWaitThread+0x3d4> b5293c: b9402ac8 ldr w8, [x22, #0x28] b52940: 12003d09 and w9, w8, #0xffff b52944: 7100093f cmp w9, #0x2 b52948: 54000261 b.ne 0xb52994 <scheduleWaitThread+0x3e4> b5294c: f9401ac8 ldr x8, [x22, #0x30] b52950: f9400d00 ldr x0, [x8, #0x18] b52954: 9400093b bl 0xb54e40 <blackHoleOwner> b52958: b40002e0 cbz x0, 0xb529b4 <scheduleWaitThread+0x404> b5295c: b9403804 ldr w4, [x0, #0x38] b52960: 397a3288 ldrb w8, [x20, #0xe8c] b52964: 340002e8 cbz w8, 0xb529c0 <scheduleWaitThread+0x410> b52968: 14000041 b 0xb52a6c <scheduleWaitThread+0x4bc> b5296c: 397a3288 ldrb w8, [x20, #0xe8c] b52970: 34000288 cbz w8, 0xb529c0 <scheduleWaitThread+0x410> b52974: b94082c4 ldr w4, [x22, #0x80] b52978: 52800041 mov w1, #0x2 b5297c: 52800043 mov w3, #0x2 b52980: 1400003f b 0xb52a7c <scheduleWaitThread+0x4cc> b52984: 397a3288 ldrb w8, [x20, #0xe8c] b52988: 340001c8 cbz w8, 0xb529c0 <scheduleWaitThread+0x410> b5298c: 2a1903e3 mov w3, w25 b52990: 14000004 b 0xb529a0 <scheduleWaitThread+0x3f0> b52994: 397a3289 ldrb w9, [x20, #0xe8c] b52998: 34000149 cbz w9, 0xb529c0 <scheduleWaitThread+0x410> b5299c: 11001903 add w3, w8, #0x6 b529a0: 52800041 mov w1, #0x2 b529a4: aa1703e0 mov x0, x23 b529a8: aa1603e2 mov x2, x22 --
0000000000b57eb8 <getRTSStats>: b57eb8: d503245f bti c b57ebc: d00002cf adrp x15, 0xbb1000 <__retguard_1921> b57ec0: f943d1ef ldr x15, [x15, #0x7a0] b57ec4: ca1e01ef eor x15, x15, x30 b57ec8: d503233f paciasp b57ecc: d100c3ff sub sp, sp, #0x30 b57ed0: a90153fe stp x30, x20, [sp, #0x10] b57ed4: a9023ff3 stp x19, x15, [sp, #0x20] b57ed8: d0001034 adrp x20, 0xd5d000 <numa_map+0x3c> b57edc: 91208294 add x20, x20, #0x820 b57ee0: 52802f02 mov w2, #0x178 b57ee4: aa1403e1 mov x1, x20 b57ee8: aa0003f3 mov x19, x0 b57eec: a9007fff stp xzr, xzr, [sp] b57ef0: 94011ac8 bl 0xb9ea10 <memcpy@plt> b57ef4: 910003e0 mov x0, sp b57ef8: 910023e1 add x1, sp, #0x8 b57efc: 9400994a bl 0xb7e424 <getProcessTimes> b57f00: d0001029 adrp x9, 0xd5d000 <numa_map+0x3c> b57f04: d000102b adrp x11, 0xd5d000 <numa_map+0x3c> b57f08: a9402be8 ldp x8, x10, [sp] b57f0c: f943e129 ldr x9, [x9, #0x7c0] b57f10: f943e56b ldr x11, [x11, #0x7c8] b57f14: cb09010c sub x12, x8, x9 b57f18: cb0b014d sub x13, x10, x11 b57f1c: a909366c stp x12, x13, [x19, #0x90] b57f20: f940428c ldr x12, [x20, #0x80] b57f24: f940b28d ldr x13, [x20, #0x160] b57f28: 8b0c0129 add x9, x9, x12 b57f2c: 8b0d0129 add x9, x9, x13 b57f30: cb090108 sub x8, x8, x9 b57f34: f9003a68 str x8, [x19, #0x70] b57f38: f9404688 ldr x8, [x20, #0x88] b57f3c: a94153fe ldp x30, x20, [sp, #0x10] b57f40: 8b080168 add x8, x11, x8 b57f44: cb080148 sub x8, x10, x8 b57f48: f9003e68 str x8, [x19, #0x78] b57f4c: a9423ff3 ldp x19, x15, [sp, #0x20] b57f50: 9100c3ff add sp, sp, #0x30 b57f54: d00002c9 adrp x9, 0xbb1000 <__retguard_1921> b57f58: d50323bf autiasp b57f5c: f943d129 ldr x9, [x9, #0x7a0] b57f60: ca1e01ef eor x15, x15, x30 b57f64: eb0901ef subs x15, x15, x9 b57f68: b400004f cbz x15, 0xb57f70 <getRTSStats+0xb8> b57f6c: d4200020 brk #0x1 b57f70: d65f03c0 ret 0000000000b57f74 <StgRun>: b57f74: d503245f bti c b57f78: 900002cf adrp x15, 0xbaf000 <unlink@plt+0xf540> b57f7c: f94799ef ldr x15, [x15, #0xf30] b57f80: ca1e01ef eor x15, x15, x30 b57f84: d503233f paciasp b57f88: f81a0ffe str x30, [sp, #-0x60]! b57f8c: a9016ffc stp x28, x27, [sp, #0x10] b57f90: a90267fa stp x26, x25, [sp, #0x20] b57f94: a9035ff8 stp x24, x23, [sp, #0x30] b57f98: a90457f6 stp x22, x21, [sp, #0x40] b57f9c: a9054ff4 stp x20, x19, [sp, #0x50] b57fa0: a9bf7bfd stp x29, x30, [sp, #-0x10]! b57fa4: 910003fd mov x29, sp b57fa8: a9bf47f0 stp x16, x17, [sp, #-0x10]! b57fac: a9bf53f3 stp x19, x20, [sp, #-0x10]! b57fb0: a9bf5bf5 stp x21, x22, [sp, #-0x10]! b57fb4: a9bf63f7 stp x23, x24, [sp, #-0x10]! b57fb8: a9bf6bf9 stp x25, x26, [sp, #-0x10]! b57fbc: a9bf73fb stp x27, x28, [sp, #-0x10]! b57fc0: 6dbf27e8 stp d8, d9, [sp, #-0x10]! b57fc4: 6dbf2fea stp d10, d11, [sp, #-0x10]! b57fc8: 6dbf37ec stp d12, d13, [sp, #-0x10]! b57fcc: 6dbf3fee stp d14, d15, [sp, #-0x10]! b57fd0: d14013ff sub sp, sp, #0x4, lsl #12 // =0x4000 b57fd4: aa0103f3 mov x19, x1 b57fd8: d61f0000 br x0 0000000000b57fdc <StgReturn>: b57fdc: 914013ff add sp, sp, #0x4, lsl #12 // =0x4000 b57fe0: aa1603e0 mov x0, x22 b57fe4: 6cc13fee ldp d14, d15, [sp], #0x10 b57fe8: 6cc137ec ldp d12, d13, [sp], #0x10 b57fec: 6cc12fea ldp d10, d11, [sp], #0x10 b57ff0: 6cc127e8 ldp d8, d9, [sp], #0x10 b57ff4: a8c173fb ldp x27, x28, [sp], #0x10 b57ff8: a8c16bf9 ldp x25, x26, [sp], #0x10 b57ffc: a8c163f7 ldp x23, x24, [sp], #0x10 b58000: a8c15bf5 ldp x21, x22, [sp], #0x10 b58004: a8c153f3 ldp x19, x20, [sp], #0x10 b58008: a8c147f0 ldp x16, x17, [sp], #0x10 b5800c: a8c17bfd ldp x29, x30, [sp], #0x10 b58010: a9454ff4 ldp x20, x19, [sp, #0x50] b58014: a94457f6 ldp x22, x21, [sp, #0x40] b58018: a9435ff8 ldp x24, x23, [sp, #0x30] b5801c: a94267fa ldp x26, x25, [sp, #0x20] b58020: a9416ffc ldp x28, x27, [sp, #0x10] b58024: f84607fe ldr x30, [sp], #0x60 b58028: f00002a9 adrp x9, 0xbaf000 <unlink@plt+0xf540> b5802c: d50323bf autiasp b58030: f9479929 ldr x9, [x9, #0xf30]
I've been keeping the commands in a shell script, though I was still a bit surprised it worked to get to the same point first try. I was running the commands manually, as the script didn't fetch the sources, extract the sysroot, etc. Apart from actually procuring the sysroot tarball to extract from, I've cleaned it up so it does everything into a hopefully usable 292-line script. Most of that line count is from comments, arguments split up over many lines, support for both ways of fetching sources, and the embedded patchfile. You can, of course, read it and run things manually if you want. While, of course, the various commands have been tested, I haven't actually run it as an integrated script (in either fetch mode). Comment paragraphs starting with “NOTE:” mark out things which I'm not sure whether are needed or not or where I don't know why they're needed, or it doesn't make sense that they're needed (or inversely, that they work). It installs dependencies with pkg_add and fetches sources w/ Git by default, or source tarball if $FETCH_TARBALL_SOURCES is set to 1. It requires as its first argument a path to a gzipped sysroot tarball from an OpenBSD/arm64 system with libiconv installed. I created mine with /usr/lib, /usr/include, and /usr/local/{lib,include,bin}, though I doubt any binaries are necessary. Since the only package I had installed was libiconv, all I had in the /usr/local/ directories were libiconv stuff, but if you have other stuff installed, I think the following command should suffice: tar czf sysroot.tar.gz /usr/lib /usr/include /usr/local/lib/*{iconv,charset}* /usr/local/include/*{iconv,charset}* /usr/local/bin/iconv You don't need to be root (I didn't, on a very minimal VM). When extracting them, it recreates the sysroot tree with the permissions of the user running tar. Since I had to make changes to the tree to get the build working, I decided to do a Git-based build on my real machine to keep easier track of any changes, so I'll just embed the output of my `git diff` into the script, which it'll use to patch the sourcetree. I've attached the script as well. |
build-ghc-9.10.1-for-openbsd-arm64-on-openbsd-7.6-amd64.ksh
Description: Binary data
Cheers,
Habib
|