From 6e045ca26d969f7465819984668417c9c3b47520 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 28 Oct 2018 19:04:28 +0100 Subject: sys/syz-extract: support missing arch headers The latest Linux kernel misses some arch-specific headers on some archs: asm/a.out.h asm/prctl.h asm/mce.h Support that. --- sys/syz-extract/linux.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sys/syz-extract/linux.go') diff --git a/sys/syz-extract/linux.go b/sys/syz-extract/linux.go index 5c428461c..c5786a87d 100644 --- a/sys/syz-extract/linux.go +++ b/sys/syz-extract/linux.go @@ -43,6 +43,22 @@ func (*linux) prepare(sourcedir string, build bool, arches []string) error { } func (*linux) prepareArch(arch *Arch) error { + // Kernel misses these headers on all arches. + // So we create empty stubs in buildDir/syzkaller and add -IbuildDir/syzkaller + // as the last flag so it won't override real kernel headers. + for _, hdr := range []string{ + "asm/a.out.h", + "asm/prctl.h", + "asm/mce.h", + } { + fullPath := filepath.Join(arch.buildDir, "syzkaller", hdr) + if err := osutil.MkdirAll(filepath.Dir(fullPath)); err != nil { + return err + } + if err := osutil.WriteFile(fullPath, nil); err != nil { + return nil + } + } if !arch.build { return nil } @@ -100,6 +116,7 @@ func (*linux) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint "-I" + sourceDir + "/include/uapi", "-I" + buildDir + "/include/generated/uapi", "-I" + sourceDir, + "-I" + buildDir + "/syzkaller", "-include", sourceDir + "/include/linux/kconfig.h", } args = append(args, arch.target.CFlags...) -- cgit mrf-deployment