summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/link_external_undef.txt
blob: f3205054599695c5d4eb8266f1287878dec84fd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Test case for issue 47993, in which the linker crashes
# on a bad input instead of issuing an error and exiting.

# This test requires external linking, so use cgo as a proxy 
[!cgo] skip

! go build -ldflags='-linkmode=external' .
! stderr 'panic'
stderr '^.*undefined symbol in relocation.*'

-- go.mod --

module issue47993

go 1.16

-- main.go --

package main

type M struct {
	b bool
}

// Note the body-less func def here. This is what causes the problems.
func (m *M) run(fp func())

func doit(m *M) {
        InAsm()
	m.run(func() {
	})
}

func main() {
     m := &M{true}
     doit(m)
}

func InAsm() 

-- main.s --

// Add an assembly function so as to leave open the possibility
// that body-less functions in Go might be defined in assembly.

// Currently we just need an empty file here.