src/cmd/link/testdata/linkname/push.go
raw| 1 | // Copyright 2024 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // "Push" linknames are ok. |
| 6 | |
| 7 | package main |
| 8 | |
| 9 | import ( |
| 10 | "cmd/link/testdata/linkname/p" |
| 11 | _ "unsafe" |
| 12 | ) |
| 13 | |
| 14 | // Push f1 to p. |
| 15 | // |
| 16 | //go:linkname f1 cmd/link/testdata/linkname/p.f1 |
| 17 | func f1() { f2() } |
| 18 | |
| 19 | // f2 is pushed from p. |
| 20 | // |
| 21 | //go:linkname f2 |
| 22 | func f2() |
| 23 | |
| 24 | func main() { |
| 25 | p.F() |
| 26 | } |