mirror of
https://github.com/reactos/syzkaller.git
synced 2024-12-03 17:01:28 +00:00
syz-extract: select declaring printf or not
Kernels are standalone implementations and can have their own implementations of functions that have different prototypes than the standard ones. In the NetBSD case the kernel printf returns void, and it is declared in <sys/systm.h> so avoid re-declaring it. Select if we are going to declare printf or not depending on the OS.
This commit is contained in:
parent
7afa56efb4
commit
3520854be0
@ -30,5 +30,5 @@ func (*akaros) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uin
|
||||
for _, incdir := range info.Incdirs {
|
||||
args = append(args, "-I"+filepath.Join(dir, incdir))
|
||||
}
|
||||
return extract(info, "gcc", args, "")
|
||||
return extract(info, "gcc", args, "", true)
|
||||
}
|
||||
|
@ -17,12 +17,13 @@ import (
|
||||
"github.com/google/syzkaller/pkg/compiler"
|
||||
)
|
||||
|
||||
func extract(info *compiler.ConstInfo, cc string, args []string, addSource string) (map[string]uint64, map[string]bool, error) {
|
||||
func extract(info *compiler.ConstInfo, cc string, args []string, addSource string, declarePrintf bool) (map[string]uint64, map[string]bool, error) {
|
||||
data := &CompileData{
|
||||
AddSource: addSource,
|
||||
Defines: info.Defines,
|
||||
Includes: info.Includes,
|
||||
Values: info.Consts,
|
||||
AddSource: addSource,
|
||||
Defines: info.Defines,
|
||||
Includes: info.Includes,
|
||||
Values: info.Consts,
|
||||
DeclarePrintf: declarePrintf,
|
||||
}
|
||||
undeclared := make(map[string]bool)
|
||||
bin, out, err := compile(cc, args, data)
|
||||
@ -88,10 +89,11 @@ func extract(info *compiler.ConstInfo, cc string, args []string, addSource strin
|
||||
}
|
||||
|
||||
type CompileData struct {
|
||||
AddSource string
|
||||
Defines map[string]string
|
||||
Includes []string
|
||||
Values []string
|
||||
AddSource string
|
||||
Defines map[string]string
|
||||
Includes []string
|
||||
Values []string
|
||||
DeclarePrintf bool
|
||||
}
|
||||
|
||||
func compile(cc string, args []string, data *CompileData) (bin string, out []byte, err error) {
|
||||
@ -144,7 +146,9 @@ var srcTemplate = template.Must(template.New("").Parse(`
|
||||
|
||||
{{.AddSource}}
|
||||
|
||||
{{.DeclarePrintf}}
|
||||
int printf(const char *format, ...);
|
||||
{{end}}
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
|
@ -67,7 +67,7 @@ func (*freebsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui
|
||||
info.Consts = append(info.Consts, compat)
|
||||
}
|
||||
}
|
||||
res, undeclared, err := extract(info, "gcc", args, "#include <sys/syscall.h>")
|
||||
res, undeclared, err := extract(info, "gcc", args, "#include <sys/syscall.h>", true)
|
||||
for orig, compats := range compatNames {
|
||||
for _, compat := range compats {
|
||||
if undeclared[orig] && !undeclared[compat] {
|
||||
|
@ -31,5 +31,5 @@ func (*fuchsia) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui
|
||||
for _, incdir := range info.Incdirs {
|
||||
args = append(args, "-I"+filepath.Join(dir, incdir))
|
||||
}
|
||||
return extract(info, cc, args, "")
|
||||
return extract(info, cc, args, "", true)
|
||||
}
|
||||
|
@ -103,5 +103,5 @@ unsigned long phys_base;
|
||||
unsigned long __phys_addr(unsigned long addr) { return 0; }
|
||||
#endif
|
||||
`
|
||||
return extract(info, "gcc", args, addSource)
|
||||
return extract(info, "gcc", args, addSource, true)
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func (*netbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uin
|
||||
info.Consts = append(info.Consts, compat)
|
||||
}
|
||||
}
|
||||
res, undeclared, err := extract(info, "gcc", args, "#include <sys/syscall.h>")
|
||||
res, undeclared, err := extract(info, "gcc", args, "#include <sys/syscall.h>", false)
|
||||
for orig, compats := range compatNames {
|
||||
for _, compat := range compats {
|
||||
if undeclared[orig] && !undeclared[compat] {
|
||||
|
@ -18,5 +18,5 @@ func (*windows) prepareArch(arch *Arch) error {
|
||||
}
|
||||
|
||||
func (*windows) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) {
|
||||
return extract(info, "cl", nil, "")
|
||||
return extract(info, "cl", nil, "", true)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user