File: data-location.yaml

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (450 lines) | stat: -rw-r--r-- 15,545 bytes parent folder | download | duplicates (13)
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
## Show that when "DATA" is used with an address, it forces the found location
## to be symbolized as data, including the source information.

# RUN: yaml2obj %s -o %t.so

# RUN: llvm-symbolizer 'DATA 0x304d0' 'DATA 0x304d1' 'DATA 0x304d3' \
# RUN:   'DATA 0x304c0' 'DATA 0x304c8' 'DATA 0x304d4' 'DATA 0x304dc' \
# RUN:   'DATA 0x304d8' --obj=%t.so | FileCheck %s

# CHECK:      bss_global
# CHECK-NEXT: {{[0-9]+}} 4
# CHECK-NEXT: /tmp/file.cpp:1
# CHECK-EMPTY:

## Check that lookups in the middle of the symbol are also resolved correctly.
# CHECK:      bss_global
# CHECK-NEXT: {{[0-9]+}} 4
# CHECK-NEXT: /tmp/file.cpp:1
# CHECK-EMPTY:
# CHECK:      bss_global
# CHECK-NEXT: {{[0-9]+}} 4
# CHECK-NEXT: /tmp/file.cpp:1
# CHECK-EMPTY:

## Now, the remainder of the symbols.
# CHECK-NEXT: data_global
# CHECK-NEXT: {{[0-9]+}} 4
# CHECK-NEXT: /tmp/file.cpp:2
# CHECK-EMPTY:
# CHECK-NEXT: str
# CHECK-NEXT: {{[0-9]+}} 8
# CHECK-NEXT: /tmp/file.cpp:4
# CHECK-EMPTY:
# CHECK-NEXT: f()::function_global
# CHECK-NEXT: {{[0-9]+}} 4
# CHECK-NEXT: /tmp/file.cpp:8
# CHECK-EMPTY:

## Including the one that includes an addend.
# CHECK-NEXT: alpha
# CHECK-NEXT: {{[0-9]+}} 4
# CHECK-NEXT: /tmp/file.cpp:12
# CHECK-EMPTY:
# CHECK-NEXT: beta
# CHECK-NEXT: {{[0-9]+}} 4
# CHECK-NEXT: /tmp/file.cpp:13
# CHECK-EMPTY:

## Ensure there's still a global that's offset-based.
# RUN: llvm-dwarfdump --debug-info %t.so | FileCheck %s --check-prefix=OFFSET

# OFFSET: DW_AT_location (DW_OP_addrx 0x4, DW_OP_plus_uconst 0x4)

################################################################################
## File below was generated using:
##
##   $ clang++ -g -O3 /tmp/file.cpp -shared -fuse-ld=lld -nostdlib \
##     -target aarch64-linux-gnuabi -mllvm -global-merge-ignore-single-use \
##     -o /tmp/file.so
##
##  With /tmp/file.cpp as:
##    1: int bss_global;
##    2: int data_global = 2;
##    3:
##    4: const char* str =
##    5:     "12345678";
##    6:
##    7: int* f() {
##    8:   static int function_global;
##    9:   return &function_global;
##   10: }
##   11:
##   12: static int alpha;
##   13: static int beta;
##   14: int *f(bool b) { return beta ? &alpha : β }
##   15:
##
## ... then, one can get the offsets using `nm`, like:
##   $ nm out.so | grep bss_global
##     00000000000038fc B bss_global
##
## Note the use of the aarch64 target (with -nostdlib in order to allow linkage
## without libraries for cross-compilation) as well as -O3 and
## -global-merge-ignore-single-use. This is a specific combination that makes
## the compiler emit the `alpha` global variable with a more complex
## DW_AT_location than just a DW_OP_addr/DW_OP_addrx. In this instance, it
## outputs a `DW_AT_location  (DW_OP_addrx 0x4, DW_OP_plus_uconst 0x4)`.
##
## Ideally, this would be tested by invoking clang directly on a C source file,
## but unfortunately there's no way to do that for LLVM tests. The other option
## is to compile IR to an objfile, but llvm-symbolizer doesn't understand that
## two symbols can have the same address in different sections. In the code
## above, for example, we'd have bss_global at .bss+0x0, and data_global at
## .data+0x0, and so the symbolizer would only print one of them. Hence, we have
## the ugly dso-to-yaml blob below.
##
## For now, constant strings don't have a debuginfo entry, and so can't be
## symbolized correctly. In future (if D123534 gets merged), this can be updated
## to include a check that llvm-symbolizer can also symbolize constant strings,
## like `str` above (basically that &"12345678" should be symbolizable)
## to the specific line. Then, you can find the address of the constant string
## from the relocation:
##
##   $ nm out.so | grep str
##     00000000000038c0 D str
##   $ llvm-objdump -R out.so | grep 38c0
##     00000000000038c0 R_X86_64_RELATIVE *ABS*+0x4f8 # <-- 0x4f8
################################################################################

