1# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t
2# RUN: llvm-dwarfdump -debug-info -debug-loclists %t \
3# RUN:   | FileCheck %s --check-prefixes=REGULAR,BOTH
4# RUN: llvm-dwarfdump -debug-info -debug-loclists --verbose %t \
5# RUN:   | FileCheck %s --check-prefixes=VERBOSE,BOTH
6
7
8# BOTH:          DW_AT_location {{.*}}(0x0000000c
9
10# REGULAR-NEXT:      [0x0000000000000000, 0x0000000000000001): DW_OP_reg0 RAX
11# VERBOSE-NEXT:      [0x0000000000000000, 0x0000000000000001) ".text": DW_OP_reg0 RAX
12
13# REGULAR-NEXT:      [0x0000000000000001, 0x0000000000000002): DW_OP_reg1 RDX
14# VERBOSE-NEXT:      [0x0000000000000001, 0x0000000000000002) ".text": DW_OP_reg1 RDX
15
16# REGULAR-NEXT:      [0x0000000000000002, 0x0000000000000003): DW_OP_reg2 RCX
17# VERBOSE-NEXT:      [0x0000000000000002, 0x0000000000000003) ".text": DW_OP_reg2 RCX
18
19# BOTH-NEXT:         <default>: DW_OP_reg3 RBX
20
21# REGULAR-NEXT:      [0x0000000000000004, 0x0000000000000005): DW_OP_reg4 RSI
22# VERBOSE-NEXT:      [0x0000000000000004, 0x0000000000000005) ".text": DW_OP_reg4 RSI
23
24# REGULAR-NEXT:      [0x0000000000000005, 0x0000000000000006): DW_OP_reg5 RDI
25# VERBOSE-NEXT:      [0x0000000000000005, 0x0000000000000006) ".text": DW_OP_reg5 RDI
26
27# REGULAR-NEXT:      [0x0000000000000006, 0x0000000000000007): DW_OP_reg6 RBP
28# VERBOSE-NEXT:      [0x0000000000000006, 0x0000000000000007) ".text": DW_OP_reg6 RBP
29
30# REGULAR-NEXT:      [0x0000000000000007, 0x0000000000000008): DW_OP_reg7 RSP
31# VERBOSE-NEXT:      [0x0000000000000007, 0x0000000000000008) ".text": DW_OP_reg7 RSP
32
33# BOTH-NEXT:         DW_LLE_startx_length (0x000000000000dead, 0x0000000000000001): DW_OP_reg4 RSI)
34
35# BOTH: locations list header: length = 0x00000056, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
36# BOTH-NEXT: 0x0000000c:
37# BOTH-NEXT:     DW_LLE_startx_endx     (0x0000000000000000, 0x0000000000000001): DW_OP_reg0 RAX
38# BOTH-NEXT:     DW_LLE_startx_length   (0x0000000000000001, 0x0000000000000001): DW_OP_reg1 RDX
39# BOTH-NEXT:     DW_LLE_offset_pair     (0x0000000000000002, 0x0000000000000003): DW_OP_reg2 RCX
40
41# REGULAR-NEXT:  <default>: DW_OP_reg3 RBX
42# VERBOSE-NEXT:  DW_LLE_default_location()
43# VERBOSE-NEXT:            => <default>: DW_OP_reg3 RBX
44
45# REGULAR-NEXT:  [0x0000000000000004, 0x0000000000000005): DW_OP_reg4 RSI
46# VERBOSE-NEXT:  DW_LLE_start_end       (0x0000000000000004, 0x0000000000000005) ".text"
47# VERBOSE-NEXT:            => [0x0000000000000004, 0x0000000000000005) ".text": DW_OP_reg4 RSI
48
49# REGULAR-NEXT:  [0x0000000000000005, 0x0000000000000006): DW_OP_reg5 RDI
50# VERBOSE-NEXT:  DW_LLE_start_length    (0x0000000000000005, 0x0000000000000001) ".text"
51# VERBOSE-NEXT:            => [0x0000000000000005, 0x0000000000000006) ".text": DW_OP_reg5 RDI
52
53# BOTH-NEXT:     DW_LLE_base_addressx   (0x0000000000000002)
54
55# BOTH-NEXT:     DW_LLE_offset_pair     (0x0000000000000000, 0x0000000000000001): DW_OP_reg6 RBP
56
57# VERBOSE-NEXT:  DW_LLE_base_address    (0x0000000000000007) ".text"
58
59# REGULAR-NEXT:  [0x0000000000000007, 0x0000000000000008): DW_OP_reg7 RSP
60# VERBOSE-NEXT:  DW_LLE_offset_pair     (0x0000000000000000, 0x0000000000000001)
61# VERBOSE-NEXT:            => [0x0000000000000007, 0x0000000000000008) ".text": DW_OP_reg7 RSP
62
63# BOTH-NEXT:     DW_LLE_startx_length   (0x000000000000dead, 0x0000000000000001): DW_OP_reg4 RSI
64
65# VERBOSE-NEXT:  DW_LLE_end_of_list     ()
66
67
68        .text
69f:                                      # @f
70.Lf0:
71        nop
72.Lf1:
73        nop
74.Lf2:
75        nop
76.Lf3:
77        nop
78.Lf4:
79        nop
80.Lf5:
81        nop
82.Lf6:
83        nop
84.Lf7:
85        nop
86.Lf8:
87.Lfend:
88                                        # -- End function
89        .section        .debug_loclists,"",@progbits
90        .long   .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
91.Ldebug_loclist_table_start0:
92        .short  5                       # Version
93        .byte   8                       # Address size
94        .byte   0                       # Segment selector size
95        .long   0                       # Offset entry count
96.Lloclists_table_base0:
97.Ldebug_loc0:
98        .byte   2                       # DW_LLE_startx_endx
99        .uleb128 0                      #   start idx
100        .uleb128 1                      #   end idx
101        .byte   1                       # Loc expr size
102        .byte   80                      # super-register DW_OP_reg0
103
104        .byte   3                       # DW_LLE_startx_length
105        .uleb128 1                      #   start idx
106        .uleb128 .Lf2-.Lf1              #   length
107        .byte   1                       # Loc expr size
108        .byte   81                      # super-register DW_OP_reg1
109
110        .byte   4                       # DW_LLE_offset_pair
111        .uleb128 .Lf2-.Lf0              #   starting offset
112        .uleb128 .Lf3-.Lf0              #   ending offset
113        .byte   1                       # Loc expr size
114        .byte   82                      # super-register DW_OP_reg2
115
116        .byte   5                       # DW_LLE_default_location
117        .byte   1                       # Loc expr size
118        .byte   83                      # super-register DW_OP_reg3
119
120        .byte   7                       # DW_LLE_start_end
121        .quad   .Lf4                    #   starting offset
122        .quad   .Lf5                    #   ending offset
123        .byte   1                       # Loc expr size
124        .byte   84                      # super-register DW_OP_reg4
125
126        .byte   8                       # DW_LLE_start_length
127        .quad   .Lf5                    #   starting offset
128        .uleb128 .Lf6-.Lf5              #   length
129        .byte   1                       # Loc expr size
130        .byte   85                      # super-register DW_OP_reg5
131
132        .byte   1                       # DW_LLE_base_addressx
133        .uleb128 2                      #   base address
134
135        .byte   4                       # DW_LLE_offset_pair
136        .uleb128 .Lf6-.Lf6              #   starting offset
137        .uleb128 .Lf7-.Lf6              #   ending offset
138        .byte   1                       # Loc expr size
139        .byte   86                      # super-register DW_OP_reg6
140
141        .byte   6                       # DW_LLE_base_address
142        .quad   .Lf7                    #   base address
143
144        .byte   4                       # DW_LLE_offset_pair
145        .uleb128 .Lf7-.Lf7              #   starting offset
146        .uleb128 .Lf8-.Lf7              #   ending offset
147        .byte   1                       # Loc expr size
148        .byte   87                      # super-register DW_OP_reg7
149
150        .byte   3                       # DW_LLE_startx_length
151        .uleb128 0xdead                 #   start idx
152        .uleb128 .Lf1-.Lf0              #   length
153        .byte   1                       # Loc expr size
154        .byte   84                      # super-register DW_OP_reg4
155
156        .byte   0                       # DW_LLE_end_of_list
157.Ldebug_loclist_table_end0:
158
159        .section        .debug_abbrev,"",@progbits
160        .byte   1                       # Abbreviation Code
161        .byte   17                      # DW_TAG_compile_unit
162        .byte   1                       # DW_CHILDREN_yes
163        .byte   115                     # DW_AT_addr_base
164        .byte   23                      # DW_FORM_sec_offset
165        .ascii  "\214\001"              # DW_AT_loclists_base
166        .byte   23                      # DW_FORM_sec_offset
167        .byte   17                      # DW_AT_low_pc
168        .byte   27                      # DW_FORM_addrx
169        .byte   18                      # DW_AT_high_pc
170        .byte   6                       # DW_FORM_data4
171        .byte   0                       # EOM(1)
172        .byte   0                       # EOM(2)
173        .byte   2                       # Abbreviation Code
174        .byte   46                      # DW_TAG_subprogram
175        .byte   1                       # DW_CHILDREN_yes
176        .byte   17                      # DW_AT_low_pc
177        .byte   27                      # DW_FORM_addrx
178        .byte   18                      # DW_AT_high_pc
179        .byte   6                       # DW_FORM_data4
180        .byte   0                       # EOM(1)
181        .byte   0                       # EOM(2)
182        .byte   3                       # Abbreviation Code
183        .byte   5                       # DW_TAG_formal_parameter
184        .byte   0                       # DW_CHILDREN_no
185        .byte   2                       # DW_AT_location
186        .byte   23                      # DW_FORM_sec_offset
187        .byte   0                       # EOM(1)
188        .byte   0                       # EOM(2)
189        .byte   0                       # EOM(3)
190        .section        .debug_info,"",@progbits
191.Lcu_begin0:
192        .long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
193.Ldebug_info_start0:
194        .short  5                       # DWARF version number
195        .byte   1                       # DWARF Unit Type
196        .byte   8                       # Address Size (in bytes)
197        .long   .debug_abbrev           # Offset Into Abbrev. Section
198        .byte   1                       # Abbrev [1] 0xc:0x3c DW_TAG_compile_unit
199        .long   .Laddr_table_base0      # DW_AT_addr_base
200        .long   .Lloclists_table_base0  # DW_AT_loclists_base
201        .byte   0                       # DW_AT_low_pc
202        .long   .Lfend-.Lf0             # DW_AT_high_pc
203        .byte   2                       # Abbrev [2] 0x27:0x1c DW_TAG_subprogram
204        .byte   0                       # DW_AT_low_pc
205        .long   .Lfend-.Lf0             # DW_AT_high_pc
206        .byte   3                       # Abbrev [3] 0x36:0xc DW_TAG_formal_parameter
207        .long   .Ldebug_loc0            # DW_AT_location
208        .byte   0                       # End Of Children Mark
209        .byte   0                       # End Of Children Mark
210.Ldebug_info_end0:
211
212        .section        .debug_addr,"",@progbits
213        .long   .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
214.Ldebug_addr_start0:
215        .short  5                       # DWARF version number
216        .byte   8                       # Address size
217        .byte   0                       # Segment selector size
218.Laddr_table_base0:
219        .quad   .Lf0
220        .quad   .Lf1
221        .quad   .Lf6
222.Ldebug_addr_end0:
223