The package references recorded in the object file, which are
obtained from the compiler, are escaped. We should also use the
escaped package paths in the linker for resolving package
references.
Change-Id: I42eb12df6ff24330e6dc7bed1dc8224bb3b8a106
Reviewed-on: https://go-review.googlesource.com/c/go/+/200158
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
if _, ok := l.start[r]; ok {
panic("already added")
}
+ pkg = objabi.PathToPrefix(pkg) // the object file contains escaped package path
if _, ok := l.objByPkg[pkg]; !ok {
l.objByPkg[pkg] = r
}
rr = r
default:
pkg := r.Pkg(int(p))
- rr = l.objByPkg[pkg]
+ var ok bool
+ rr, ok = l.objByPkg[pkg]
+ if !ok {
+ log.Fatalf("reference of nonexisted package %s, from %v", pkg, r.unit.Lib)
+ }
}
return l.ToGlobal(rr, int(s.SymIdx))
}