| 1 |
|
| 2 |
# Test case for issue 47993, in which the linker crashes |
| 3 |
# on a bad input instead of issuing an error and exiting. |
| 4 |
|
| 5 |
# This test requires external linking, so use cgo as a proxy |
| 6 |
[!cgo] skip |
| 7 |
|
| 8 |
! go build -ldflags='-linkmode=external' . |
| 9 |
! stderr 'panic' |
| 10 |
stderr '^.*undefined symbol in relocation.*' |
| 11 |
|
| 12 |
-- go.mod -- |
| 13 |
|
| 14 |
module issue47993 |
| 15 |
|
| 16 |
go 1.16 |
| 17 |
|
| 18 |
-- main.go -- |
| 19 |
|
| 20 |
package main |
| 21 |
|
| 22 |
type M struct { |
| 23 |
b bool |
| 24 |
} |
| 25 |
|
| 26 |
// Note the body-less func def here. This is what causes the problems. |
| 27 |
func (m *M) run(fp func()) |
| 28 |
|
| 29 |
func doit(m *M) { |
| 30 |
InAsm() |
| 31 |
m.run(func() { |
| 32 |
}) |
| 33 |
} |
| 34 |
|
| 35 |
func main() { |
| 36 |
m := &M{true} |
| 37 |
doit(m) |
| 38 |
} |
| 39 |
|
| 40 |
func InAsm() |
| 41 |
|
| 42 |
-- main.s -- |
| 43 |
|
| 44 |
// Add an assembly function so as to leave open the possibility |
| 45 |
// that body-less functions in Go might be defined in assembly. |
| 46 |
|
| 47 |
// Currently we just need an empty file here. |
| 48 |
|