From 75a7c5e2d1f09a4a58e7e1f1f4ef0b0f55a33413 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 19 Feb 2018 19:35:04 +0100 Subject: prog: rework address allocation 1. mmap all memory always, without explicit mmap calls in the program. This makes lots of things much easier and removes lots of code. Makes mmap not a special syscall and allows to fuzz without mmap enabled. 2. Change address assignment algorithm. Current algorithm allocates unmapped addresses too frequently and allows collisions between arguments of a single syscall. The new algorithm analyzes actual allocations in the program and places new arguments at unused locations. --- prog/encodingexec.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'prog/encodingexec.go') diff --git a/prog/encodingexec.go b/prog/encodingexec.go index ae885d3b1..27fa63350 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -194,16 +194,10 @@ func (p *Prog) SerializeForExec(buffer []byte) (int, error) { } func (target *Target) PhysicalAddr(arg *PointerArg) uint64 { - if arg.Res == nil && arg.PagesNum == 0 { + if arg.IsNull() { return 0 } - addr := arg.PageIndex*target.PageSize + target.DataOffset - if arg.PageOffset >= 0 { - addr += uint64(arg.PageOffset) - } else { - addr += target.PageSize - uint64(-arg.PageOffset) - } - return addr + return target.DataOffset + arg.Address } type execContext struct { -- cgit mrf-deployment