diff options
| -rw-r--r-- | pkg/build/build.go | 16 | ||||
| -rw-r--r-- | pkg/build/linux.go | 13 | ||||
| -rw-r--r-- | sys/syz-extract/linux.go | 2 | ||||
| -rw-r--r-- | syz-ci/manager.go | 1 | ||||
| -rw-r--r-- | syz-ci/syz-ci.go | 1 | ||||
| -rw-r--r-- | tools/syz-build/build.go | 2 |
6 files changed, 22 insertions, 13 deletions
diff --git a/pkg/build/build.go b/pkg/build/build.go index cabb8046e..4baed2b95 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -28,6 +28,7 @@ type Params struct { KernelDir string OutputDir string Compiler string + Linker string Ccache string UserspaceDir string CmdlineFile string @@ -47,13 +48,14 @@ type ImageDetails struct { // If CmdlineFile is not empty, contents of the file are appended to the kernel command line. // If SysctlFile is not empty, contents of the file are appended to the image /etc/sysctl.conf. // Output is stored in OutputDir and includes (everything except for image is optional): -// - image: the image -// - key: ssh key for the image -// - kernel: kernel for injected boot -// - initrd: initrd for injected boot -// - kernel.config: actual kernel config used during build -// - obj/: directory with kernel object files (this should match KernelObject -// specified in sys/targets, e.g. vmlinux for linux) +// - image: the image +// - key: ssh key for the image +// - kernel: kernel for injected boot +// - initrd: initrd for injected boot +// - kernel.config: actual kernel config used during build +// - obj/: directory with kernel object files (this should match KernelObject +// specified in sys/targets, e.g. vmlinux for linux) +// // The returned structure contains a kernel ID that will be the same for kernels // with the same runtime behavior, and different for kernels with different runtime // behavior. Binary equal builds, or builds that differ only in e.g. debug info, diff --git a/pkg/build/linux.go b/pkg/build/linux.go index be9a38377..9fae48fc6 100644 --- a/pkg/build/linux.go +++ b/pkg/build/linux.go @@ -148,9 +148,9 @@ func (linux) writeFile(file string, data []byte) error { return osutil.SandboxChown(file) } -func runMakeImpl(arch, compiler, ccache, kernelDir string, addArgs ...string) error { +func runMakeImpl(arch, compiler, linker, ccache, kernelDir string, addArgs ...string) error { target := targets.Get(targets.Linux, arch) - args := LinuxMakeArgs(target, compiler, ccache, "") + args := LinuxMakeArgs(target, compiler, linker, ccache, "") args = append(args, addArgs...) cmd := osutil.Command("make", args...) if err := osutil.Sandbox(cmd, true, true); err != nil { @@ -175,10 +175,10 @@ func runMakeImpl(arch, compiler, ccache, kernelDir string, addArgs ...string) er } func runMake(params Params, addArgs ...string) error { - return runMakeImpl(params.TargetArch, params.Compiler, params.Ccache, params.KernelDir, addArgs...) + return runMakeImpl(params.TargetArch, params.Compiler, params.Linker, params.Ccache, params.KernelDir, addArgs...) } -func LinuxMakeArgs(target *targets.Target, compiler, ccache, buildDir string) []string { +func LinuxMakeArgs(target *targets.Target, compiler, linker, ccache, buildDir string) []string { args := []string{ "-j", fmt.Sprint(runtime.NumCPU()), "ARCH=" + target.KernelArch, @@ -189,7 +189,7 @@ func LinuxMakeArgs(target *targets.Target, compiler, ccache, buildDir string) [] if compiler == "" { compiler = target.KernelCompiler if target.KernelLinker != "" { - args = append(args, "LD="+target.KernelLinker) + linker = target.KernelLinker } } if compiler != "" { @@ -198,6 +198,9 @@ func LinuxMakeArgs(target *targets.Target, compiler, ccache, buildDir string) [] } args = append(args, "CC="+compiler) } + if linker != "" { + args = append(args, "LD="+linker) + } if buildDir != "" { args = append(args, "O="+buildDir) } diff --git a/sys/syz-extract/linux.go b/sys/syz-extract/linux.go index 10284d221..086c2d64b 100644 --- a/sys/syz-extract/linux.go +++ b/sys/syz-extract/linux.go @@ -79,7 +79,7 @@ func (*linux) prepareArch(arch *Arch) error { return nil } kernelDir := arch.sourceDir - makeArgs := build.LinuxMakeArgs(arch.target, "", "", arch.buildDir) + makeArgs := build.LinuxMakeArgs(arch.target, "", "", "", arch.buildDir) out, err := osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "defconfig")...) if err != nil { return fmt.Errorf("make defconfig failed: %v\n%s", err, out) diff --git a/syz-ci/manager.go b/syz-ci/manager.go index 0f449268e..cbd6a469f 100644 --- a/syz-ci/manager.go +++ b/syz-ci/manager.go @@ -321,6 +321,7 @@ func (mgr *Manager) build(kernelCommit *vcs.Commit) error { KernelDir: mgr.kernelDir, OutputDir: tmpDir, Compiler: mgr.mgrcfg.Compiler, + Linker: mgr.mgrcfg.Linker, Ccache: mgr.mgrcfg.Ccache, UserspaceDir: mgr.mgrcfg.Userspace, CmdlineFile: mgr.mgrcfg.KernelCmdline, diff --git a/syz-ci/syz-ci.go b/syz-ci/syz-ci.go index 4abbe21c0..790a29f86 100644 --- a/syz-ci/syz-ci.go +++ b/syz-ci/syz-ci.go @@ -158,6 +158,7 @@ type ManagerConfig struct { // explicit plumbing for every os/compiler combination. CompilerType string `json:"compiler_type"` // Defaults to "gcc" Compiler string `json:"compiler"` + Linker string `json:"linker"` Ccache string `json:"ccache"` Userspace string `json:"userspace"` KernelConfig string `json:"kernel_config"` diff --git a/tools/syz-build/build.go b/tools/syz-build/build.go index ec7e76eb5..20461bb7f 100644 --- a/tools/syz-build/build.go +++ b/tools/syz-build/build.go @@ -22,6 +22,7 @@ var ( flagVM = flag.String("vm", "gce", "VM type to build") flagKernelSrc = flag.String("kernel_src", "", "path to kernel checkout") flagCompiler = flag.String("compiler", "", "non-defult compiler") + flagLinker = flag.String("linker", "", "non-default linker") flagKernelConfig = flag.String("config", "", "kernel config file") flagKernelSysctl = flag.String("sysctl", "", "kernel sysctl file") flagKernelCmdline = flag.String("cmdline", "", "kernel cmdline file") @@ -46,6 +47,7 @@ func main() { KernelDir: *flagKernelSrc, OutputDir: ".", Compiler: *flagCompiler, + Linker: *flagLinker, Ccache: "", UserspaceDir: *flagUserspace, CmdlineFile: *flagKernelCmdline, |
