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: don't assume all sections but __PKGDEF are object files #28429

Closed
alandonovan opened this issue Oct 26, 2018 · 2 comments
Closed

cmd/link: don't assume all sections but __PKGDEF are object files #28429

alandonovan opened this issue Oct 26, 2018 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@alandonovan
Copy link
Contributor

I'm currently implementing support for modular static analysis in Google's build system. Unlike "go vet", which saves analysis facts in a .vetx file known to the build system, I'm taking the approach of storing the facts in an extra section in the .a files produced by cmd/pack, as this requires no changes to the build system. Analysis facts are thus, fittingly, treated much like type checker facts, which are recorded in the __PKGDEF section. Unfortunately, cmd/link blindly assumes that all sections not named __PKGDEF are object files, and tries to link them.

cmd/link should use a better heuristic for deciding what sections to link than section.Name != "__PKGDEF"; I propose strings.HasSuffix(section.Name, ".o"). Do we ever care about object files not called *.o?

@alandonovan
Copy link
Contributor Author

alandonovan commented Oct 26, 2018

Answering my own question: the name field is only 16 bytes so we can't rely on the file name suffix being untruncated, and thus the heuristic will have to rely on the prefix, or apply only to names so short that they are untruncated. So, how about the following predicate for matching non-linkable sections len(sectionName) < 16 && !strings strings.HasSuffix(sectionName, ".o")?

@katiehockman katiehockman added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 29, 2018
@gopherbot
Copy link

Change https://golang.org/cl/146297 mentions this issue: cmd/link: don't link sections not named .o

@golang golang locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants