From d9a893a554d6077f5cab4aa8a81f24213443232e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 2 Aug 2018 19:07:22 +0200 Subject: Makefile: don't compile all targets into target binaries Currently target binaries contain support for all OS/arch combinations. However, obviously a fuchsia target binary won't test windows. For target binaries we need support only for a single target (with the exception of 386/arm target in amd64/arm64 binaries). So compile in only _the_ target into target binaries. This reduces akaros/amd64 fuzzer binary from 33 to 7 MB and execprog from 28 to 2 MB. --- sys/linux/gen/386.go | 8 ++++++-- sys/linux/gen/amd64.go | 8 ++++++-- sys/linux/gen/arm.go | 8 ++++++-- sys/linux/gen/arm64.go | 8 ++++++-- sys/linux/gen/empty.go | 3 +++ sys/linux/gen/ppc64le.go | 8 ++++++-- sys/linux/init.go | 5 +++-- 7 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 sys/linux/gen/empty.go (limited to 'sys/linux') diff --git a/sys/linux/gen/386.go b/sys/linux/gen/386.go index 972193818..82bb7aa81 100644 --- a/sys/linux/gen/386.go +++ b/sys/linux/gen/386.go @@ -1,10 +1,14 @@ // AUTOGENERATED FILE +// +build !syz_target syz_target,syz_os_linux,syz_arch_386 syz_target,syz_os_linux,syz_arch_amd64 package gen import . "github.com/google/syzkaller/prog" +import . "github.com/google/syzkaller/sys/linux" -var Target_386 = &Target{OS: "linux", Arch: "386", Revision: revision_386, PtrSize: 4, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_386, Resources: resources_386, Structs: structDescs_386, Consts: consts_386} +func init() { + RegisterTarget(&Target{OS: "linux", Arch: "386", Revision: revision_386, PtrSize: 4, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_386, Resources: resources_386, Structs: structDescs_386, Consts: consts_386}, InitTarget) +} var resources_386 = []*ResourceDesc{ {Name: "assoc_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"assoc_id"}, Values: []uint64{0}}, @@ -39509,4 +39513,4 @@ var consts_386 = []ConstValue{ {Name: "bpf_insn_load_imm_dw", Value: 24}, } -const revision_386 = "d16df4bd3b5d63c53207d8d48f0e7aa8375ae471" +const revision_386 = "c026c82f557e0fb27209b060f233071e8ba38eab" diff --git a/sys/linux/gen/amd64.go b/sys/linux/gen/amd64.go index 6fffdec69..c2747f266 100644 --- a/sys/linux/gen/amd64.go +++ b/sys/linux/gen/amd64.go @@ -1,10 +1,14 @@ // AUTOGENERATED FILE +// +build !syz_target syz_target,syz_os_linux,syz_arch_amd64 package gen import . "github.com/google/syzkaller/prog" +import . "github.com/google/syzkaller/sys/linux" -var Target_amd64 = &Target{OS: "linux", Arch: "amd64", Revision: revision_amd64, PtrSize: 8, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_amd64, Resources: resources_amd64, Structs: structDescs_amd64, Consts: consts_amd64} +func init() { + RegisterTarget(&Target{OS: "linux", Arch: "amd64", Revision: revision_amd64, PtrSize: 8, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_amd64, Resources: resources_amd64, Structs: structDescs_amd64, Consts: consts_amd64}, InitTarget) +} var resources_amd64 = []*ResourceDesc{ {Name: "assoc_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"assoc_id"}, Values: []uint64{0}}, @@ -40196,4 +40200,4 @@ var consts_amd64 = []ConstValue{ {Name: "bpf_insn_load_imm_dw", Value: 24}, } -const revision_amd64 = "22bac64bd4f91440dd851726a290b9eb1f1ae092" +const revision_amd64 = "c06fc3bdc53ae8ee708128ddd51d14a679aa12f0" diff --git a/sys/linux/gen/arm.go b/sys/linux/gen/arm.go index 160738afd..8192e252a 100644 --- a/sys/linux/gen/arm.go +++ b/sys/linux/gen/arm.go @@ -1,10 +1,14 @@ // AUTOGENERATED FILE +// +build !syz_target syz_target,syz_os_linux,syz_arch_arm syz_target,syz_os_linux,syz_arch_arm64 package gen import . "github.com/google/syzkaller/prog" +import . "github.com/google/syzkaller/sys/linux" -var Target_arm = &Target{OS: "linux", Arch: "arm", Revision: revision_arm, PtrSize: 4, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_arm, Resources: resources_arm, Structs: structDescs_arm, Consts: consts_arm} +func init() { + RegisterTarget(&Target{OS: "linux", Arch: "arm", Revision: revision_arm, PtrSize: 4, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_arm, Resources: resources_arm, Structs: structDescs_arm, Consts: consts_arm}, InitTarget) +} var resources_arm = []*ResourceDesc{ {Name: "assoc_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"assoc_id"}, Values: []uint64{0}}, @@ -39367,4 +39371,4 @@ var consts_arm = []ConstValue{ {Name: "bpf_insn_load_imm_dw", Value: 24}, } -const revision_arm = "c46361b24a9d8c4d25f99c6a74ed373b73b0cdd1" +const revision_arm = "b4f6cbe7c414a45bfaf3dcccf7f1040502de3980" diff --git a/sys/linux/gen/arm64.go b/sys/linux/gen/arm64.go index 8bf0d11df..d783efc8b 100644 --- a/sys/linux/gen/arm64.go +++ b/sys/linux/gen/arm64.go @@ -1,10 +1,14 @@ // AUTOGENERATED FILE +// +build !syz_target syz_target,syz_os_linux,syz_arch_arm64 package gen import . "github.com/google/syzkaller/prog" +import . "github.com/google/syzkaller/sys/linux" -var Target_arm64 = &Target{OS: "linux", Arch: "arm64", Revision: revision_arm64, PtrSize: 8, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_arm64, Resources: resources_arm64, Structs: structDescs_arm64, Consts: consts_arm64} +func init() { + RegisterTarget(&Target{OS: "linux", Arch: "arm64", Revision: revision_arm64, PtrSize: 8, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_arm64, Resources: resources_arm64, Structs: structDescs_arm64, Consts: consts_arm64}, InitTarget) +} var resources_arm64 = []*ResourceDesc{ {Name: "assoc_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"assoc_id"}, Values: []uint64{0}}, @@ -39561,4 +39565,4 @@ var consts_arm64 = []ConstValue{ {Name: "bpf_insn_load_imm_dw", Value: 24}, } -const revision_arm64 = "e1ce203bf0cb9e092e65fc6ca9cd1cde96e19316" +const revision_arm64 = "70ff2aa900dc3911170ab814adc6a362bb014580" diff --git a/sys/linux/gen/empty.go b/sys/linux/gen/empty.go new file mode 100644 index 000000000..5baff07bf --- /dev/null +++ b/sys/linux/gen/empty.go @@ -0,0 +1,3 @@ +// AUTOGENERATED FILE +// This file is needed if OS is completely excluded by build tags. +package gen diff --git a/sys/linux/gen/ppc64le.go b/sys/linux/gen/ppc64le.go index d8f088418..8ffa0b43f 100644 --- a/sys/linux/gen/ppc64le.go +++ b/sys/linux/gen/ppc64le.go @@ -1,10 +1,14 @@ // AUTOGENERATED FILE +// +build !syz_target syz_target,syz_os_linux,syz_arch_ppc64le package gen import . "github.com/google/syzkaller/prog" +import . "github.com/google/syzkaller/sys/linux" -var Target_ppc64le = &Target{OS: "linux", Arch: "ppc64le", Revision: revision_ppc64le, PtrSize: 8, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_ppc64le, Resources: resources_ppc64le, Structs: structDescs_ppc64le, Consts: consts_ppc64le} +func init() { + RegisterTarget(&Target{OS: "linux", Arch: "ppc64le", Revision: revision_ppc64le, PtrSize: 8, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_ppc64le, Resources: resources_ppc64le, Structs: structDescs_ppc64le, Consts: consts_ppc64le}, InitTarget) +} var resources_ppc64le = []*ResourceDesc{ {Name: "assoc_id", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"assoc_id"}, Values: []uint64{0}}, @@ -36992,4 +36996,4 @@ var consts_ppc64le = []ConstValue{ {Name: "bpf_insn_load_imm_dw", Value: 24}, } -const revision_ppc64le = "1ccba534d5c6adaffc5ebfbea33c22833f5cb846" +const revision_ppc64le = "be0af9fd447e9ac157423f3260f414d60066f653" diff --git a/sys/linux/init.go b/sys/linux/init.go index 8d7231fcd..035ffee2f 100644 --- a/sys/linux/init.go +++ b/sys/linux/init.go @@ -7,10 +7,10 @@ import ( "runtime" "github.com/google/syzkaller/prog" - "github.com/google/syzkaller/sys/linux/gen" "github.com/google/syzkaller/sys/targets" ) +/* func init() { prog.RegisterTarget(gen.Target_amd64, initTarget) prog.RegisterTarget(gen.Target_386, initTarget) @@ -18,8 +18,9 @@ func init() { prog.RegisterTarget(gen.Target_arm, initTarget) prog.RegisterTarget(gen.Target_ppc64le, initTarget) } +*/ -func initTarget(target *prog.Target) { +func InitTarget(target *prog.Target) { arch := &arch{ unix: targets.MakeUnixSanitizer(target), clockGettimeSyscall: target.SyscallMap["clock_gettime"], -- cgit mrf-deployment