mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: don't link sections not named .o
For many build systems, modular static analysis is most conveniently implemented by saving analysis facts (which are analogous to export data) in an additional section in the archive file, similar to __PKGDEF. See golang.org/x/tools/go/analysis for an overview. Because such sections are not object files, the linker must not attempt to link them. This change causes the linker to skip special sections whose name does not end with .o (and is short enough not to be truncated). Fixes #28429 Change-Id: I830852decf868cb017263308b114f72838032993 Reviewed-on: https://go-review.googlesource.com/c/146297 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
90df37769d
commit
484fc06849
2 changed files with 53 additions and 0 deletions
|
|
@ -856,6 +856,13 @@ func loadobjfile(ctxt *Link, lib *sym.Library) {
|
|||
continue
|
||||
}
|
||||
|
||||
// Skip other special (non-object-file) sections that
|
||||
// build tools may have added. Such sections must have
|
||||
// short names so that the suffix is not truncated.
|
||||
if len(arhdr.name) < 16 && !strings.HasSuffix(arhdr.name, ".o") {
|
||||
continue
|
||||
}
|
||||
|
||||
pname := fmt.Sprintf("%s(%s)", lib.File, arhdr.name)
|
||||
l = atolwhex(arhdr.size)
|
||||
ldobj(ctxt, f, lib, l, pname, lib.File)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue