extract-instrmap.test
6.72 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
## This test makes sure we can extract the instrumentation map from an
## XRay-instrumented PIE file.
## Generated from the following source:
## __attribute__((xray_always_instrument)) void foo() {}
## __attribute__((xray_always_instrument)) void bar() {}
## __attribute__((xray_always_instrument)) void jar() {}
## Built with the following arguments:
## -target armv7a-linux-androideabi -nostdlib -fxray-instrument -fPIC -shared
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_ARM
Flags: [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
Entry: 0x00000000000012B0
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R ]
Sections:
- Section: .rel.dyn
Align: 0x0000000000001000
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
Sections:
- Section: .text
VAddr: 0x00000000000012B0
Align: 0x0000000000001000
- Type: PT_LOAD
Flags: [ PF_W, PF_R ]
Sections:
- Section: xray_instr_map
- Section: xray_fn_idx
VAddr: 0x00000000000033CC
Align: 0x0000000000001000
Sections:
- Name: .rel.dyn
Type: SHT_REL
Flags: [ SHF_ALLOC ]
Address: 0x0000000000000200
Link: .dynsym
AddressAlign: 0x0000000000000004
Relocations:
- Offset: 0x00000000000033CC
Type: R_ARM_RELATIVE
- Offset: 0x00000000000033DC
Type: R_ARM_RELATIVE
- Offset: 0x00000000000033EC
Type: R_ARM_RELATIVE
- Offset: 0x00000000000033FC
Type: R_ARM_RELATIVE
- Offset: 0x000000000000340C
Type: R_ARM_RELATIVE
- Offset: 0x000000000000341C
Type: R_ARM_RELATIVE
- Offset: 0x0000000000003430
Type: R_ARM_RELATIVE
- Offset: 0x0000000000003434
Type: R_ARM_RELATIVE
- Offset: 0x0000000000003438
Type: R_ARM_RELATIVE
- Offset: 0x000000000000343C
Type: R_ARM_RELATIVE
- Offset: 0x0000000000003440
Type: R_ARM_RELATIVE
- Offset: 0x0000000000003444
Type: R_ARM_RELATIVE
- Offset: 0x00000000000033F0
Symbol: _Z3barv
Type: R_ARM_ABS32
- Offset: 0x0000000000003400
Symbol: _Z3barv
Type: R_ARM_ABS32
- Offset: 0x00000000000033D0
Symbol: _Z3foov
Type: R_ARM_ABS32
- Offset: 0x00000000000033E0
Symbol: _Z3foov
Type: R_ARM_ABS32
- Offset: 0x0000000000003410
Symbol: _Z3jarv
Type: R_ARM_ABS32
- Offset: 0x0000000000003420
Symbol: _Z3jarv
Type: R_ARM_ABS32
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x00000000000012B0
AddressAlign: 0x0000000000000004
Size: 180
- Name: xray_instr_map
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC, SHF_LINK_ORDER ]
Address: 0x00000000000033CC
Link: .text
AddressAlign: 0x0000000000000001
Content: B0120000000000000001000000000000CC120000000000000101000000000000EC120000000000000001000000000000081300000000000001010000000000002813000000000000000100000000000044130000000000000101000000000000
- Name: xray_fn_idx
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC, SHF_LINK_ORDER ]
Address: 0x0000000000003430
Link: .text
AddressAlign: 0x0000000000000008
Content: CC330000EC330000EC3300000C3400000C3400002C340000
DynamicSymbols:
- Name: _Z3barv
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x00000000000012EC
Size: 0x000000000000003C
- Name: _Z3foov
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x00000000000012B0
Size: 0x000000000000003C
- Name: _Z3jarv
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x0000000000001328
Size: 0x000000000000003C
...
# RUN: yaml2obj %s -o %t.so
# RUN: llvm-xray extract %t.so -s | FileCheck %s
# CHECK: ---
# CHECK-NEXT: - { id: 1, address: 0x00000000000012B0, function: 0x00000000000012B0, kind: function-enter, always-instrument: true, function-name: 'foo()' }
# CHECK-NEXT: - { id: 1, address: 0x00000000000012CC, function: 0x00000000000012B0, kind: function-exit, always-instrument: true, function-name: 'foo()' }
# CHECK-NEXT: - { id: 2, address: 0x00000000000012EC, function: 0x00000000000012EC, kind: function-enter, always-instrument: true, function-name: 'bar()' }
# CHECK-NEXT: - { id: 2, address: 0x0000000000001308, function: 0x00000000000012EC, kind: function-exit, always-instrument: true, function-name: 'bar()' }
# CHECK-NEXT: - { id: 3, address: 0x0000000000001328, function: 0x0000000000001328, kind: function-enter, always-instrument: true, function-name: 'jar()' }
# CHECK-NEXT: - { id: 3, address: 0x0000000000001344, function: 0x0000000000001328, kind: function-exit, always-instrument: true, function-name: 'jar()' }
# CHECK-NEXT: ...
# RUN: llvm-xray extract -s --no-demangle %t.so | FileCheck --check-prefix=MANGLED %s
# MANGLED: ---
# MANGLED-NEXT: - { id: 1, address: 0x00000000000012B0, function: 0x00000000000012B0, kind: function-enter, always-instrument: true, function-name: _Z3foov }
# MANGLED-NEXT: - { id: 1, address: 0x00000000000012CC, function: 0x00000000000012B0, kind: function-exit, always-instrument: true, function-name: _Z3foov }
# MANGLED-NEXT: - { id: 2, address: 0x00000000000012EC, function: 0x00000000000012EC, kind: function-enter, always-instrument: true, function-name: _Z3barv }
# MANGLED-NEXT: - { id: 2, address: 0x0000000000001308, function: 0x00000000000012EC, kind: function-exit, always-instrument: true, function-name: _Z3barv }
# MANGLED-NEXT: - { id: 3, address: 0x0000000000001328, function: 0x0000000000001328, kind: function-enter, always-instrument: true, function-name: _Z3jarv }
# MANGLED-NEXT: - { id: 3, address: 0x0000000000001344, function: 0x0000000000001328, kind: function-exit, always-instrument: true, function-name: _Z3jarv }
# MANGLED-NEXT: ...