diff options
| author | Patrick Meyer <meyerpatrick@google.com> | 2021-05-06 23:08:43 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-05-20 13:29:54 +0200 |
| commit | ac040bb3def51ecf81966d7801521b5a59fac0db (patch) | |
| tree | c0196e1c3266495243b0c83759d9c89b34a8fb8a /sys/syz-extract/darwin.go | |
| parent | ebc32b110a66a9bebfced77df99dcd3001489158 (diff) | |
sys/syz-extract: initial darwin support
Diffstat (limited to 'sys/syz-extract/darwin.go')
| -rw-r--r-- | sys/syz-extract/darwin.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/syz-extract/darwin.go b/sys/syz-extract/darwin.go new file mode 100644 index 000000000..c6d694696 --- /dev/null +++ b/sys/syz-extract/darwin.go @@ -0,0 +1,51 @@ +// Copyright 2021 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "path/filepath" + "strings" + + "github.com/google/syzkaller/pkg/compiler" +) + +type darwin struct{} + +func (*darwin) prepare(sourcedir string, build bool, arches []*Arch) error { + if sourcedir == "" { + return fmt.Errorf("provide path to kernel checkout via -sourcedir flag (or make extract SOURCEDIR)") + } + return nil +} + +func (*darwin) prepareArch(arch *Arch) error { + return nil +} + +func (*darwin) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) { + args := []string{ + "-nostdinc", + "-I", filepath.Join(arch.sourceDir, "bsd"), + "-I", filepath.Join(arch.sourceDir, "bsd", "sys"), + "-I", filepath.Join(arch.sourceDir, "osfmk"), + } + for _, incdir := range info.Incdirs { + args = append(args, "-I"+filepath.Join(arch.sourceDir, incdir)) + } + fmt.Printf("dirs: %v", arch.includeDirs) + if arch.includeDirs != "" { + for _, dir := range strings.Split(arch.includeDirs, ",") { + args = append(args, "-I"+dir) + } + } + // TODO(HerrSpace): investigate use of bsd/kern/syscalls.master and + // osfmk/mach/mach_traps.h here. + params := &extractParams{ + AddSource: "#include <sys/syscall.h>", + DeclarePrintf: true, + TargetEndian: arch.target.HostEndian, + } + return extract(info, "clang", args, params) +} |
