cmd/link: refactor addlib

* extract pkgname() and findlib() from the function for #18190.
* rename const pkgname to const pkgdef to avoid confliction.

Change-Id: Ie62509bfbddcf19cf92b5b12b598679a069e6e74
Reviewed-on: https://go-review.googlesource.com/59417
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Hiroshi Ioka 2017-08-28 15:10:25 +09:00 committed by Ian Lance Taylor
parent 738acbc2f0
commit 4eca0898ec
2 changed files with 23 additions and 10 deletions

View file

@ -242,7 +242,7 @@ func (w *outBuf) Offset() int64 {
var coutbuf outBuf
const pkgname = "__.PKGDEF"
const pkgdef = "__.PKGDEF"
var (
// Set if we see an object compiled by the host compiler that is not
@ -811,7 +811,7 @@ func objfile(ctxt *Link, lib *Library) {
goto out
}
if !strings.HasPrefix(arhdr.name, pkgname) {
if !strings.HasPrefix(arhdr.name, pkgdef) {
Errorf(nil, "%s: cannot find package header", lib.File)
goto out
}