--- !ELF
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_DYN
  Machine:         EM_AARCH64
ProgramHeaders:
  - Type:            PT_PHDR
    Flags:           [ PF_R ]
    VAddr:           0x40
    Align:           0x8
  - Type:            PT_LOAD
    Flags:           [ PF_R ]
    FirstSec:        .dynsym
    LastSec:         .eh_frame
    Align:           0x10000
  - Type:            PT_LOAD
    Flags:           [ PF_X, PF_R ]
    FirstSec:        .text
    LastSec:         .text
    VAddr:           0x103E4
    Align:           0x10000
  - Type:            PT_LOAD
    Flags:           [ PF_W, PF_R ]
    FirstSec:        .dynamic
    LastSec:         .dynamic
    VAddr:           0x20410
    Align:           0x10000
  - Type:            PT_LOAD
    Flags:           [ PF_W, PF_R ]
    FirstSec:        .data
    LastSec:         .bss
    VAddr:           0x304C0
    Align:           0x10000
  - Type:            PT_DYNAMIC
    Flags:           [ PF_W, PF_R ]
    FirstSec:        .dynamic
    LastSec:         .dynamic
    VAddr:           0x20410
    Align:           0x8
  - Type:            PT_GNU_RELRO
    Flags:           [ PF_R ]
    FirstSec:        .dynamic
    LastSec:         .dynamic
    VAddr:           0x20410
  - Type:            PT_GNU_EH_FRAME
    Flags:           [ PF_R ]
    FirstSec:        .eh_frame_hdr
    LastSec:         .eh_frame_hdr
    VAddr:           0x37C
    Align:           0x4
  - Type:            PT_GNU_STACK
    Flags:           [ PF_W, PF_R ]
    Align:           0x0
