Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: don't assume all sections but __PKGDEF are object files #28429
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
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