From 7afa56efb4b575469f313a18b561bc036a2becb5 Mon Sep 17 00:00:00 2001 From: zoulasc Date: Sat, 28 Oct 2017 13:45:18 -0400 Subject: syz-extract: Add missing symlink for NetBSD and refactor symlink code. --- sys/syz-extract/netbsd.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'sys') diff --git a/sys/syz-extract/netbsd.go b/sys/syz-extract/netbsd.go index 04785d8b4..2be626249 100644 --- a/sys/syz-extract/netbsd.go +++ b/sys/syz-extract/netbsd.go @@ -25,17 +25,31 @@ func (*netbsd) prepare(sourcedir string, build bool, arches []string) error { } func (*netbsd) prepareArch(arch *Arch) error { - if err := os.Symlink(filepath.Join(arch.sourceDir, "sys", "arch", "amd64", "include"), - filepath.Join(arch.buildDir, "machine")); err != nil { - return fmt.Errorf("failed to create link: %v", err) + links := [][2]string{ + {"amd64", "machine"}, + {"amd64", "amd64"}, + {"x86", "x86"}, + } + for _, v := range links { + if err := machineLink(arch, v[0], v[1]); err != nil { + return err + } } - if err := os.Symlink(filepath.Join(arch.sourceDir, "sys", "arch", "x86", "include"), - filepath.Join(arch.buildDir, "x86")); err != nil { + return nil +} + +func machineLink(arch *Arch, machine string, dest string) error { + if err := os.Symlink(machineInclude(arch, machine), + filepath.Join(arch.buildDir, dest)); err != nil { return fmt.Errorf("failed to create link: %v", err) } return nil } +func machineInclude(arch *Arch, machine string) string { + return filepath.Join(arch.sourceDir, "sys", "arch", machine, "include") +} + func (*netbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) { args := []string{ "-fmessage-length=0", -- cgit mrf-deployment