aboutsummaryrefslogtreecommitdiffstats
path: root/sys/syz-extract/trusty.go
blob: cb031734a568532892aaef757cc04138aa2bb8ec (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
// Copyright 2018 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 (
	"path/filepath"
	"strings"

	"github.com/google/syzkaller/pkg/compiler"
)

type trusty struct{}

func (*trusty) prepare(sourcedir string, build bool, arches []*Arch) error {
	return nil
}

func (*trusty) prepareArch(arch *Arch) error {
	return nil
}

func (*trusty) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) {
	dir := arch.sourceDir
	args := []string{
		"-fmessage-length=0",
		"-I", filepath.Join(dir, "external", "lk", "include", "shared"),
		"-I", filepath.Join(dir, "trusty", "user", "base", "include"),
	}
	for _, incdir := range info.Incdirs {
		args = append(args, "-I"+filepath.Join(dir, incdir))
	}
	if arch.includeDirs != "" {
		for _, dir := range strings.Split(arch.includeDirs, ",") {
			args = append(args, "-I"+dir)
		}
	}
	params := &extractParams{
		DeclarePrintf: true,
		TargetEndian:  arch.target.HostEndian,
	}
	return extract(info, "gcc", args, params)
}