...

Text file src/cmd/go/testdata/script/link_external_undef.txt

Documentation: cmd/go/testdata/script

     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'
    10stderr '^.*undefined symbol in relocation.*'
    11
    12-- go.mod --
    13
    14module issue47993
    15
    16go 1.16
    17
    18-- main.go --
    19
    20package main
    21
    22type M struct {
    23	b bool
    24}
    25
    26// Note the body-less func def here. This is what causes the problems.
    27func (m *M) run(fp func())
    28
    29func doit(m *M) {
    30        InAsm()
    31	m.run(func() {
    32	})
    33}
    34
    35func main() {
    36     m := &M{true}
    37     doit(m)
    38}
    39
    40func 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

View as plain text