From a94baff95ecc03cf34ff2fbf5d514bb924f54855 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 12 Jan 2018 15:31:35 +0100 Subject: sys/syz-sysgen: don't generate syz_ syscall numbers They don't seem to be used today. --- pkg/compiler/compiler.go | 4 +++- pkg/compiler/consts.go | 30 +----------------------------- 2 files changed, 4 insertions(+), 30 deletions(-) (limited to 'pkg/compiler') diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 98348b0f8..918d25136 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -81,7 +81,9 @@ func Compile(desc *ast.Description, consts map[string]uint64, target *targets.Ta } return &Prog{fileConsts: fileConsts} } - comp.assignSyscallNumbers(consts) + if comp.target.SyscallNumbers { + comp.assignSyscallNumbers(consts) + } comp.patchConsts(consts) comp.check() if comp.errors != 0 { diff --git a/pkg/compiler/consts.go b/pkg/compiler/consts.go index 7f0cb7e38..46a781f39 100644 --- a/pkg/compiler/consts.go +++ b/pkg/compiler/consts.go @@ -127,39 +127,11 @@ func convertConstInfo(infos map[string]*constInfo) map[string]*ConstInfo { // assignSyscallNumbers assigns syscall numbers, discards unsupported syscalls. func (comp *compiler) assignSyscallNumbers(consts map[string]uint64) { - // Pseudo syscalls starting from syz_ are assigned numbers starting from syzbase. - // Note: the numbers must be stable (not depend on file reading order, etc), - // so we have to do it in 2 passes. - const syzbase = 1000000 - syzcalls := make(map[string]bool) for _, decl := range comp.desc.Nodes { c, ok := decl.(*ast.Call) - if !ok { + if !ok || strings.HasPrefix(c.CallName, "syz_") { continue } - if strings.HasPrefix(c.CallName, "syz_") { - syzcalls[c.CallName] = true - } - } - syznr := make(map[string]uint64) - for i, name := range toArray(syzcalls) { - syznr[name] = syzbase + uint64(i) - } - - for _, decl := range comp.desc.Nodes { - c, ok := decl.(*ast.Call) - if !ok { - continue - } - if strings.HasPrefix(c.CallName, "syz_") { - c.NR = syznr[c.CallName] - continue - } - // TODO(dvyukov): we don't need even syz consts in this case. - if !comp.target.SyscallNumbers { - continue - } - // Lookup in consts. str := comp.target.SyscallPrefix + c.CallName nr, ok := consts[str] if ok { -- cgit mrf-deployment