1# This test checks the handling of location lists in the case when the module is
2# not loaded at the address at which it was linked (as happens with ASLR for
3# instance).
4
5# REQUIRES: x86
6
7# RUN: yaml2obj %S/Inputs/debug_loc-aslr.yaml -o %t.dmp
8# RUN: llvm-mc --triple=x86_64-pc-linux --filetype=obj %s >%t.o
9# RUN: %lldb -c %t.dmp -o "image add %t.o" \
10# RUN:   -o "image load --file %t.o --slide 0x470000" \
11# RUN:   -o "thread info" -o "frame variable" -o exit | FileCheck %s
12
13# CHECK: thread #1: tid = 16001, 0x0000000000470001 {{.*}}`_start
14# CHECK: (int) x = 47
15# CHECK: (int) y = 74
16
17        .text
18        .globl _start
19_start:
20        nop
21        retq
22.Lstart_end:
23
24        .section        .debug_loc,"",@progbits
25# This location list implicitly uses the base address of the compile unit.
26.Ldebug_loc0:
27        .quad   _start-_start
28        .quad   .Lstart_end-_start
29        .short  3                       # Loc expr size
30        .byte   8                       # DW_OP_const1u
31        .byte   47
32        .byte   159                     # DW_OP_stack_value
33        .quad   0
34        .quad   0
35
36# This is an equivalent location list to the first one, but here the base
37# address is set explicitly.
38.Ldebug_loc1:
39        .quad   -1
40        .quad   _start
41        .quad   _start-_start
42        .quad   .Lstart_end-_start
43        .short  3                       # Loc expr size
44        .byte   8                       # DW_OP_const1u
45        .byte   74
46        .byte   159                     # DW_OP_stack_value
47        .quad   0
48        .quad   0
49
50        .section        .debug_abbrev,"",@progbits
51        .byte   1                       # Abbreviation Code
52        .byte   17                      # DW_TAG_compile_unit
53        .byte   1                       # DW_CHILDREN_yes
54        .byte   37                      # DW_AT_producer
55        .byte   8                       # DW_FORM_string
56        .byte   19                      # DW_AT_language
57        .byte   5                       # DW_FORM_data2
58        .byte   17                      # DW_AT_low_pc
59        .byte   1                       # DW_FORM_addr
60        .byte   18                      # DW_AT_high_pc
61        .byte   6                       # DW_FORM_data4
62        .byte   0                       # EOM(1)
63        .byte   0                       # EOM(2)
64        .byte   2                       # Abbreviation Code
65        .byte   46                      # DW_TAG_subprogram
66        .byte   1                       # DW_CHILDREN_yes
67        .byte   17                      # DW_AT_low_pc
68        .byte   1                       # DW_FORM_addr
69        .byte   18                      # DW_AT_high_pc
70        .byte   6                       # DW_FORM_data4
71        .byte   3                       # DW_AT_name
72        .byte   8                       # DW_FORM_string
73        .byte   0                       # EOM(1)
74        .byte   0                       # EOM(2)
75        .byte   4                       # Abbreviation Code
76        .byte   52                      # DW_TAG_variable
77        .byte   0                       # DW_CHILDREN_no
78        .byte   2                       # DW_AT_location
79        .byte   23                      # DW_FORM_sec_offset
80        .byte   3                       # DW_AT_name
81        .byte   8                       # DW_FORM_string
82        .byte   73                      # DW_AT_type
83        .byte   19                      # DW_FORM_ref4
84        .byte   0                       # EOM(1)
85        .byte   0                       # EOM(2)
86        .byte   6                       # Abbreviation Code
87        .byte   36                      # DW_TAG_base_type
88        .byte   0                       # DW_CHILDREN_no
89        .byte   3                       # DW_AT_name
90        .byte   8                       # DW_FORM_string
91        .byte   62                      # DW_AT_encoding
92        .byte   11                      # DW_FORM_data1
93        .byte   11                      # DW_AT_byte_size
94        .byte   11                      # DW_FORM_data1
95        .byte   0                       # EOM(1)
96        .byte   0                       # EOM(2)
97        .byte   0                       # EOM(3)
98        .section        .debug_info,"",@progbits
99.Lcu_begin0:
100        .long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
101.Ldebug_info_start0:
102        .short  4                       # DWARF version number
103        .long   .debug_abbrev           # Offset Into Abbrev. Section
104        .byte   8                       # Address Size (in bytes)
105        .byte   1                       # Abbrev [1] 0xb:0x6a DW_TAG_compile_unit
106        .asciz  "Hand-written DWARF"    # DW_AT_producer
107        .short  12                      # DW_AT_language
108        .quad   _start                  # DW_AT_low_pc
109        .long   .Lstart_end-_start      # DW_AT_high_pc
110        .byte   2                       # Abbrev [2] 0x2a:0x43 DW_TAG_subprogram
111        .quad   _start                  # DW_AT_low_pc
112        .long   .Lstart_end-_start      # DW_AT_high_pc
113        .asciz  "_start"                # DW_AT_name
114        .byte   4                       # Abbrev [4] 0x52:0xf DW_TAG_variable
115        .long   .Ldebug_loc0            # DW_AT_location
116        .asciz  "x"                     # DW_AT_name
117        .long   .Lint                   # DW_AT_type
118        .byte   4                       # Abbrev [4] 0x52:0xf DW_TAG_variable
119        .long   .Ldebug_loc1            # DW_AT_location
120        .asciz  "y"                     # DW_AT_name
121        .long   .Lint                   # DW_AT_type
122        .byte   0                       # End Of Children Mark
123.Lint:
124        .byte   6                       # Abbrev [6] 0x6d:0x7 DW_TAG_base_type
125        .asciz  "int"                   # DW_AT_name
126        .byte   5                       # DW_AT_encoding
127        .byte   4                       # DW_AT_byte_size
128        .byte   0                       # End Of Children Mark
129.Ldebug_info_end0:
130