This is the closest I get, I am out of ideas. Don't know why it runs but doesn't update the string.
go run . test [116 101 115 116 0 0 0 0 0 0] 4 0 0 #include <stdio.h> #include <string.h> int hello(char *s) { char c[80]; strcpy (c, s); sprintf(s, "hello %s", c); printf("------\n"); return 0; } #include "textflag.h" TEXT ·hello_trampoline(SB),NOSPLIT,$0-0 JMP hello_c(SB) package main import ( "fmt" "unsafe" "golang.org/x/sys/unix" ) //go:linkname hello_t hello_c //go:cgo_import_dynamic hello_c hello "./c/hello.dylib" //go:nosplit func hello_t(s unsafe.Pointer) (uintptr, uintptr, unix.Errno) { return unix.Syscall(funcPC(hello_trampoline), uintptr(s), 0, 0) } func hello_trampoline() //go:nosplit func funcPC(f func()) uintptr { return **(**uintptr)(unsafe.Pointer(&f)) } func main() { b := make([]byte, 10, 10) copy(b, []byte("test")) r1, r2, err := hello_t(unsafe.Pointer(&b[0])) fmt.Printf("%s %v %d %d %d\n", b, b, r1, r2, err) } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/68003925-1a44-4b7c-8cec-21849784bee5%40googlegroups.com.