/
backend.go
89 lines (77 loc) · 2.02 KB
/
backend.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright 2020 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package backend
import (
"fmt"
"github.com/google/syzkaller/pkg/host"
"github.com/google/syzkaller/sys/targets"
)
type Impl struct {
Units []*CompileUnit
Symbols []*Symbol
Frames []Frame
Symbolize func(pcs map[*Module][]uint64) ([]Frame, error)
RestorePC func(pc uint32) uint64
CallbackPoints []uint64
PreciseCoverage bool
}
type Module struct {
Name string
Path string
Addr uint64
}
type CompileUnit struct {
ObjectUnit
Path string
Module *Module
}
type Symbol struct {
ObjectUnit
Module *Module
Unit *CompileUnit
Start uint64
End uint64
Symbolized bool
}
// ObjectUnit represents either CompileUnit or Symbol.
type ObjectUnit struct {
Name string
PCs []uint64 // PCs we can get in coverage callbacks for this unit.
CMPs []uint64 // PCs we can get in comparison interception callbacks for this unit.
}
type Frame struct {
Module *Module
PC uint64
Name string
FuncName string
Path string
Inline bool
Range
}
type Range struct {
StartLine int
StartCol int
EndLine int
EndCol int
}
const LineEnd = 1 << 30
func Make(target *targets.Target, vm, objDir, srcDir, buildDir string, splitBuild bool,
moduleObj []string, modules []host.KernelModule) (*Impl, error) {
if objDir == "" {
return nil, fmt.Errorf("kernel obj directory is not specified")
}
if target.OS == "darwin" {
return makeMachO(target, objDir, srcDir, buildDir, moduleObj, modules)
}
if vm == "gvisor" {
return makeGvisor(target, objDir, srcDir, buildDir, modules)
}
var delimiters []string
if splitBuild {
// Path prefixes used by Android Pixel kernels. See
// https://source.android.com/docs/setup/build/building-pixel-kernels for more
// details.
delimiters = []string{"/aosp/", "/private/"}
}
return makeELF(target, objDir, srcDir, buildDir, delimiters, moduleObj, modules)
}