Sections:
  - Name:            .dynsym
    Type:            SHT_DYNSYM
    Flags:           [ SHF_ALLOC ]
    Address:         0x238
    Link:            .dynstr
    AddressAlign:    0x8
  - Name:            .gnu.hash
    Type:            SHT_GNU_HASH
    Flags:           [ SHF_ALLOC ]
    Address:         0x2C8
    Link:            .dynsym
    AddressAlign:    0x8
    Header:
      SymNdx:          0x1
      Shift2:          0x1A
    BloomFilter:     [ 0x400188002180000C ]
    HashBuckets:     [ 0x1 ]
    HashValues:      [ 0xEE8502A, 0xEE85016, 0xC033991C, 0x61F7372E, 0xB88AB7F ]
  - Name:            .hash
    Type:            SHT_HASH
    Flags:           [ SHF_ALLOC ]
    Address:         0x2F8
    Link:            .dynsym
    AddressAlign:    0x4
    Bucket:          [ 5, 0, 4, 0, 3, 0 ]
    Chain:           [ 0, 0, 0, 1, 2, 0 ]
  - Name:            .dynstr
    Type:            SHT_STRTAB
    Flags:           [ SHF_ALLOC ]
    Address:         0x330
    AddressAlign:    0x1
  - Name:            .rela.dyn
    Type:            SHT_RELA
    Flags:           [ SHF_ALLOC ]
    Address:         0x358
    Link:            .dynsym
    AddressAlign:    0x8
    Relocations:
      - Offset:          0x304C8
        Type:            R_AARCH64_RELATIVE
        Addend:          880
  - Name:            .rodata
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
    Address:         0x370
    AddressAlign:    0x1
    EntSize:         0x1
    Content:         '313233343536373800'
  - Name:            .eh_frame_hdr
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC ]
    Address:         0x37C
    AddressAlign:    0x4
    Content:         011B033B18000000020000006800010034000000740001004C000000
  - Name:            .eh_frame
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC ]
    Address:         0x398
    AddressAlign:    0x8
    Content:         1400000000000000017A5200017C1E011B0C1F0000000000140000001C0000002C0001000C00000000000000000000001400000034000000200001001C000000000000000000000000000000
  - Name:            .text
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    Address:         0x103E4
    AddressAlign:    0x4
    Content:         0001009000501391C0035FD60801009008611391E90308AA2A4540B85F0100710001899AC0035FD6
  - Name:            .dynamic
    Type:            SHT_DYNAMIC
    Flags:           [ SHF_WRITE, SHF_ALLOC ]
    Address:         0x20410
    Link:            .dynstr
    AddressAlign:    0x8
    Entries:
      - Tag:             DT_RELA
        Value:           0x358
      - Tag:             DT_RELASZ
        Value:           0x18
      - Tag:             DT_RELAENT
        Value:           0x18
      - Tag:             DT_RELACOUNT
        Value:           0x1
      - Tag:             DT_SYMTAB
        Value:           0x238
      - Tag:             DT_SYMENT
        Value:           0x18
      - Tag:             DT_STRTAB
        Value:           0x330
      - Tag:             DT_STRSZ
        Value:           0x28
      - Tag:             DT_GNU_HASH
        Value:           0x2C8
      - Tag:             DT_HASH
        Value:           0x2F8
      - Tag:             DT_NULL
        Value:           0x0
  - Name:            .data
    Type:            SHT_PROGBITS
    Flags:           [ SHF_WRITE, SHF_ALLOC ]
    Address:         0x304C0
    AddressAlign:    0x8
    Content:         '02000000000000000000000000000000'
  - Name:            .bss
    Type:            SHT_NOBITS
    Flags:           [ SHF_WRITE, SHF_ALLOC ]
    Address:         0x304D0
    AddressAlign:    0x4
    Size:            0x10
  - Name:            .debug_abbrev
    Type:            SHT_PROGBITS
    AddressAlign:    0x1
    Content:         011101252513050325721710171B25111B120673170000023400032549133F193A0B3B0B0218000003240003253E0B0B0B0000040F004913000005260049130000062E01111B120640187A196E2503253A0B3B0B49133F190000073400032549133A0B3B0B02180000083400032549133A0B3B0B02186E25000009050003253A0B3B0B4913000000
  - Name:            .debug_info
    Type:            SHT_PROGBITS
    AddressAlign:    0x1
    Content:         AB0000000500010800000000010021000108000000000000000205280000000800000002032E000000000102A1000304050402052E000000000202A101020648000000000402A102044D00000005520000000307080106050C000000016F0D0E0007A500000007082E000000000802A1030008092E000000000D02A1040A080B2E000000000C04A10423040C06061C000000016F0F0E000EA50000000910000EAA00000000042E0000000311020100
  - Name:            .debug_str_offsets
    Type:            SHT_PROGBITS
    AddressAlign:    0x1
    Content:         4C00000005000000A2000000000000002C00000059000000280000001C00000072000000640000008C0000008700000069000000140000007B0000009C0000001A0000000E0000008500000076000000
  - Name:            .comment
    Type:            SHT_PROGBITS
    Flags:           [ SHF_MERGE, SHF_STRINGS ]
    AddressAlign:    0x1
    EntSize:         0x1
    Content:         4C696E6B65723A204C4C442031352E302E300000636C616E672076657273696F6E2031352E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A6563742E67697420306462616566363162353666306566306162306366333865613932666663316633356265653366662900
  - Name:            .debug_line
    Type:            SHT_PROGBITS
    AddressAlign:    0x1
    Content:         620000000500080037000000010101FB0E0D00010101010000000100000101011F010E00000003011F020F051E0100000000006C97BBE59F7DC6A9EA956633431DA63E0400000902E4030100000000001805030A140500BF05190A0105120608740204000101
  - Name:            .debug_line_str
    Type:            SHT_PROGBITS
    Flags:           [ SHF_MERGE, SHF_STRINGS ]
    AddressAlign:    0x1
    EntSize:         0x1
    Content:         2F746D702F66696C652E637070002F7573722F6C6F63616C2F676F6F676C652F686F6D652F6D69746368702F6C6C766D2D6275696C642F6F707400
