diff options
| -rw-r--r-- | prog/analysis.go | 19 | ||||
| -rw-r--r-- | prog/target.go | 1 |
2 files changed, 14 insertions, 6 deletions
diff --git a/prog/analysis.go b/prog/analysis.go index 8a7b2730a..0ac0a97b9 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -195,7 +195,10 @@ const ( fallbackSignalErrnoBlocked fallbackSignalCtor fallbackSignalFlags - fallbackCallMask = 0x1fff + // This allows us to have 2M syscalls and leaves 8 bits for 256 errno values. + // Linux currently have 133 errno's. Larger errno values will be truncated, + // which is acceptable for fallback coverage. + fallbackCallMask = 0x1fffff ) func (p *Prog) FallbackSignal(info []CallInfo) { @@ -297,15 +300,19 @@ func DecodeFallbackSignal(s uint32) (callID, errno int) { } func encodeFallbackSignal(typ, id, aux int) uint32 { + checkMaxCallID(id) if typ & ^7 != 0 { panic(fmt.Sprintf("bad fallback signal type %v", typ)) } - if id & ^fallbackCallMask != 0 { - panic(fmt.Sprintf("bad call id in fallback signal %v", id)) - } - return uint32(typ) | uint32(id&fallbackCallMask)<<3 | uint32(aux)<<16 + return uint32(typ) | uint32(id&fallbackCallMask)<<3 | uint32(aux)<<24 } func decodeFallbackSignal(s uint32) (typ, id, aux int) { - return int(s & 7), int((s >> 3) & fallbackCallMask), int(s >> 16) + return int(s & 7), int((s >> 3) & fallbackCallMask), int(s >> 24) +} + +func checkMaxCallID(id int) { + if id & ^fallbackCallMask != 0 { + panic(fmt.Sprintf("too many syscalls, have %v, max supported %v", id, fallbackCallMask+1)) + } } diff --git a/prog/target.go b/prog/target.go index 2cfb25108..cb485c069 100644 --- a/prog/target.go +++ b/prog/target.go @@ -138,6 +138,7 @@ func (target *Target) lazyInit() { } func (target *Target) initTarget() { + checkMaxCallID(len(target.Syscalls) - 1) target.ConstMap = make(map[string]uint64) for _, c := range target.Consts { target.ConstMap[c.Name] = c.Value |
