aboutsummaryrefslogtreecommitdiffstats
path: root/sys/syz-extract/darwin.go
blob: 68322be0175fdf7182bb329a95079dbfff65f6b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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 {
	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",
		"-DPRIVATE",
		"-DPF",
		"-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)
}