//
// 1. direct call
// 2. through a reachable interface type
-// 3. reflect.Value.Call, .Method, or reflect.Method.Func
+// 3. reflect.Value.Method (or MethodByName), or reflect.Type.Method
+// (or MethodByName)
//
// The first case is handled by the flood fill, a directly called method
// is marked as reachable.
// as reachable. This is extremely conservative, but easy and correct.
//
// The third case is handled by looking to see if any of:
-// - reflect.Value.Call is reachable
-// - reflect.Value.Method is reachable
-// - reflect.Type.Method or MethodByName is called.
+// - reflect.Value.Method or MethodByName is reachable
+// - reflect.Type.Method or MethodByName is called (through the
+// REFLECTMETHOD attribute marked by the compiler).
// If any of these happen, all bets are off and all exported methods
// of reachable types are marked reachable.
//
d.init()
d.flood()
- callSym := ctxt.Syms.ROLookup("reflect.Value.Call", sym.SymVerABIInternal)
methSym := ctxt.Syms.ROLookup("reflect.Value.Method", sym.SymVerABIInternal)
+ methByNameSym := ctxt.Syms.ROLookup("reflect.Value.MethodByName", sym.SymVerABIInternal)
reflectSeen := false
if ctxt.DynlinkingGo() {
for {
if !reflectSeen {
- if d.reflectMethod || (callSym != nil && callSym.Attr.Reachable()) || (methSym != nil && methSym.Attr.Reachable()) {
+ if d.reflectMethod || (methSym != nil && methSym.Attr.Reachable()) || (methByNameSym != nil && methByNameSym.Attr.Reachable()) {
// Methods might be called via reflection. Give up on
// static analysis, mark all exported methods of
// all reachable types as reachable.