aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/syz-extract/fetch.go16
-rw-r--r--sys/syz-extract/netbsd.go16
-rw-r--r--sys/syz-extract/openbsd.go10
-rw-r--r--sys/syz-sysgen/sysgen.go15
4 files changed, 31 insertions, 26 deletions
diff --git a/sys/syz-extract/fetch.go b/sys/syz-extract/fetch.go
index a7a0e46fe..834189fff 100644
--- a/sys/syz-extract/fetch.go
+++ b/sys/syz-extract/fetch.go
@@ -39,8 +39,8 @@ func extract(info *compiler.ConstInfo, cc string, args []string, params *extract
missingIncludes := make(map[string]bool)
undeclared := make(map[string]bool)
valMap := make(map[string]bool)
- for _, val := range info.Consts {
- valMap[val] = true
+ for _, def := range info.Consts {
+ valMap[def.Name] = true
}
for {
bin1, out, err := compile(cc, args, data)
@@ -74,11 +74,11 @@ func extract(info *compiler.ConstInfo, cc string, args []string, params *extract
cc, args, err, out)
}
data.Values = nil
- for _, v := range info.Consts {
- if undeclared[v] {
+ for _, def := range info.Consts {
+ if undeclared[def.Name] {
continue
}
- data.Values = append(data.Values, v)
+ data.Values = append(data.Values, def)
}
data.Includes = nil
for _, v := range info.Includes {
@@ -105,8 +105,8 @@ func extract(info *compiler.ConstInfo, cc string, args []string, params *extract
len(flagVals), len(data.Values))
}
res := make(map[string]uint64)
- for i, name := range data.Values {
- res[name] = flagVals[i]
+ for i, def := range data.Values {
+ res[def.Name] = flagVals[i]
}
return res, undeclared, nil
}
@@ -115,7 +115,7 @@ type CompileData struct {
*extractParams
Defines map[string]string
Includes []string
- Values []string
+ Values []*compiler.Const
}
func compile(cc string, args []string, data *CompileData) (string, []byte, error) {
diff --git a/sys/syz-extract/netbsd.go b/sys/syz-extract/netbsd.go
index 8cc5efac0..b2ce7d620 100644
--- a/sys/syz-extract/netbsd.go
+++ b/sys/syz-extract/netbsd.go
@@ -72,20 +72,20 @@ func (*netbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uin
// Syscall consts on netbsd have weird prefixes sometimes,
// try to extract consts with these prefixes as well.
compatNames := make(map[string][]string)
- for _, val := range info.Consts {
+ for _, def := range info.Consts {
const SYS = "SYS_"
- if strings.HasPrefix(val, SYS) {
+ if strings.HasPrefix(def.Name, SYS) {
for _, prefix := range []string{"_", "__", "___"} {
for _, suffix := range []string{"30", "50"} {
- compat := SYS + prefix + val[len(SYS):] + suffix
- compatNames[val] = append(compatNames[val], compat)
- info.Consts = append(info.Consts, compat)
+ compat := SYS + prefix + def.Name[len(SYS):] + suffix
+ compatNames[def.Name] = append(compatNames[def.Name], compat)
+ info.Consts = append(info.Consts, &compiler.Const{Name: compat})
}
}
} else {
- compat := "LINUX_" + val
- compatNames[val] = append(compatNames[val], compat)
- info.Consts = append(info.Consts, compat)
+ compat := "LINUX_" + def.Name
+ compatNames[def.Name] = append(compatNames[def.Name], compat)
+ info.Consts = append(info.Consts, &compiler.Const{Name: compat})
}
}
params := &extractParams{
diff --git a/sys/syz-extract/openbsd.go b/sys/syz-extract/openbsd.go
index f103d1949..9d9a7026e 100644
--- a/sys/syz-extract/openbsd.go
+++ b/sys/syz-extract/openbsd.go
@@ -71,11 +71,11 @@ func (*openbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui
"SYS_tmpfd": true,
}
compatNames := make(map[string][]string)
- for _, val := range info.Consts {
- if _, ok := syscallsQuirks[val]; ok {
- compat := "SYS___" + val[len("SYS_"):]
- compatNames[val] = append(compatNames[val], compat)
- info.Consts = append(info.Consts, compat)
+ for _, def := range info.Consts {
+ if _, ok := syscallsQuirks[def.Name]; ok {
+ compat := "SYS___" + def.Name[len("SYS_"):]
+ compatNames[def.Name] = append(compatNames[def.Name], compat)
+ info.Consts = append(info.Consts, &compiler.Const{Name: compat})
}
}
params := &extractParams{
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go
index 0459d544f..70b38fee5 100644
--- a/sys/syz-sysgen/sysgen.go
+++ b/sys/syz-sysgen/sysgen.go
@@ -98,9 +98,17 @@ func main() {
var jobs []*Job
for _, arch := range archs {
+ target := targets.List[OS][arch]
+ constInfo := compiler.ExtractConsts(descriptions, target, nil)
+ if OS == targets.TestOS {
+ // The ConstFile object provides no guarantees re concurrent read-write,
+ // so let's patch it before we start goroutines.
+ compiler.FabricateSyscallConsts(target, constInfo, constFile)
+ }
jobs = append(jobs, &Job{
- Target: targets.List[OS][arch],
+ Target: target,
Unsupported: make(map[string]bool),
+ ConstInfo: constInfo,
})
}
sort.Slice(jobs, func(i, j int) bool {
@@ -167,6 +175,7 @@ type Job struct {
Errors []string
Unsupported map[string]bool
ArchData ArchData
+ ConstInfo map[string]*compiler.ConstInfo
}
func processJob(job *Job, descriptions *ast.Description, constFile *compiler.ConstFile) {
@@ -174,10 +183,6 @@ func processJob(job *Job, descriptions *ast.Description, constFile *compiler.Con
job.Errors = append(job.Errors, fmt.Sprintf("%v: %v\n", pos, msg))
}
consts := constFile.Arch(job.Target.Arch)
- if job.Target.OS == targets.TestOS {
- constInfo := compiler.ExtractConsts(descriptions, job.Target, eh)
- compiler.FabricateSyscallConsts(job.Target, constInfo, consts)
- }
prog := compiler.Compile(descriptions, consts, job.Target, eh)
if prog == nil {
return