syzkaller/sys/syz-extract/trusty.go
Marco Vanotti 6aad7497a8 sys/syz-extract: Add "DefineGlibcUse" flag.
Instead of defining the __GLIBC_USE macro on every OS, we are just
defining it based on a parameter. That parameter is set to false for all
OSs except for fuchsia.
2019-07-16 16:34:29 +02:00

44 lines
1.1 KiB
Go

// 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 (
"fmt"
"path/filepath"
"strings"
"github.com/google/syzkaller/pkg/compiler"
)
type trusty struct{}
func (*trusty) prepare(sourcedir string, build bool, arches []string) error {
if sourcedir == "" {
return fmt.Errorf("provide path to kernel checkout via -sourcedir flag (or make extract SOURCEDIR)")
}
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)
}
}
return extract(info, "gcc", args, "", true, false)
}