Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: impossible r.Sym.Cfunc == 1 condition in internal/ld/lib.go #13257

Closed
mdempsky opened this issue Nov 16, 2015 · 5 comments
Closed

cmd/link: impossible r.Sym.Cfunc == 1 condition in internal/ld/lib.go #13257

mdempsky opened this issue Nov 16, 2015 · 5 comments

Comments

@mdempsky
Copy link
Member

cmd/link has this test in a block of code labeled "Mark every Go-called C function with cfunc=2, recursively.":

internal/ld/lib.go:2096:                                                if r.Sym.Cfunc == 1 {

As far as I can tell, the only assignments to cmd/link/internal/ld.LSym's Cfunc field are:

internal/ld/lib.go:2098:                                                        r.Sym.Cfunc = 2
internal/ld/objfile.go:268:             s.Cfunc = uint8(v & 2)

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.)

FWIW, I tracked this check back to https://golang.org/cl/135170044 (0bb14d7), and it appears to have been impossible even then (though less obvious since cmd/cc and cmd/ld used the same LSym type).

CC @rsc @randall77

@mwhudson
Copy link
Contributor

I think this is some of the code I was talking about here: https://groups.google.com/d/msg/golang-dev/KK5olmcQ6U4/RdnUHhkVeA8J

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Nov 16, 2015
@mdempsky
Copy link
Member Author

@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.

@mwhudson
Copy link
Contributor

Ah OK :-)

@rsc
Copy link
Contributor

rsc commented Nov 17, 2015

Yes, func checkgo can be deleted.

@ALTree
Copy link
Member

ALTree commented Jan 8, 2017

Fixed by 1012892.

@ALTree ALTree closed this as completed Jan 8, 2017
@golang golang locked and limited conversation to collaborators Jan 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants