@@ -36,6 +36,12 @@ TEXT runtime·rt0_go(SB),NOSPLIT,$0
3636 MOVD _cgo_init(SB) , R12
3737 CMP R0 , R12
3838 BEQ nocgo
39+ #ifdef GOARCH_ppc64
40+ // ppc64 use elf ABI v1. we must get the real entry address from
41+ // first slot of the function descriptor before call .
42+ MOVD 8 ( R12 ) , R2
43+ MOVD ( R12 ) , R12
44+ #endif
3945 MOVD R12 , CTR // r12 = "global function entry point"
4046 MOVD R13 , R5 // arg 2 : TLS base pointer
4147 MOVD $ setg_gcc<>(SB) , R4 // arg 1 : setg
564570 MOVD R0 , 0 (R1) // clear back chain pointer (TODO can we give it real back trace information?)
565571 // This is a "global call" , so put the global entry point in r12
566572 MOVD R3 , R12
573+
574+ #ifdef GOARCH_ppc64
575+ // ppc64 use elf ABI v1. we must get the real entry address from
576+ // first slot of the function descriptor before call .
577+ #ifndef GOOS_aix
578+ // aix just passes the function pointer for the moment , see golang.org/ cl / 146898 for details.
579+ MOVD 8 ( R12 ) , R2
580+ MOVD ( R12 ) , R12
581+ #endif
582+ #endif
567583 MOVD R12 , CTR
568584 MOVD R4 , R3 // arg in r3
569585 BL (CTR)
@@ -722,9 +738,20 @@ TEXT runtime·setg(SB), NOSPLIT, $0-8
722738 BL runtime·save_g(SB)
723739 RET
724740
741+ #ifdef GOARCH_ppc64
742+ TEXT setg_gcc<>(SB) , NOSPLIT|NOFRAME , $ 0 - 0
743+ DWORD $ _setg_gcc<>(SB)
744+ DWORD $ 0
745+ DWORD $ 0
746+ #endif
747+
725748// void setg_gcc(G * ) ; set g in C TLS.
726749// Must obey the gcc calling convention.
750+ #ifdef GOARCH_ppc64le
727751TEXT setg_gcc<>(SB) , NOSPLIT|NOFRAME , $ 0 - 0
752+ #else
753+ TEXT _setg_gcc<>(SB) , NOSPLIT|NOFRAME , $ 0 - 0
754+ #endif
728755 // The standard prologue clobbers R31 , which is callee - save in
729756 // the C ABI , so we have to use $ - 8 - 0 and save LR ourselves.
730757 MOVD LR , R4
0 commit comments