1# RUN: yaml2obj %s -o %t1.o
2# RUN: yaml2obj %s -o %t2.o
3
4# RUN: printf "\x04" > %t.stats
5
6# RUN: printf "%%s" "%t1.o" >> %t.stats
7# RUN: printf "\x00" >> %t.stats
8# RUN: printf "\x01\x00\x00\x00\x01\x00\x00\x00" >> %t.stats
9# RUN: printf "\x11\x00\x00\x00\x02\x00\x00\x20" >> %t.stats
10# RUN: printf "\x21\x00\x00\x00\x03\x00\x00\x40" >> %t.stats
11# RUN: printf "\x01\x00\x00\x00\x04\x00\x00\x60" >> %t.stats
12# RUN: printf "\x11\x00\x00\x00\x05\x00\x00\x80" >> %t.stats
13# RUN: printf "\x21\x00\x00\x00\x06\x00\x00\xa0" >> %t.stats
14# RUN: printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> %t.stats
15
16# RUN: printf "%%s" "%t2.o" >> %t.stats
17# RUN: printf "\x00" >> %t.stats
18# RUN: printf "\x21\x00\x00\x00\x07\x00\x00\x00" >> %t.stats
19# RUN: printf "\x11\x00\x00\x00\x08\x00\x00\x20" >> %t.stats
20# RUN: printf "\x01\x00\x00\x00\x09\x00\x00\x40" >> %t.stats
21# RUN: printf "\x21\x00\x00\x00\x0b\x00\x00\x60" >> %t.stats
22# RUN: printf "\x11\x00\x00\x00\x0c\x00\x00\x80" >> %t.stats
23# RUN: printf "\x01\x00\x00\x00\x0e\x00\x00\xa0" >> %t.stats
24# RUN: printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> %t.stats
25
26# RUN: sanstats %t.stats | FileCheck %s
27
28# Test that if binaries are not in the original location then sanstats
29# searches them next to the stats file.
30# RUN: mkdir -p %t.dir
31# RUN: mv -f %t1.o %t2.o %t.dir
32# RUN: sanstats %t.stats | FileCheck %s --check-prefix=INVALID
33# RUN: mv -f %t.stats %t.dir/copy.stats
34# RUN: cd %t.dir && sanstats copy.stats | FileCheck %s
35
36# INVALID: <invalid>
37# CHECK-NOT: <invalid>
38# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 cfi-vcall 1
39# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-nvcall 2
40# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 cfi-derived-cast 3
41# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 cfi-unrelated-cast 4
42# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-icall 5
43# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 <unknown> 6
44
45# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 cfi-vcall 7
46# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-nvcall 8
47# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 cfi-derived-cast 9
48# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 cfi-unrelated-cast 11
49# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-icall 12
50# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 <unknown> 14
51
52--- !ELF
53FileHeader:
54  Class:           ELFCLASS64
55  Data:            ELFDATA2LSB
56  Type:            ET_REL
57  Machine:         EM_X86_64
58Sections:
59  - Name:            .text
60    Type:            SHT_PROGBITS
61    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
62    AddressAlign:    0x0000000000000010
63    Content:         554889E55DC3662E0F1F840000000000554889E55DC3662E0F1F840000000000554889E55DC3
64  - Name:            .debug_str
65    Type:            SHT_PROGBITS
66    Flags:           [ SHF_MERGE, SHF_STRINGS ]
67    AddressAlign:    0x0000000000000001
68    Content:         636C616E672076657273696F6E20332E382E3020287472756E6B203235353339332920286C6C766D2F7472756E6B203235353734352900662E63002F746D7000663100663200663300
69  - Name:            .debug_loc
70    Type:            SHT_PROGBITS
71    AddressAlign:    0x0000000000000001
72    Content:         ''
73  - Name:            .debug_abbrev
74    Type:            SHT_PROGBITS
75    AddressAlign:    0x0000000000000001
76    Content:         011101250E1305030E10171B0E110112060000022E00110112064018030E3A0B3B0B3F19000000
77  - Name:            .debug_info
78    Type:            SHT_PROGBITS
79    AddressAlign:    0x0000000000000001
80    Content:         660000000400000000000801000000000C0000000000000000000000000000000000000000002600000002000000000000000006000000015600000000010102000000000000000006000000015600000000010202000000000000000006000000015600000000010300
81  - Name:            .rela.debug_info
82    Type:            SHT_RELA
83    Link:            .symtab
84    AddressAlign:    0x0000000000000008
85    Info:            .debug_info
86    Relocations:
87      - Offset:          0x0000000000000006
88        Type:            R_X86_64_32
89      - Offset:          0x000000000000000C
90        Type:            R_X86_64_32
91      - Offset:          0x0000000000000012
92        Type:            R_X86_64_32
93        Addend:          55
94      - Offset:          0x0000000000000016
95        Type:            R_X86_64_32
96      - Offset:          0x000000000000001A
97        Type:            R_X86_64_32
98        Addend:          59
99      - Offset:          0x000000000000001E
100        Type:            R_X86_64_64
101      - Offset:          0x000000000000002B
102        Type:            R_X86_64_64
103      - Offset:          0x0000000000000039
104        Type:            R_X86_64_32
105        Addend:          64
106      - Offset:          0x0000000000000040
107        Type:            R_X86_64_64
108        Addend:          16
109      - Offset:          0x000000000000004E
110        Type:            R_X86_64_32
111        Addend:          67
112      - Offset:          0x0000000000000055
113        Type:            R_X86_64_64
114        Addend:          32
115      - Offset:          0x0000000000000063
116        Type:            R_X86_64_32
117        Addend:          70
118  - Name:            .debug_ranges
119    Type:            SHT_PROGBITS
120    AddressAlign:    0x0000000000000001
121    Content:         ''
122  - Name:            .debug_pubnames
123    Type:            SHT_PROGBITS
124    AddressAlign:    0x0000000000000001
125    Content:         230000000200000000006A0000002A0000006631003F0000006632005400000066330000000000
126  - Name:            .rela.debug_pubnames
127    Type:            SHT_RELA
128    Link:            .symtab
129    AddressAlign:    0x0000000000000008
130    Info:            .debug_pubnames
131    Relocations:
132      - Offset:          0x0000000000000006
133        Type:            R_X86_64_32
134  - Name:            .comment
135    Type:            SHT_PROGBITS
136    Flags:           [ SHF_MERGE, SHF_STRINGS ]
137    AddressAlign:    0x0000000000000001
138    Content:         00636C616E672076657273696F6E20332E382E3020287472756E6B203235353339332920286C6C766D2F7472756E6B203235353734352900
139  - Name:            .note.GNU-stack
140    Type:            SHT_PROGBITS
141    AddressAlign:    0x0000000000000001
142    Content:         ''
143  - Name:            .eh_frame
144    Type:            SHT_X86_64_UNWIND
145    Flags:           [ SHF_ALLOC ]
146    AddressAlign:    0x0000000000000008
147    Content:         1400000000000000017A5200017810011B0C070890010000180000001C000000000000000600000000410E108602430D060000001800000038000000000000000600000000410E108602430D060000001C00000054000000000000000600000000410E108602430D0600000000000000
148  - Name:            .rela.eh_frame
149    Type:            SHT_RELA
150    Link:            .symtab
151    AddressAlign:    0x0000000000000008
152    Info:            .eh_frame
153    Relocations:
154      - Offset:          0x0000000000000020
155        Type:            R_X86_64_PC32
156      - Offset:          0x000000000000003C
157        Type:            R_X86_64_PC32
158        Addend:          16
159      - Offset:          0x0000000000000058
160        Type:            R_X86_64_PC32
161        Addend:          32
162  - Name:            .debug_line
163    Type:            SHT_PROGBITS
164    AddressAlign:    0x0000000000000001
165    Content:         4300000002001A0000000101FB0E0D00010101010000000100000100662E630000000000000902000000000000000001050C0A4A0500BB050C0A4A0500BB050C0A4A0202000101
166  - Name:            .rela.debug_line
167    Type:            SHT_RELA
168    Link:            .symtab
169    AddressAlign:    0x0000000000000008
170    Info:            .debug_line
171    Relocations:
172      - Offset:          0x0000000000000027
173        Type:            R_X86_64_64
174Symbols:
175  - Name:            f.c
176    Type:            STT_FILE
177  - Type:            STT_SECTION
178    Section:         .text
179  - Type:            STT_SECTION
180    Section:         .debug_str
181  - Type:            STT_SECTION
182    Section:         .debug_abbrev
183  - Type:            STT_SECTION
184    Section:         .debug_info
185  - Type:            STT_SECTION
186    Section:         .debug_line
187  - Name:            f1
188    Type:            STT_FUNC
189    Section:         .text
190    Size:            0x0000000000000006
191    Binding:         STB_GLOBAL
192  - Name:            f2
193    Type:            STT_FUNC
194    Section:         .text
195    Value:           0x0000000000000010
196    Size:            0x0000000000000006
197    Binding:         STB_GLOBAL
198  - Name:            f3
199    Type:            STT_FUNC
200    Section:         .text
201    Value:           0x0000000000000020
202    Size:            0x0000000000000006
203    Binding:         STB_GLOBAL
204...
205