mirror of
https://github.com/golang/go
synced 2024-10-14 11:53:56 +00:00
cmd/gc: add space to export data to match linker expectations
The linker split PKGDEF into (prefix, name, def) pairs, and defines def to begin after a space following the identifier. This is totally wrong for the following export data: func "".FunctionName() var SomethingCompletelyUnrelated int The linker would parse name=`"".FunctionName()\n\tvar` def=`SomethingCompletelyUnrelated int` since there is no space after FunctionName. R=minux.ma, rsc CC=golang-dev https://golang.org/cl/7068051
This commit is contained in:
parent
4ba27df69c
commit
8fff2525cb
|
@ -220,10 +220,11 @@ dumpexportvar(Sym *s)
|
|||
// currently that can leave unresolved ONONAMEs in import-dot-ed packages in the wrong package
|
||||
if(debug['l'] < 2)
|
||||
typecheckinl(n);
|
||||
Bprint(bout, "\tfunc %#S%#hT { %#H }\n", s, t, n->inl);
|
||||
// NOTE: The space after %#S here is necessary for ld's export data parser.
|
||||
Bprint(bout, "\tfunc %#S %#hT { %#H }\n", s, t, n->inl);
|
||||
reexportdeplist(n->inl);
|
||||
} else
|
||||
Bprint(bout, "\tfunc %#S%#hT\n", s, t);
|
||||
Bprint(bout, "\tfunc %#S %#hT\n", s, t);
|
||||
} else
|
||||
Bprint(bout, "\tvar %#S %#T\n", s, t);
|
||||
}
|
||||
|
@ -282,10 +283,10 @@ dumpexporttype(Type *t)
|
|||
// currently that can leave unresolved ONONAMEs in import-dot-ed packages in the wrong package
|
||||
if(debug['l'] < 2)
|
||||
typecheckinl(f->type->nname);
|
||||
Bprint(bout, "\tfunc (%#T) %#hhS%#hT { %#H }\n", getthisx(f->type)->type, f->sym, f->type, f->type->nname->inl);
|
||||
Bprint(bout, "\tfunc (%#T) %#hhS %#hT { %#H }\n", getthisx(f->type)->type, f->sym, f->type, f->type->nname->inl);
|
||||
reexportdeplist(f->type->nname->inl);
|
||||
} else
|
||||
Bprint(bout, "\tfunc (%#T) %#hhS%#hT\n", getthisx(f->type)->type, f->sym, f->type);
|
||||
Bprint(bout, "\tfunc (%#T) %#hhS %#hT\n", getthisx(f->type)->type, f->sym, f->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
17
test/fixedbugs/bug472.dir/p1.go
Normal file
17
test/fixedbugs/bug472.dir/p1.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p1
|
||||
|
||||
import "runtime"
|
||||
|
||||
func E() func() int { return runtime.NumCPU }
|
||||
|
||||
func F() func() { return runtime.Gosched }
|
||||
|
||||
func G() func() string { return runtime.GOROOT }
|
||||
|
||||
func H() func() { return runtime.GC }
|
||||
|
||||
func I() func() string { return runtime.Version }
|
17
test/fixedbugs/bug472.dir/p2.go
Normal file
17
test/fixedbugs/bug472.dir/p2.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p2
|
||||
|
||||
import "runtime"
|
||||
|
||||
func E() func() int { return runtime.NumCPU }
|
||||
|
||||
func F() func() { return runtime.GC }
|
||||
|
||||
func G() func() string { return runtime.GOROOT }
|
||||
|
||||
func H() func() { return runtime.Gosched }
|
||||
|
||||
func I() func() string { return runtime.Version }
|
13
test/fixedbugs/bug472.dir/z.go
Normal file
13
test/fixedbugs/bug472.dir/z.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "./p1"
|
||||
_ "./p2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
}
|
10
test/fixedbugs/bug472.go
Normal file
10
test/fixedbugs/bug472.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
// rundir
|
||||
|
||||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Linker would incorrectly parse export data and think
|
||||
// definitions are inconsistent.
|
||||
|
||||
package ignored
|
Loading…
Reference in a new issue