cmd/link: don't assume all sections but __PKGDEF are object files #28429
Labels
Comments
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 |
Change https://golang.org/cl/146297 mentions this issue: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 proposestrings.HasSuffix(section.Name, ".o")
. Do we ever care about object files not called *.o?The text was updated successfully, but these errors were encountered: