SEGFAULT @ 0xfffffffffffffffe (gdb) x/16i 0x3ff6e60000 ## Trampoline code 0x3ff6e60000: auipc t0,0x0 0x3ff6e60004: addi sp,sp,-32 0x3ff6e60006: sd ra,16(sp) 0x3ff6e60008: sd t0,8(sp) 0x3ff6e6000a: sd sp,0(sp) 0x3ff6e6000c: auipc t1,0x1c 0x3ff6e60010: ld t2,0(t1) 0x3ff6e60014: jalr t2 0x3ff6e60016: ld ra,16(sp) 0x3ff6e60018: addi sp,sp,32 0x3ff6e6001a: ret 0x3ff6e6001c: nop 0x3ff6e6001e: nop 0x3ff6e60020: unimp 0x3ff6e60022: unimp 0x3ff6e60024: unimp (gdb) x/2x 0x3ff6e60028 0x3ff6e60028: 0x0000002a 0xaab68572 (gdb) x thunkEntry 0x2aaab68572 : 0x00088317 (gdb) x/12i thunkEntry 0x2aaab68572 : auipc t1,0x88 0x2aaab68576 : ld t1,918(t1) 0x2aaab6857a : ld t1,0(t1) 0x2aaab6857e : addi sp,sp,-1008 0x2aaab68582 : sd a0,8(sp) 0x2aaab68584 : ld t1,1080(t1) 0x2aaab68588 : sd a0,24(sp) 0x2aaab6858a : sd a5,64(sp) 0x2aaab6858c : sd ra,1000(sp) 0x2aaab68590 : sd s0,992(sp) 0x2aaab68594 : sd s1,984(sp) 0x2aaab68598 : sd a1,32(sp) ... (gdb) i b ## Some breakpoints set (trampoline & thunkEntry), but not hit Num Type Disp Enb Address What 1 breakpoint keep y 0x0000002aaab686d8 in allocateExecutablePage at /usr/build/RiscV64vm/platforms/Cross/plugins/IA32ABI/riscv64abicc.c:325 breakpoint already hit 1 time 2 breakpoint keep y 0x0000002aaab671b2 in primAlienReplace at /usr/build/RiscV64vm/src/plugins/IA32ABI/IA32ABI.c:495 breakpoint already hit 1 time 4 breakpoint keep y primThunkEntry 5 breakpoint keep y 0x0000002aaab68572 in thunkEntry at /usr/build/RiscV64vm/platforms/Cross/plugins/IA32ABI/riscv64abicc.c:185 6 breakpoint keep y 0x3ff6e60000 7 breakpoint keep y 0x3ff6e6000c (gdb) vvv===vvv===vvv===vvv Trampoline Setup Details vvv===vvv===vvv===vvv 'From Squeak5.3 of 12 May 2022 [latest update: #19481] on 29 July 2022 at 1:54:08 pm'! !FFICallbackThunk methodsFor: 'private-instance initalization' stamp: 'KenD 7/29/2022 13:54'! initializeRiscV64 "Initialize the receiver with a __ccall thunk. The thunk calls thunkEntry in the Alien/IA32ABI plugin, whose source is in platforms/Cross/plugins/IA32ABI/riscv64abicc.c. thunkEntry is the entry point for Callbacks. The objective of the thunk is to call thunkEntry with all arguments to the call of the thunk (registers and stack) as well as a pointer to the thunk itself. thunkEntry is as follows: long long thunkEntry(long x0, long x1, long x2, long x3, long x4, long x5, long x6, long x7, double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, void *thunkpPlus20, sqIntptr_t *stackp) thunkEntry then collects the various arguments (thunk, integer register arguments, floating-point register arguments, stack pointer) in a VMCallbackContext and invokes the callback via invokeCallbackContext:." " 0 : 00000297 auipc t0,0x0 Current PC = self codeAddress 4 : 1101 addi sp,sp,-32 reserve 4 stack slots (1 for alignment) 6 : e806 sd ra,16(sp) push Return Address 8 : e416 sd t0,8(sp) push self codeAddress a : e00a sd sp,0(sp) push current Stack Pointer c : 0001C317 auipc t1,0x1c PC+0x1c is address of &entryThunk 10: 00033383 ld t2,0(t1) get &entryThunk in register 14 : 9382 jalr t2 Call entryThunk() 16 : 60c2 ld ra,16(sp) Restore saved Return Address 18 : 6105 addi sp,sp,32 Restore Stack Pointer 20 : 8082 ret Return to Mamma 22 : 0001 noop --keep prefetch happy-- 24 : 0001 noop ... 28: <@entryThunk> " | addrTop wordReversedAddr | "NB: upper & lower instructions swapped" self unsignedLongLongAt: 1 put: 16rE806110100000297. "16r0" self unsignedLongLongAt: 9 put: 16r0001C317E00AE416. "16r8" self unsignedLongLongAt: 17 put: 16r60C2938200033383. "16r10" self unsignedLongLongAt: 25 put: 16r0001000180826105. "16r18" addrTop := self primThunkEntryAddress >> 32. wordReversedAddr := ((self primThunkEntryAddress bitAnd: 16rFFFFFFFF) << 32) bitOr: addrTop. self unsignedLongLongAt: 41 put: wordReversedAddr. self halt. self "self newCCall"! ! ^^^===^^^===^^^===^^^