...
1# Tests that the linker implements the PPC64 ELFv2 ABI
2# register save and restore functions as defined in
3# section 2.3.3.1 of the PPC64 ELFv2 ABI when linking
4# external objects most likely compiled with gcc's
5# -Os option.
6#
7# Verifies golang.org/issue/52366 for linux/ppc64le
8[!GOOS:linux] skip
9[!compiler:gc] skip
10[!cgo] skip
11[!GOARCH:ppc64le] skip
12
13go build -ldflags='-linkmode=internal'
14exec ./abitest
15stdout success
16
17go build -buildmode=pie -o abitest.pie -ldflags='-linkmode=internal'
18exec ./abitest.pie
19stdout success
20
21-- go.mod --
22module abitest
23
24-- abitest.go --
25package main
26
27/*
28#cgo CFLAGS: -Os
29
30int foo_fpr() {
31 asm volatile("":::"fr31","fr30","fr29","fr28");
32}
33int foo_gpr0() {
34 asm volatile("":::"r30","r29","r28");
35}
36int foo_gpr1() {
37 asm volatile("":::"fr31", "fr30","fr29","fr28","r30","r29","r28");
38}
39int foo_vr() {
40 asm volatile("":::"v31","v30","v29","v28");
41}
42*/
43import "C"
44
45import "fmt"
46
47func main() {
48 C.foo_fpr()
49 C.foo_gpr0()
50 C.foo_gpr1()
51 C.foo_vr()
52 fmt.Println("success")
53}
View as plain text