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

     1  // Copyright 2017 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  
     9  	"github.com/google/syzkaller/pkg/compiler"
    10  	"github.com/google/syzkaller/sys/fuchsia/layout"
    11  )
    12  
    13  type fuchsia struct{}
    14  
    15  func (*fuchsia) prepare(sourcedir string, build bool, arches []*Arch) error {
    16  	return nil
    17  }
    18  
    19  func (*fuchsia) prepareArch(arch *Arch) error {
    20  	return nil
    21  }
    22  
    23  func (*fuchsia) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) {
    24  	srcDir := arch.sourceDir
    25  	outDir := filepath.Join(srcDir, "out", arch.target.KernelHeaderArch)
    26  
    27  	cc := filepath.Join(srcDir, "prebuilt/third_party/clang/linux-x64/bin/clang")
    28  	args := []string{
    29  		"-fmessage-length=0",
    30  		"-I", filepath.Join(outDir, "zircon_toolchain/obj/zircon/public/sysroot/sysroot/include"),
    31  		"-I", filepath.Join(outDir, "fidling/gen/zircon/vdso/zx"),
    32  	}
    33  	for _, fidlLib := range layout.AllFidlLibraries {
    34  		args = append(args, "-I", filepath.Join(outDir, fidlLib.PathToCompiledDir()))
    35  	}
    36  	for _, incdir := range info.Incdirs {
    37  		args = append(args, "-I", filepath.Join(srcDir, incdir))
    38  	}
    39  
    40  	params := &extractParams{
    41  		DeclarePrintf:  true,
    42  		DefineGlibcUse: true,
    43  		TargetEndian:   arch.target.HostEndian,
    44  	}
    45  	return extract(info, cc, args, params)
    46  }