summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/sanstats/elf.test
blob: 344384721e17766b020d6d26f4fbc5d385f7fc08 (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# RUN: yaml2obj %s > %t1.o
# RUN: yaml2obj %s > %t2.o

# RUN: printf "\x04" > %t.stats

# RUN: printf "%%s" "%t1.o" >> %t.stats
# RUN: printf "\x00" >> %t.stats
# RUN: printf "\x01\x00\x00\x00\x01\x00\x00\x00" >> %t.stats
# RUN: printf "\x11\x00\x00\x00\x02\x00\x00\x20" >> %t.stats
# RUN: printf "\x21\x00\x00\x00\x03\x00\x00\x40" >> %t.stats
# RUN: printf "\x01\x00\x00\x00\x04\x00\x00\x60" >> %t.stats
# RUN: printf "\x11\x00\x00\x00\x05\x00\x00\x80" >> %t.stats
# RUN: printf "\x21\x00\x00\x00\x06\x00\x00\xa0" >> %t.stats
# RUN: printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> %t.stats

# RUN: printf "%%s" "%t2.o" >> %t.stats
# RUN: printf "\x00" >> %t.stats
# RUN: printf "\x21\x00\x00\x00\x07\x00\x00\x00" >> %t.stats
# RUN: printf "\x11\x00\x00\x00\x08\x00\x00\x20" >> %t.stats
# RUN: printf "\x01\x00\x00\x00\x09\x00\x00\x40" >> %t.stats
# RUN: printf "\x21\x00\x00\x00\x0b\x00\x00\x60" >> %t.stats
# RUN: printf "\x11\x00\x00\x00\x0c\x00\x00\x80" >> %t.stats
# RUN: printf "\x01\x00\x00\x00\x0e\x00\x00\xa0" >> %t.stats
# RUN: printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> %t.stats

# RUN: sanstats %t.stats | FileCheck %s

# Test that if binaries are not in the original location then sanstats
# searches them next to the stats file.
# RUN: mkdir -p %t.dir
# RUN: mv -f %t1.o %t2.o %t.dir
# RUN: sanstats %t.stats | FileCheck %s --check-prefix=INVALID
# RUN: mv -f %t.stats %t.dir/copy.stats
# RUN: cd %t.dir && sanstats copy.stats | FileCheck %s

# INVALID: <invalid>
# CHECK-NOT: <invalid>
# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 cfi-vcall 1
# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-nvcall 2
# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 cfi-derived-cast 3
# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 cfi-unrelated-cast 4
# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-icall 5
# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 <unknown> 6

# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 cfi-vcall 7
# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-nvcall 8
# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 cfi-derived-cast 9
# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 cfi-unrelated-cast 11
# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-icall 12
# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 <unknown> 14

--- !ELF
FileHeader:      
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_REL
  Machine:         EM_X86_64
Sections:        
  - Name:            .text
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    AddressAlign:    0x0000000000000010
    Content:         554889E55DC3662E0F1F840000000000554889E55DC3662E0F1F840000000000554889E55DC3
  - Name:            .debug_str
    Type:            SHT_PROGBITS
    Flags:           [ SHF_MERGE, SHF_STRINGS ]
    AddressAlign:    0x0000000000000001
    Content:         636C616E672076657273696F6E20332E382E3020287472756E6B203235353339332920286C6C766D2F7472756E6B203235353734352900662E63002F746D7000663100663200663300
  - Name:            .debug_loc
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         ''
  - Name:            .debug_abbrev
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         011101250E1305030E10171B0E110112060000022E00110112064018030E3A0B3B0B3F19000000
  - Name:            .debug_info
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         660000000400000000000801000000000C0000000000000000000000000000000000000000002600000002000000000000000006000000015600000000010102000000000000000006000000015600000000010202000000000000000006000000015600000000010300
  - Name:            .rela.debug_info
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    Info:            .debug_info
    Relocations:     
      - Offset:          0x0000000000000006
        Type:            R_X86_64_32
      - Offset:          0x000000000000000C
        Type:            R_X86_64_32
      - Offset:          0x0000000000000012
        Type:            R_X86_64_32
        Addend:          55
      - Offset:          0x0000000000000016
        Type:            R_X86_64_32
      - Offset:          0x000000000000001A
        Type:            R_X86_64_32
        Addend:          59
      - Offset:          0x000000000000001E
        Type:            R_X86_64_64
      - Offset:          0x000000000000002B
        Type:            R_X86_64_64
      - Offset:          0x0000000000000039
        Type:            R_X86_64_32
        Addend:          64
      - Offset:          0x0000000000000040
        Type:            R_X86_64_64
        Addend:          16
      - Offset:          0x000000000000004E
        Type:            R_X86_64_32
        Addend:          67
      - Offset:          0x0000000000000055
        Type:            R_X86_64_64
        Addend:          32
      - Offset:          0x0000000000000063
        Type:            R_X86_64_32
        Addend:          70
  - Name:            .debug_ranges
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         ''
  - Name:            .debug_pubnames
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         230000000200000000006A0000002A0000006631003F0000006632005400000066330000000000
  - Name:            .rela.debug_pubnames
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    Info:            .debug_pubnames
    Relocations:     
      - Offset:          0x0000000000000006
        Type:            R_X86_64_32
  - Name:            .comment
    Type:            SHT_PROGBITS
    Flags:           [ SHF_MERGE, SHF_STRINGS ]
    AddressAlign:    0x0000000000000001
    Content:         00636C616E672076657273696F6E20332E382E3020287472756E6B203235353339332920286C6C766D2F7472756E6B203235353734352900
  - Name:            .note.GNU-stack
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         ''
  - Name:            .eh_frame
    Type:            SHT_X86_64_UNWIND
    Flags:           [ SHF_ALLOC ]
    AddressAlign:    0x0000000000000008
    Content:         1400000000000000017A5200017810011B0C070890010000180000001C000000000000000600000000410E108602430D060000001800000038000000000000000600000000410E108602430D060000001C00000054000000000000000600000000410E108602430D0600000000000000
  - Name:            .rela.eh_frame
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    Info:            .eh_frame
    Relocations:     
      - Offset:          0x0000000000000020
        Type:            R_X86_64_PC32
      - Offset:          0x000000000000003C
        Type:            R_X86_64_PC32
        Addend:          16
      - Offset:          0x0000000000000058
        Type:            R_X86_64_PC32
        Addend:          32
  - Name:            .debug_line
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         4300000002001A0000000101FB0E0D00010101010000000100000100662E630000000000000902000000000000000001050C0A4A0500BB050C0A4A0500BB050C0A4A0202000101
  - Name:            .rela.debug_line
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    Info:            .debug_line
    Relocations:     
      - Offset:          0x0000000000000027
        Type:            R_X86_64_64
Symbols:
  - Name:            f.c
    Type:            STT_FILE
  - Type:            STT_SECTION
    Section:         .text
  - Type:            STT_SECTION
    Section:         .debug_str
  - Type:            STT_SECTION
    Section:         .debug_abbrev
  - Type:            STT_SECTION
    Section:         .debug_info
  - Type:            STT_SECTION
    Section:         .debug_line
  - Name:            f1
    Type:            STT_FUNC
    Section:         .text
    Size:            0x0000000000000006
    Binding:         STB_GLOBAL
  - Name:            f2
    Type:            STT_FUNC
    Section:         .text
    Value:           0x0000000000000010
    Size:            0x0000000000000006
    Binding:         STB_GLOBAL
  - Name:            f3
    Type:            STT_FUNC
    Section:         .text
    Value:           0x0000000000000020
    Size:            0x0000000000000006
    Binding:         STB_GLOBAL
...
OpenPOWER on IntegriCloud