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

Comments

Projects
None yet
6 participants
@mdempsky
Copy link
Member

commented Nov 16, 2015

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

This comment has been minimized.

Copy link
Contributor

commented Nov 16, 2015

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

This comment has been minimized.

Copy link
Member Author

commented Nov 16, 2015

@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

This comment has been minimized.

Copy link
Contributor

commented Nov 16, 2015

Ah OK :-)

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 17, 2015

Yes, func checkgo can be deleted.

@ALTree

This comment has been minimized.

Copy link
Member

commented Jan 8, 2017

Fixed by 1012892.

@ALTree ALTree closed this 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.
You can’t perform that action at this time.