From ed787856f258f495445c2267b9cf40d7d4ce320d Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Wed, 27 Apr 2016 17:37:54 +0200 Subject: Use readelf to obtain the upper 32 bits of addresses returned by kcov. When executors send coverage data to the manager, they clamp the addresses of covered blocks to 32 bits. Manager uses RestorePC() to restore the original addresses. Previously, RestorePC() assumed that the upper 4 bytes of a kernel code address were 0xffffffff, which is not so on Android. Instead we now parse `readelf -SW vmlinux` output to obtain the upper bytes of PROGBITS sections VMAs in the case those VMAs are non-zero. We assume that the upper 4 bytes are the same for every section. --- tools/syz-execprog/execprog.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/syz-execprog/execprog.go b/tools/syz-execprog/execprog.go index e9246766b..fdba0f258 100644 --- a/tools/syz-execprog/execprog.go +++ b/tools/syz-execprog/execprog.go @@ -110,7 +110,7 @@ func main() { buf := new(bytes.Buffer) binary.Write(buf, binary.LittleEndian, uint64(0xC0BFFFFFFFFFFF64)) for _, pc := range c { - binary.Write(buf, binary.LittleEndian, cover.RestorePC(pc)) + binary.Write(buf, binary.LittleEndian, cover.RestorePC(pc, 0xffffffff)) } err := ioutil.WriteFile(fmt.Sprintf("%v.%v", *flagCoverFile, i), buf.Bytes(), 0660) if err != nil { -- cgit mrf-deployment