From e54e9781a4e043b3140b0c908ba4f4e469fd317e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 26 Apr 2020 14:14:14 +0200 Subject: prog: remove Dir from Type Having Dir is Type is handy, but forces us to duplicate lots of types. E.g. if a struct is referenced as both in and out, then we need to have 2 copies and 2 copies of structs/types it includes. If also prevents us from having the struct type as struct identity (because we can have up to 3 of them). Revert to the old way we used to do it: propagate Dir as we walk syscall arguments. This moves lots of dir passing from pkg/compiler to prog package. Now Arg contains the dir, so once we build the tree, we can use dirs as before. Reduces size of sys/linux/gen/amd64.go from 6058336 to 5661150 (-6.6%). Update #1580 --- sys/linux/init_iptables.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sys/linux/init_iptables.go') diff --git a/sys/linux/init_iptables.go b/sys/linux/init_iptables.go index a1adf3fb0..7e96662fb 100644 --- a/sys/linux/init_iptables.go +++ b/sys/linux/init_iptables.go @@ -9,17 +9,17 @@ import ( "github.com/google/syzkaller/prog" ) -func (arch *arch) generateIptables(g *prog.Gen, typ prog.Type, old prog.Arg) ( +func (arch *arch) generateIptables(g *prog.Gen, typ prog.Type, dir prog.Dir, old prog.Arg) ( arg prog.Arg, calls []*prog.Call) { - return arch.generateNetfilterTable(g, typ, old, true, 5) + return arch.generateNetfilterTable(g, typ, dir, old, true, 5) } -func (arch *arch) generateArptables(g *prog.Gen, typ prog.Type, old prog.Arg) ( +func (arch *arch) generateArptables(g *prog.Gen, typ prog.Type, dir prog.Dir, old prog.Arg) ( arg prog.Arg, calls []*prog.Call) { - return arch.generateNetfilterTable(g, typ, old, false, 3) + return arch.generateNetfilterTable(g, typ, dir, old, false, 3) } -func (arch *arch) generateNetfilterTable(g *prog.Gen, typ prog.Type, old prog.Arg, +func (arch *arch) generateNetfilterTable(g *prog.Gen, typ prog.Type, dir prog.Dir, old prog.Arg, hasUnion bool, hookCount int) (arg prog.Arg, calls []*prog.Call) { const ( hookStart = 4 @@ -27,7 +27,7 @@ func (arch *arch) generateNetfilterTable(g *prog.Gen, typ prog.Type, old prog.Ar unused = uint64(^uint32(0)) ) if old == nil { - arg = g.GenerateSpecialArg(typ, &calls) + arg = g.GenerateSpecialArg(typ, dir, &calls) } else { // TODO(dvyukov): try to restore original hook order after mutation // instead of assigning brand new offsets. @@ -106,10 +106,10 @@ func (arch *arch) generateNetfilterTable(g *prog.Gen, typ prog.Type, old prog.Ar return } -func (arch *arch) generateEbtables(g *prog.Gen, typ prog.Type, old prog.Arg) ( +func (arch *arch) generateEbtables(g *prog.Gen, typ prog.Type, dir prog.Dir, old prog.Arg) ( arg prog.Arg, calls []*prog.Call) { if old == nil { - arg = g.GenerateSpecialArg(typ, &calls) + arg = g.GenerateSpecialArg(typ, dir, &calls) } else { // TODO(dvyukov): try to restore original hook order after mutation // instead of assigning brand new offsets. -- cgit mrf-deployment