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

gobin: rework go:linkname abuse #1350

Open
hdonnay opened this issue May 31, 2024 · 1 comment
Open

gobin: rework go:linkname abuse #1350

hdonnay opened this issue May 31, 2024 · 1 comment

Comments

@hdonnay
Copy link
Member

hdonnay commented May 31, 2024

See: golang/go#67401

The gobin package currently uses this to distinguish between "error reading go dependency information" and "not a go binary". If there's some other feature of go-produced ELF or PE binaries we could use as a rule to distinguish them, that would let us (and go upstream) remove this.

@hdonnay
Copy link
Member Author

hdonnay commented Jun 5, 2024

Poked at this a bit, and there's no good way to get this information without effectively duplicating the stdlib debug/buildinfo package. Detecting any Go-specific feature of an executable means that the first 3/4 of buildinfo.Read needs to be duplicated. At that point, the io.ReaderAt can be handed off to buildinfo.Read to have most of the work duplicated, or we can duplicate the section-decoding logic and call runtime/debug.ParseBuildInfo, thus just re-implementing it. Just exporting the error seems like a tiny change that's easily forwards-compatible if documented to be used with errors.Is.

Opened golang/go#67845 to campaign for exporting the value (or sentinel).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants
@hdonnay and others