mirror of
https://github.com/reactos/syzkaller.git
synced 2025-03-02 08:38:11 +00:00
sys/syz-extract: use clang if gcc is broken
On my Debian gcc -m32 is hopelessly broken. Using clang fixes at least arch 386. Arch arm is still broken b/c clang does not like some of kernel arm inline assemly constraints.
This commit is contained in:
parent
a76bf83ffa
commit
edcd9e3c9a
@ -13,6 +13,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/google/syzkaller/pkg/ast"
|
"github.com/google/syzkaller/pkg/ast"
|
||||||
"github.com/google/syzkaller/pkg/compiler"
|
"github.com/google/syzkaller/pkg/compiler"
|
||||||
@ -38,6 +39,9 @@ type Arch struct {
|
|||||||
files []*File
|
files []*File
|
||||||
err error
|
err error
|
||||||
done chan bool
|
done chan bool
|
||||||
|
// Used by OS implementations:
|
||||||
|
once sync.Once
|
||||||
|
cc string
|
||||||
}
|
}
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
|
@ -5,6 +5,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -110,6 +111,13 @@ func (*linux) prepareArch(arch *Arch) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*linux) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) {
|
func (*linux) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) {
|
||||||
|
arch.once.Do(func() {
|
||||||
|
arch.cc = "gcc"
|
||||||
|
if !checkCompiler("gcc", arch.target.CFlags) &&
|
||||||
|
checkCompiler("clang", arch.target.CFlags) {
|
||||||
|
arch.cc = "clang"
|
||||||
|
}
|
||||||
|
})
|
||||||
headerArch := arch.target.KernelHeaderArch
|
headerArch := arch.target.KernelHeaderArch
|
||||||
sourceDir := arch.sourceDir
|
sourceDir := arch.sourceDir
|
||||||
buildDir := arch.buildDir
|
buildDir := arch.buildDir
|
||||||
@ -151,7 +159,7 @@ unsigned long phys_base;
|
|||||||
unsigned long __phys_addr(unsigned long addr) { return 0; }
|
unsigned long __phys_addr(unsigned long addr) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
`
|
`
|
||||||
res, undeclared, err := extract(info, "gcc", args, addSource, true, false)
|
res, undeclared, err := extract(info, arch.cc, args, addSource, true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -171,3 +179,9 @@ unsigned long __phys_addr(unsigned long addr) { return 0; }
|
|||||||
}
|
}
|
||||||
return res, undeclared, nil
|
return res, undeclared, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkCompiler(cc string, args []string) bool {
|
||||||
|
cmd := exec.Command(cc, append(args, "-x", "c", "-", "-o", "/dev/null")...)
|
||||||
|
cmd.Stdin = strings.NewReader("int main(){}")
|
||||||
|
return cmd.Run() == nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user