-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: cgo_import_dynamic with internal linking provides wrong symbol #61220
Comments
To be clear, the |
I thought their documentation was found at cmd/cgo/doc.go?
I understand they are not supported in user code. However, they are used in the runtime and packages like golang.org/x/sys/unix which may be affected by this issue. |
Currently, on macOS we only support cgo_import_dynamic for functions that are directly called. We don't yet support variables or taking address of a function. CL https://golang.org/cl/501855 may help. (Even with that, it probably only works if the code is written in a specific way.) As @ianlancetaylor said, generally we don't support it in user code. We do handle the use cases that the runtime and syscall packages need. If you believe that is handled incorrectly, please file a specific issue for that. Thanks. |
True. I meant that they aren't publicly documented. The documentation in cmd/cgo/doc.go is in a comment that describes the implementation but is not part of the user visible docs (https://pkg.go.dev/cmd/cgo). |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run the following code with command:
go run -trimpath -gcflags="-std" -ldflags="-linkmode internal" main.go
What did you expect to see?
Program run without issue with output similar to what you get from external linking.
What did you see instead?
Program crashed when dereferencing the pointer.
additional information
If
cgo_import_dynamic
uses the one argument version the linker produces an undefined symbol.Of course, the std flag is only kept in both to limit the number of differences and doesn't affect the output. This issue affects purego#114.
The text was updated successfully, but these errors were encountered: