mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-23 11:29:46 +00:00
prog: export RestoreLinks function
Allows to use compiled descriptions. Will be useful for static checking utility.
This commit is contained in:
parent
a6bc9c88b9
commit
f950e82d47
@ -132,40 +132,13 @@ func (target *Target) initTarget() {
|
||||
target.ConstMap[c.Name] = c.Value
|
||||
}
|
||||
|
||||
target.resourceMap = make(map[string]*ResourceDesc)
|
||||
for _, res := range target.Resources {
|
||||
target.resourceMap[res.Name] = res
|
||||
}
|
||||
|
||||
keyedStructs := make(map[StructKey]*StructDesc)
|
||||
for _, desc := range target.Structs {
|
||||
keyedStructs[desc.Key] = desc.Desc
|
||||
}
|
||||
target.resourceMap = restoreLinks(target.Syscalls, target.Resources, target.Structs)
|
||||
target.Structs = nil
|
||||
|
||||
target.SyscallMap = make(map[string]*Syscall)
|
||||
for i, c := range target.Syscalls {
|
||||
c.ID = i
|
||||
target.SyscallMap[c.Name] = c
|
||||
ForeachType(c, func(t0 Type) {
|
||||
switch t := t0.(type) {
|
||||
case *ResourceType:
|
||||
t.Desc = target.resourceMap[t.TypeName]
|
||||
if t.Desc == nil {
|
||||
panic("no resource desc")
|
||||
}
|
||||
case *StructType:
|
||||
t.StructDesc = keyedStructs[t.Key]
|
||||
if t.StructDesc == nil {
|
||||
panic("no struct desc")
|
||||
}
|
||||
case *UnionType:
|
||||
t.StructDesc = keyedStructs[t.Key]
|
||||
if t.StructDesc == nil {
|
||||
panic("no union desc")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
target.populateResourceCtors()
|
||||
@ -187,6 +160,43 @@ func (target *Target) GetConst(name string) uint64 {
|
||||
return v
|
||||
}
|
||||
|
||||
func RestoreLinks(syscalls []*Syscall, resources []*ResourceDesc, structs []*KeyedStruct) {
|
||||
restoreLinks(syscalls, resources, structs)
|
||||
}
|
||||
|
||||
func restoreLinks(syscalls []*Syscall, resources []*ResourceDesc, structs []*KeyedStruct) map[string]*ResourceDesc {
|
||||
resourceMap := make(map[string]*ResourceDesc)
|
||||
for _, res := range resources {
|
||||
resourceMap[res.Name] = res
|
||||
}
|
||||
keyedStructs := make(map[StructKey]*StructDesc)
|
||||
for _, desc := range structs {
|
||||
keyedStructs[desc.Key] = desc.Desc
|
||||
}
|
||||
for _, c := range syscalls {
|
||||
ForeachType(c, func(t0 Type) {
|
||||
switch t := t0.(type) {
|
||||
case *ResourceType:
|
||||
t.Desc = resourceMap[t.TypeName]
|
||||
if t.Desc == nil {
|
||||
panic("no resource desc")
|
||||
}
|
||||
case *StructType:
|
||||
t.StructDesc = keyedStructs[t.Key]
|
||||
if t.StructDesc == nil {
|
||||
panic("no struct desc")
|
||||
}
|
||||
case *UnionType:
|
||||
t.StructDesc = keyedStructs[t.Key]
|
||||
if t.StructDesc == nil {
|
||||
panic("no union desc")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return resourceMap
|
||||
}
|
||||
|
||||
type Gen struct {
|
||||
r *randGen
|
||||
s *state
|
||||
|
Loading…
Reference in New Issue
Block a user