aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encoding.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-30 14:17:47 -0700
committerDmitry Vyukov <dvyukov@google.com>2018-08-30 21:45:03 -0700
commite8dd2c6713522707b3b89884eb95601cdf9bc9be (patch)
tree9df12a938af90c06794ec9f60920d59330766ed1 /prog/encoding.go
parent6ba5fe3e62880ddf8aeec68ab44eabaa8bc148b8 (diff)
prog: add concept of "special pointers"
Currently we only generate either valid user-space pointers or NULL. Extend NULL to a set of special pointers that we will use in programs. All targets now contain 3 special values: - NULL - 0xfffffffffffffff (invalid kernel pointer) - 0x999999999999999 (non-canonical address) Each target can add additional special pointers on top of this. Also generate NULL/special pointers for non-opt ptr's. This restriction was always too restrictive. We may want to generate them with very low probability, but we do want to generate them. Also change pointers to NULL/special during mutation (but still not in the opposite direction).
Diffstat (limited to 'prog/encoding.go')
-rw-r--r--prog/encoding.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/prog/encoding.go b/prog/encoding.go
index 92e2c47f0..c968fa0b7 100644
--- a/prog/encoding.go
+++ b/prog/encoding.go
@@ -85,8 +85,8 @@ func (a *ConstArg) serialize(ctx *serializer) {
}
func (a *PointerArg) serialize(ctx *serializer) {
- if a.IsNull() {
- ctx.printf("0x0")
+ if a.IsSpecial() {
+ ctx.printf("0x%x", a.Address)
return
}
target := ctx.target
@@ -345,10 +345,8 @@ func (target *Target) parseArgInt(typ Type, p *parser) (Arg, error) {
case *ResourceType:
return MakeResultArg(typ, nil, v), nil
case *PtrType, *VmaType:
- if typ.Optional() {
- return MakeNullPointerArg(typ), nil
- }
- return typ.makeDefaultArg(), nil
+ index := -v % uint64(len(target.SpecialPointers))
+ return MakeSpecialPointerArg(typ, index), nil
default:
eatExcessive(p, true)
return typ.makeDefaultArg(), nil