]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: C is gone, remove check for Go calling C
authorDavid Crawshaw <crawshaw@golang.org>
Wed, 2 Mar 2016 15:01:01 +0000 (10:01 -0500)
committerDavid Crawshaw <crawshaw@golang.org>
Wed, 2 Mar 2016 16:34:56 +0000 (16:34 +0000)
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: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/link.go
src/cmd/link/internal/ld/objfile.go
src/cmd/link/internal/ld/pobj.go

index 3112f794c68b5986d642f1270c5752a05dee446b..d14106887bba7c6b48851f547d23510c59e236e3 100644 (file)
@@ -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
index 76db853ef21982693aa58548b58c3e0150d78e7d..beb142e44f6b76edf6441a397e70fd9e4c5b9487 100644 (file)
@@ -43,7 +43,6 @@ type LSym struct {
        Type       int16
        Version    int16
        Dupok      uint8
-       Cfunc      uint8
        External   uint8
        Nosplit    uint8
        Reachable  bool
index 05d18ec4c2bc8b9044d4aeb5928cedebbe5fca06..268d4e12eca01a52d54eb04d872ff5c5aca944fd 100644 (file)
@@ -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 ")
                }
index 9ec14c24ed59161baf44bdd2d831484f99637573..a66843fc11d985d9be421379b0e4e1e0a75bfbb8 100644 (file)
@@ -194,7 +194,6 @@ func Ldmain() {
                mark(Linklookup(Ctxt, "runtime.read_tls_fallback", 0))
        }
 
-       checkgo()
        checkstrdata()
        deadcode()
        callgraph()