aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Lindqvist <anton@basename.se>2020-03-04 16:42:55 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-03-04 18:27:18 +0100
commit9ef240be5fd0feed4ba63edfba3cbaa94837d01d (patch)
tree7226b65a7170546870b99335dee6ab51a0fc6af4
parent4fb7265b9730c3f528b245190f426552c6c845c2 (diff)
sys/syz-extract: fix handling of odd prefixed syscalls on OpenBSD
This makes syz-extract work again on OpenBSD.
-rw-r--r--sys/syz-extract/openbsd.go31
1 files changed, 18 insertions, 13 deletions
diff --git a/sys/syz-extract/openbsd.go b/sys/syz-extract/openbsd.go
index 715131f28..37b29bdd7 100644
--- a/sys/syz-extract/openbsd.go
+++ b/sys/syz-extract/openbsd.go
@@ -57,21 +57,26 @@ func (*openbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui
args = append(args, "-I"+dir)
}
}
- // Syscall consts on openbsd have weird prefixes sometimes,
- // try to extract consts with these prefixes as well.
+ // Some syscalls on OpenBSD are prefixed with `SYS___' as opposed of the
+ // more common `SYS_' prefix.
+ syscallsQuirks := map[string]bool{
+ "SYS_get_tcb": true,
+ "SYS_getcwd": true,
+ "SYS_realpath": true,
+ "SYS_semctl": true,
+ "SYS_set_tcb": true,
+ "SYS_syscall": true,
+ "SYS_tfork": true,
+ "SYS_threxit": true,
+ "SYS_thrsigdivert": true,
+ "SYS_thrsleep": true,
+ "SYS_thrwakeup": true,
+ "SYS_tmpfd": true,
+ }
compatNames := make(map[string][]string)
for _, val := range info.Consts {
- const SYS = "SYS_"
- if strings.HasPrefix(val, 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)
- }
- }
- } else {
- compat := "LINUX_" + val
+ if _, ok := syscallsQuirks[val]; ok {
+ compat := "SYS___" + val[len("SYS_"):]
compatNames[val] = append(compatNames[val], compat)
info.Consts = append(info.Consts, compat)
}