for any {
var load []uint64
returnAllUndefs := -1
- undefs := ctxt.loader.UndefinedRelocTargets(returnAllUndefs)
- for _, symIdx := range undefs {
- name := ctxt.loader.SymName(symIdx)
- if off := armap[name]; off != 0 && !loaded[off] {
+ undefs, froms := ctxt.loader.UndefinedRelocTargets(returnAllUndefs)
+ for k, symIdx := range undefs {
+ sname := ctxt.loader.SymName(symIdx)
+ if off := armap[sname]; off != 0 && !loaded[off] {
load = append(load, off)
loaded[off] = true
+ if ctxt.Debugvlog > 1 {
+ ctxt.Logf("hostArchive(%s): selecting object at offset %x to resolve %s [%d] reference from %s [%d]\n", name, off, sname, symIdx, ctxt.loader.SymName(froms[k]), froms[k])
+ }
}
}
// If we have any undefined symbols in external
// objects, try to read them from the libgcc file.
any := false
- undefs := ctxt.loader.UndefinedRelocTargets(1)
+ undefs, froms := ctxt.loader.UndefinedRelocTargets(1)
if len(undefs) > 0 {
any = true
+ if ctxt.Debugvlog > 1 {
+ ctxt.Logf("loadlib: first unresolved is %s [%d] from %s [%d]\n",
+ ctxt.loader.SymName(undefs[0]), undefs[0],
+ ctxt.loader.SymName(froms[0]), froms[0])
+ }
}
if any {
if *flagLibGCC == "" {
hostArchive(ctxt, p)
}
any = false
- undefs := ctxt.loader.UndefinedRelocTargets(1)
+ undefs, froms := ctxt.loader.UndefinedRelocTargets(1)
if len(undefs) > 0 {
any = true
+ if ctxt.Debugvlog > 1 {
+ ctxt.Logf("loadWindowsHostArchives: remaining unresolved is %s [%d] from %s [%d]\n",
+ ctxt.loader.SymName(undefs[0]), undefs[0],
+ ctxt.loader.SymName(froms[0]), froms[0])
+ }
}
}
// If needed, create the __CTOR_LIST__ and __DTOR_LIST__
// to true if there is an unresolved reference to the symbol in want[K].
func symbolsAreUnresolved(ctxt *Link, want []string) []bool {
returnAllUndefs := -1
- undefs := ctxt.loader.UndefinedRelocTargets(returnAllUndefs)
+ undefs, _ := ctxt.loader.UndefinedRelocTargets(returnAllUndefs)
seen := make(map[loader.Sym]struct{})
rval := make([]bool, len(want))
wantm := make(map[string]int)
// space, looking for symbols with relocations targeting undefined
// references. The linker's loadlib method uses this to determine if
// there are unresolved references to functions in system libraries
-// (for example, libgcc.a), presumably due to CGO code. Return
-// value is a list of loader.Sym's corresponding to the undefined
-// cross-refs. The "limit" param controls the maximum number of
-// results returned; if "limit" is -1, then all undefs are returned.
-func (l *Loader) UndefinedRelocTargets(limit int) []Sym {
- result := []Sym{}
+// (for example, libgcc.a), presumably due to CGO code. Return value
+// is a pair of lists of loader.Sym's. First list corresponds to the
+// corresponding to the undefined symbols themselves, the second list
+// is the symbol that is making a reference to the undef. The "limit"
+// param controls the maximum number of results returned; if "limit"
+// is -1, then all undefs are returned.
+func (l *Loader) UndefinedRelocTargets(limit int) ([]Sym, []Sym) {
+ result, fromr := []Sym{}, []Sym{}
+outerloop:
for si := Sym(1); si < Sym(len(l.objSyms)); si++ {
relocs := l.Relocs(si)
for ri := 0; ri < relocs.Count(); ri++ {
rs := r.Sym()
if rs != 0 && l.SymType(rs) == sym.SXREF && l.SymName(rs) != ".got" {
result = append(result, rs)
+ fromr = append(fromr, si)
if limit != -1 && len(result) >= limit {
- break
+ break outerloop
}
}
}
}
- return result
+ return result, fromr
}
// AssignTextSymbolOrder populates the Textp slices within each