import (
"bufio"
+ "cmd/internal/obj"
"cmd/internal/objabi"
"cmd/internal/sys"
"cmd/link/internal/sym"
k := unresolvedSymKey{from: s, to: r.Sym}
if !ctxt.unresolvedSymSet[k] {
ctxt.unresolvedSymSet[k] = true
+
+ // Try to find symbol under another ABI.
+ var reqABI, haveABI obj.ABI
+ haveABI = ^obj.ABI(0)
+ for abi := obj.ABI(0); abi < obj.ABICount; abi++ {
+ v := sym.ABIToVersion(abi)
+ if v == -1 {
+ continue
+ }
+ if v == int(r.Sym.Version) {
+ reqABI = abi
+ } else if ctxt.Syms.ROLookup(r.Sym.Name, v) != nil {
+ haveABI = abi
+ }
+ }
+
// Give a special error message for main symbol (see #24809).
if r.Sym.Name == "main.main" {
Errorf(s, "function main is undeclared in the main package")
+ } else if haveABI != ^obj.ABI(0) {
+ Errorf(s, "relocation target %s not defined for %s (but is defined for %s)", r.Sym.Name, reqABI, haveABI)
} else {
Errorf(s, "relocation target %s not defined", r.Sym.Name)
}