Symbols:
  - Name:            file.cpp
    Type:            STT_FILE
    Index:           SHN_ABS
  - Name:            '$x.0'
    Section:         .text
    Value:           0x103E4
  - Name:            _ZZ1fvE15function_global
    Type:            STT_OBJECT
    Section:         .bss
    Value:           0x304D4
    Size:            0x4
  - Name:            '$d.1'
    Section:         .bss
    Value:           0x304D0
  - Name:            '$d.2'
    Section:         .data
    Value:           0x304C0
  - Name:            '$d.3'
    Section:         .rodata
    Value:           0x370
  - Name:            '$d.4'
    Section:         .debug_abbrev
  - Name:            '$d.5'
    Section:         .debug_info
  - Name:            '$d.6'
    Section:         .debug_str_offsets
  - Name:            '$d.7'
    Section:         .debug_str
    Value:           0xA2
  - Name:            '$d.8'
    Section:         .debug_addr
  - Name:            _ZL4beta
    Type:            STT_OBJECT
    Section:         .bss
    Value:           0x304D8
    Size:            0x4
  - Name:            _ZL5alpha
    Type:            STT_OBJECT
    Section:         .bss
    Value:           0x304DC
    Size:            0x4
  - Name:            '$d.9'
    Section:         .comment
    Value:           0x13
  - Name:            '$d.10'
    Section:         .eh_frame
    Value:           0x398
  - Name:            '$d.11'
    Section:         .debug_line
  - Name:            '$d.12'
    Section:         .debug_line_str
    Value:           0xE
  - Name:            _DYNAMIC
    Section:         .dynamic
    Value:           0x20410
    Other:           [ STV_HIDDEN ]
  - Name:            _Z1fv
    Type:            STT_FUNC
    Section:         .text
    Binding:         STB_GLOBAL
    Value:           0x103E4
    Size:            0xC
  - Name:            _Z1fb
    Type:            STT_FUNC
    Section:         .text
    Binding:         STB_GLOBAL
    Value:           0x103F0
    Size:            0x1C
  - Name:            bss_global
    Type:            STT_OBJECT
    Section:         .bss
    Binding:         STB_GLOBAL
    Value:           0x304D0
    Size:            0x4
  - Name:            data_global
    Type:            STT_OBJECT
    Section:         .data
    Binding:         STB_GLOBAL
    Value:           0x304C0
    Size:            0x4
  - Name:            str
    Type:            STT_OBJECT
    Section:         .data
    Binding:         STB_GLOBAL
    Value:           0x304C8
    Size:            0x8
DynamicSymbols:
  - Name:            _Z1fv
    Type:            STT_FUNC
    Section:         .text
    Binding:         STB_GLOBAL
    Value:           0x103E4
    Size:            0xC
  - Name:            _Z1fb
    Type:            STT_FUNC
    Section:         .text
    Binding:         STB_GLOBAL
    Value:           0x103F0
    Size:            0x1C
  - Name:            bss_global
    Type:            STT_OBJECT
    Section:         .bss
    Binding:         STB_GLOBAL
    Value:           0x304D0
    Size:            0x4
  - Name:            data_global
    Type:            STT_OBJECT
    Section:         .data
    Binding:         STB_GLOBAL
    Value:           0x304C0
    Size:            0x4
  - Name:            str
    Type:            STT_OBJECT
    Section:         .data
    Binding:         STB_GLOBAL
    Value:           0x304C8
    Size:            0x8
DWARF:
  debug_str:
    - '/tmp/file.cpp'
    - _Z1fb
    - alpha
    - f
    - data_global
    - int
    - '/usr/local/google/home/mitchp/llvm-build/opt'
    - bss_global
    - char
    - _ZL4beta
    - str
    - bool
    - _ZL5alpha
    - b
    - beta
    - function_global
    - _Z1fv
    - 'clang version 15.0.0 (https://github.com/llvm/llvm-project.git 0dbaef61b56f0ef0ab0cf38ea92ffc1f35bee3ff)'
  debug_addr:
    - Length:          0x3C
      Version:         0x5
      AddressSize:     0x8
      Entries:
        - Address:         0x304D0
        - Address:         0x304C0
        - Address:         0x304C8
        - Address:         0x304D4
        - Address:         0x304D8
        - Address:         0x103E4
        - Address:         0x103F0
...