Commit 1012892f authored by David Crawshaw's avatar David Crawshaw

cmd/link: C is gone, remove check for Go calling C

It looks like the compiler still uses the Cfunc flag for functions
marked as //go:systemstack, but if I'm reading this right, that
doesn't apply here and the linker no longer needs Cfunc.

Change-Id: I63b9192c2f52f41401263c29dc8dfd8be8a901a1
Reviewed-on: https://go-review.googlesource.com/20105
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 8b360d5f
......@@ -2119,63 +2119,6 @@ func Diag(format string, args ...interface{}) {
}
}
func checkgo() {
if Debug['C'] == 0 {
return
}
// TODO(rsc,khr): Eventually we want to get to no Go-called C functions at all,
// which would simplify this logic quite a bit.
// Mark every Go-called C function with cfunc=2, recursively.
var changed int
var i int
var r *Reloc
var s *LSym
for {
changed = 0
for s = Ctxt.Textp; s != nil; s = s.Next {
if s.Cfunc == 0 || (s.Cfunc == 2 && s.Nosplit != 0) {
for i = 0; i < len(s.R); i++ {
r = &s.R[i]
if r.Sym == nil {
continue
}
if (r.Type == obj.R_CALL || r.Type == obj.R_CALLARM) && r.Sym.Type == obj.STEXT {
if r.Sym.Cfunc == 1 {
changed = 1
r.Sym.Cfunc = 2
}
}
}
}
}
if changed == 0 {
break
}
}
// Complain about Go-called C functions that can split the stack
// (that can be preempted for garbage collection or trigger a stack copy).
for s := Ctxt.Textp; s != nil; s = s.Next {
if s.Cfunc == 0 || (s.Cfunc == 2 && s.Nosplit != 0) {
for i = 0; i < len(s.R); i++ {
r = &s.R[i]
if r.Sym == nil {
continue
}
if (r.Type == obj.R_CALL || r.Type == obj.R_CALLARM) && r.Sym.Type == obj.STEXT {
if s.Cfunc == 0 && r.Sym.Cfunc == 2 && r.Sym.Nosplit == 0 {
fmt.Printf("Go %s calls C %s\n", s.Name, r.Sym.Name)
} else if s.Cfunc == 2 && s.Nosplit != 0 && r.Sym.Nosplit == 0 {
fmt.Printf("Go calls C %s calls %s\n", s.Name, r.Sym.Name)
}
}
}
}
}
}
func Rnd(v int64, r int64) int64 {
if r <= 0 {
return v
......
......@@ -43,7 +43,6 @@ type LSym struct {
Type int16
Version int16
Dupok uint8
Cfunc uint8
External uint8
Nosplit uint8
Reachable bool
......
......@@ -265,7 +265,6 @@ overwrite:
s.Nosplit = rduint8(f)
v := rdint(f)
s.Leaf = uint8(v & 1)
s.Cfunc = uint8(v & 2)
n := rdint(f)
var a *Auto
for i := 0; i < n; i++ {
......@@ -331,9 +330,6 @@ overwrite:
if s.Dupok != 0 {
fmt.Fprintf(ctxt.Bso, "dupok ")
}
if s.Cfunc != 0 {
fmt.Fprintf(ctxt.Bso, "cfunc ")
}
if s.Nosplit != 0 {
fmt.Fprintf(ctxt.Bso, "nosplit ")
}
......
......@@ -194,7 +194,6 @@ func Ldmain() {
mark(Linklookup(Ctxt, "runtime.read_tls_fallback", 0))
}
checkgo()
checkstrdata()
deadcode()
callgraph()
......
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