Commit 8fff2525 authored by Rémy Oudompheng's avatar Rémy Oudompheng

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
parent 4ba27df6
......@@ -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);
}
}
......
// 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 }
// 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 }
// 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() {
}
// 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment