github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/syz-extract/trusty.go (about)

     1  // Copyright 2018 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package main
     5  
     6  import (
     7  	"path/filepath"
     8  	"strings"
     9  
    10  	"github.com/google/syzkaller/pkg/compiler"
    11  )
    12  
    13  type trusty struct{}
    14  
    15  func (*trusty) prepare(sourcedir string, build bool, arches []*Arch) error {
    16  	return nil
    17  }
    18  
    19  func (*trusty) prepareArch(arch *Arch) error {
    20  	return nil
    21  }
    22  
    23  func (*trusty) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) {
    24  	dir := arch.sourceDir
    25  	args := []string{
    26  		"-fmessage-length=0",
    27  		"-I", filepath.Join(dir, "external", "lk", "include", "shared"),
    28  		"-I", filepath.Join(dir, "trusty", "user", "base", "include"),
    29  	}
    30  	for _, incdir := range info.Incdirs {
    31  		args = append(args, "-I"+filepath.Join(dir, incdir))
    32  	}
    33  	if arch.includeDirs != "" {
    34  		for _, dir := range strings.Split(arch.includeDirs, ",") {
    35  			args = append(args, "-I"+dir)
    36  		}
    37  	}
    38  	params := &extractParams{
    39  		DeclarePrintf: true,
    40  		TargetEndian:  arch.target.HostEndian,
    41  	}
    42  	return extract(info, "gcc", args, params)
    43  }