Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: impossible r.Sym.Cfunc == 1 condition in internal/ld/lib.go #13257
cmd/link has this test in a block of code labeled "Mark every Go-called C function with cfunc=2, recursively.":
As far as I can tell, the only assignments to cmd/link/internal/ld.LSym's Cfunc field are:
neither of which can set it to 1.
(There's a "ptxt.From.Sym.Cfunc = 1" assignment in compile/internal/gc/pgen.go, but that's referring to the Cfunc field of an cmd/internal/obj.LSym.)
I think this is some of the code I was talking about here: https://groups.google.com/d/msg/golang-dev/KK5olmcQ6U4/RdnUHhkVeA8J
@mwhudson Yep, though whereas you were pointing out the code was unneeded after the c2go conversion (until rsc later repurposed it for go:systemstack), I'm pointing out that "cfunc == 1" is (and has always been) impossible within the linker.
Because of an asymmetry between the code responsible for writing cfunc into a Go object file and reading it back in, setting cfunc==1 in the compiler results in setting cfunc==2 in the linker, and there's no other assignments of cfunc=1 within the linker.