1 # Test handling of (optimized-out/location-less) variables whose value is
2 # specified by DW_AT_const_value
4 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
6 # RUN: -o "target variable udata data1 data2 data4 data8 string strp ref4 udata_ptr" \
7 # RUN: -o exit | FileCheck %s
9 # CHECK-LABEL: target variable
10 ## Variable specified via DW_FORM_udata. This is typical for clang (10).
11 # CHECK: (unsigned long) udata = 4742474247424742
12 ## Variables specified via fixed-size forms. This is typical for gcc (9).
13 # CHECK: (unsigned long) data1 = 47
14 # CHECK: (unsigned long) data2 = 4742
15 # CHECK: (unsigned long) data4 = 47424742
16 # CHECK: (unsigned long) data8 = 4742474247424742
17 ## Variables specified using string forms. This behavior purely speculative -- I
18 ## don't know of any compiler that would represent character strings this way.
19 # CHECK: (char[7]) string = "string"
20 # CHECK: (char[7]) strp = "strp"
21 ## Bogus attribute form. Let's make sure we don't crash at least.
22 # CHECK: (char[7]) ref4 = <empty constant data>
23 ## A variable of pointer type.
24 # CHECK: (unsigned long *) udata_ptr = 0xdeadbeefbaadf00d
26 .section .debug_abbrev,"",@progbits
27 .byte 1 # Abbreviation Code
28 .byte 17 # DW_TAG_compile_unit
29 .byte 1 # DW_CHILDREN_yes
30 .byte 37 # DW_AT_producer
31 .byte 8 # DW_FORM_string
33 .byte 8 # DW_FORM_string
36 .byte 2 # Abbreviation Code
37 .byte 15 # DW_TAG_pointer_type
38 .byte 0 # DW_CHILDREN_no
40 .byte 19 # DW_FORM_ref4
43 .byte 4 # Abbreviation Code
44 .byte 1 # DW_TAG_array_type
45 .byte 1 # DW_CHILDREN_yes
47 .byte 19 # DW_FORM_ref4
50 .byte 5 # Abbreviation Code
51 .byte 33 # DW_TAG_subrange_type
52 .byte 0 # DW_CHILDREN_no
54 .byte 19 # DW_FORM_ref4
55 .byte 55 # DW_AT_count
56 .byte 11 # DW_FORM_data1
59 .byte 6 # Abbreviation Code
60 .byte 36 # DW_TAG_base_type
61 .byte 0 # DW_CHILDREN_no
63 .byte 8 # DW_FORM_string
64 .byte 11 # DW_AT_byte_size
65 .byte 11 # DW_FORM_data1
66 .byte 62 # DW_AT_encoding
67 .byte 11 # DW_FORM_data1
71 .byte \code # Abbreviation Code
72 .byte 52 # DW_TAG_variable
73 .byte 0 # DW_CHILDREN_no
75 .byte 8 # DW_FORM_string
77 .byte 19 # DW_FORM_ref4
78 .byte 28 # DW_AT_const_value
83 var
10, 0xf # DW_FORM_udata
84 var
11, 0xb # DW_FORM_data1
85 var
12, 0x5 # DW_FORM_data2
86 var
13, 0x6 # DW_FORM_data4
87 var
14, 0x7 # DW_FORM_data8
88 var
15, 0x8 # DW_FORM_string
89 var
16, 0xe # DW_FORM_strp
90 var
17, 0x13 # DW_FORM_ref4
92 .section .debug_info,"",@progbits
94 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
96 .short 4 # DWARF version number
97 .long .debug_abbrev # Offset Into Abbrev. Section
98 .byte 8 # Address Size (in bytes)
99 .byte 1 # Abbrev DW_TAG_compile_unit
100 .asciz "Hand-written DWARF" # DW_AT_producer
101 .asciz "const.c" # DW_AT_name
103 .byte 4 # Abbrev DW_TAG_array_type
104 .long .Lchar-.Lcu_begin0 # DW_AT_type
105 .byte 5 # Abbrev DW_TAG_subrange_type
106 .long .Lulong-.Lcu_begin0 # DW_AT_type
107 .byte 7 # DW_AT_count
108 .byte 0 # End Of Children Mark
110 .byte 6 # Abbrev DW_TAG_base_type
111 .asciz "char" # DW_AT_name
112 .byte 1 # DW_AT_byte_size
113 .byte 6 # DW_AT_encoding
115 .byte 6 # Abbrev DW_TAG_base_type
116 .asciz "unsigned long" # DW_AT_name
117 .byte 8 # DW_AT_byte_size
118 .byte 7 # DW_AT_encoding
120 .byte 2 # Abbrev DW_TAG_pointer_type
121 .long .Lulong-.Lcu_begin0 # DW_AT_type
123 .byte 10 # Abbrev DW_TAG_variable
124 .asciz "udata" # DW_AT_name
125 .long .Lulong-.Lcu_begin0 # DW_AT_type
126 .uleb128 4742474247424742 # DW_AT_const_value
128 .byte 11 # Abbrev DW_TAG_variable
129 .asciz "data1" # DW_AT_name
130 .long .Lulong-.Lcu_begin0 # DW_AT_type
131 .byte 47 # DW_AT_const_value
133 .byte 12 # Abbrev DW_TAG_variable
134 .asciz "data2" # DW_AT_name
135 .long .Lulong-.Lcu_begin0 # DW_AT_type
136 .word 4742 # DW_AT_const_value
138 .byte 13 # Abbrev DW_TAG_variable
139 .asciz "data4" # DW_AT_name
140 .long .Lulong-.Lcu_begin0 # DW_AT_type
141 .long 47424742 # DW_AT_const_value
143 .byte 14 # Abbrev DW_TAG_variable
144 .asciz "data8" # DW_AT_name
145 .long .Lulong-.Lcu_begin0 # DW_AT_type
146 .quad 4742474247424742 # DW_AT_const_value
148 .byte 15 # Abbrev DW_TAG_variable
149 .asciz "string" # DW_AT_name
150 .long .Lchar_arr-.Lcu_begin0 # DW_AT_type
151 .asciz "string" # DW_AT_const_value
153 .byte 16 # Abbrev DW_TAG_variable
154 .asciz "strp" # DW_AT_name
155 .long .Lchar_arr-.Lcu_begin0 # DW_AT_type
156 .long .Lstrp # DW_AT_const_value
158 .byte 17 # Abbrev DW_TAG_variable
159 .asciz "ref4" # DW_AT_name
160 .long .Lchar_arr-.Lcu_begin0 # DW_AT_type
161 .long .Lulong-.Lcu_begin0 # DW_AT_const_value
163 .byte 10 # Abbrev DW_TAG_variable
164 .asciz "udata_ptr" # DW_AT_name
165 .long .Lulong_ptr-.Lcu_begin0 # DW_AT_type
166 .uleb128 0xdeadbeefbaadf00d # DW_AT_const_value
168 .byte 0 # End Of Children Mark
171 .section .debug_str,"MS",@progbits,1