strictDupMsgs int // number of strict-dup warning/errors, when FlagStrictDups is enabled
elfsetstring elfsetstringFunc
+
+ SymLookup func(name string, ver int) *sym.Symbol
}
const (
// PropagateLoaderChangesToSymbols is a temporary shim function that
// takes a list of loader.Sym symbols and works to copy their contents
-// and attributes over to a corresponding sym.Symbol. See the
-// PropagateSymbolChangesBackToLoader header comment for more info.
+// and attributes over to a corresponding sym.Symbol. The parameter
+// anonVerReplacement specifies a version number for any new anonymous
+// symbols encountered on the list, when creating sym.Symbols for them
+// (or zero if we don't expect to encounter any new anon symbols). See
+// the PropagateSymbolChangesBackToLoader header comment for more
+// info.
//
// WARNING: this function is brittle and depends heavily on loader
// implementation. A key problem with doing this is that as things
// stand at the moment, some sym.Symbol contents/attributes are
-// populated only when converting from loader.Sym to sym.Symbol
-// in loadlibfull, meaning if we may wipe out some information
-// when copying back.
+// populated only when converting from loader.Sym to sym.Symbol in
+// loadlibfull, meaning we may wipe out some information when copying
+// back.
-func (l *Loader) PropagateLoaderChangesToSymbols(toconvert []Sym, syms *sym.Symbols) []*sym.Symbol {
+func (l *Loader) PropagateLoaderChangesToSymbols(toconvert []Sym, anonVerReplacement int) []*sym.Symbol {
result := []*sym.Symbol{}
relocfixup := []Sym{}
// sym.Symbols are created.
// First pass, symbol creation and symbol data fixup.
- anonVerReplacement := syms.IncVersion()
rslice := []Reloc{}
for _, cand := range toconvert {
sv := l.SymVersion(cand)
st := l.SymType(cand)
if sv < 0 {
+ if anonVerReplacement == 0 {
+ panic("expected valid anon version replacement")
+ }
sv = anonVerReplacement
}
// or may not be in the name lookup map.
} else {
isnew = true
- s = syms.Lookup(sn, sv)
+ s = l.SymLookup(sn, sv)
}
}
result = append(result, s)
}
// Provide lookup functions for sym.Symbols.
- syms.Lookup = func(name string, ver int) *sym.Symbol {
+ l.SymLookup = func(name string, ver int) *sym.Symbol {
i := l.LookupOrCreateSym(name, ver)
if s := l.Syms[i]; s != nil {
return s
syms.Allsym = append(syms.Allsym, s) // XXX see above
return s
}
+ syms.Lookup = l.SymLookup
syms.ROLookup = func(name string, ver int) *sym.Symbol {
i := l.Lookup(name, ver)
return l.Syms[i]