1# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o 2# RUN: llvm-dwarfdump -v %t.o | FileCheck %s 3 4# Test object to verify that dwarfdump handles dwp files with DWARF v5 string 5# offset tables. We have 3 CUs and 2 TUs, where it is assumed that 6# CU1 and TU1 came from one object file, CU2 and TU2 from a second object 7# file, and CU3 from a third object file that was compiled with 8# -gdwarf-4. 9# 10 .section .debug_str.dwo,"MS",@progbits,1 11str_producer: 12 .asciz "Handmade DWARF producer" 13str_CU1: 14 .asciz "Compile_Unit_1" 15str_CU1_dir: 16 .asciz "/home/test/CU1" 17str_CU2: 18 .asciz "Compile_Unit_2" 19str_CU2_dir: 20 .asciz "/home/test/CU2" 21str_TU1: 22 .asciz "Type_Unit_1" 23str_TU1_type: 24 .asciz "MyStruct_1" 25str_TU2: 26 .asciz "Type_Unit_2" 27str_TU2_type: 28 .asciz "MyStruct_2" 29str_CU3: 30 .asciz "Compile_Unit_3" 31str_CU3_dir: 32 .asciz "/home/test/CU3" 33 34 .section .debug_str_offsets.dwo,"",@progbits 35# Object files 1's portion of the .debug_str_offsets.dwo section. 36# CU1 and TU1 share a contribution to the string offsets table. 37.debug_str_offsets_object_file1_start: 38 .long .debug_str_offsets_object_file1_end-.debug_str_offsets_base_1 39 .short 5 # DWARF version 40 .short 0 # Padding 41.debug_str_offsets_base_1: 42 .long str_producer-.debug_str.dwo 43 .long str_CU1-.debug_str.dwo 44 .long str_CU1_dir-.debug_str.dwo 45 .long str_TU1-.debug_str.dwo 46 .long str_TU1_type-.debug_str.dwo 47.debug_str_offsets_object_file1_end: 48 49# Object files 2's portion of the .debug_str_offsets.dwo section. 50# CU2 and TU2 share a contribution to the string offsets table. 51.debug_str_offsets_object_file2_start: 52 .long .debug_str_offsets_object_file2_end-.debug_str_offsets_base_2 53 .short 5 # DWARF version 54 .short 0 # Padding 55.debug_str_offsets_base_2: 56 .long str_producer-.debug_str.dwo 57 .long str_CU2-.debug_str.dwo 58 .long str_CU2_dir-.debug_str.dwo 59 .long str_TU2-.debug_str.dwo 60 .long str_TU2_type-.debug_str.dwo 61.debug_str_offsets_object_file2_end: 62 63# Object files 3's portion of the .debug_str_offsets.dwo section. 64# This file is assumed to have been compiled with -gdwarf-4 and 65# therefore contains a version 4 CU and a GNU format contribution 66# to the .debug_str_offsets section. 67.debug_str_offsets_object_file3_start: 68.debug_str_offsets_base_3: 69 .long str_producer-.debug_str.dwo 70 .long str_CU3-.debug_str.dwo 71 .long str_CU3_dir-.debug_str.dwo 72.debug_str_offsets_object_file3_end: 73 74# Abbrevs are shared for all compile and type units 75 .section .debug_abbrev.dwo,"",@progbits 76 .byte 0x01 # Abbrev code 77 .byte 0x11 # DW_TAG_compile_unit 78 .byte 0x00 # DW_CHILDREN_no 79 .byte 0x25 # DW_AT_producer 80 .byte 0x1a # DW_FORM_strx 81 .byte 0x03 # DW_AT_name 82 .byte 0x1a # DW_FORM_strx 83 .byte 0x03 # DW_AT_name 84 .byte 0x1a # DW_FORM_strx 85 .byte 0x00 # EOM(1) 86 .byte 0x00 # EOM(2) 87 .byte 0x02 # Abbrev code 88 .byte 0x41 # DW_TAG_type_unit 89 .byte 0x01 # DW_CHILDREN_yes 90 .byte 0x03 # DW_AT_name 91 .byte 0x1a # DW_FORM_strx 92 .byte 0x00 # EOM(1) 93 .byte 0x00 # EOM(2) 94 .byte 0x03 # Abbrev code 95 .byte 0x13 # DW_TAG_structure_type 96 .byte 0x00 # DW_CHILDREN_no (no members) 97 .byte 0x03 # DW_AT_name 98 .byte 0x1a # DW_FORM_strx 99 .byte 0x00 # EOM(1) 100 .byte 0x00 # EOM(2) 101 .byte 0x04 # Abbrev code 102 .byte 0x11 # DW_TAG_compile_unit 103 .byte 0x00 # DW_CHILDREN_no 104 .byte 0x25 # DW_AT_producer 105 .short 0x3e82 # DW_FORM_GNU_str_index 106 .byte 0x03 # DW_AT_name 107 .short 0x3e82 # DW_FORM_GNU_str_index 108 .byte 0x03 # DW_AT_name 109 .short 0x3e82 # DW_FORM_GNU_str_index 110 .byte 0x00 # EOM(1) 111 .byte 0x00 # EOM(2) 112 .byte 0x00 # EOM(3) 113abbrev_end: 114 115 .section .debug_info.dwo,"",@progbits 116 117# DWARF v5 CU header. 118CU1_5_start: 119 .long CU1_5_end-CU1_5_version # Length of Unit 120CU1_5_version: 121 .short 5 # DWARF version number 122 .byte 1 # DWARF Unit Type 123 .byte 8 # Address Size (in bytes) 124 .long .debug_abbrev.dwo # Offset Into Abbrev. Section 125# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name 126# and DW_AT_compdir. 127 .byte 1 # Abbreviation code 128 .byte 0 # The index of the producer string 129 .byte 1 # The index of the CU name string 130 .byte 2 # The index of the comp dir string 131 .byte 0 # NULL 132CU1_5_end: 133 134CU2_5_start: 135 .long CU2_5_end-CU2_5_version # Length of Unit 136CU2_5_version: 137 .short 5 # DWARF version number 138 .byte 1 # DWARF Unit Type 139 .byte 8 # Address Size (in bytes) 140 .long .debug_abbrev.dwo # Offset Into Abbrev. Section 141# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name 142# and DW_AT_compdir. 143 .byte 1 # Abbreviation code 144 .byte 0 # The index of the producer string 145 .byte 1 # The index of the CU name string 146 .byte 2 # The index of the comp dir string 147 .byte 0 # NULL 148CU2_5_end: 149 150CU3_4_start: 151 .long CU3_4_end-CU3_4_version # Length of Unit 152CU3_4_version: 153 .short 4 # DWARF version number 154 .long .debug_abbrev.dwo # Offset Into Abbrev. Section 155 .byte 8 # Address Size (in bytes) 156# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name 157# and DW_AT_compdir. 158 .byte 4 # Abbreviation code 159 .byte 0 # The index of the producer string 160 .byte 1 # The index of the CU name string 161 .byte 2 # The index of the comp dir string 162 .byte 0 # NULL 163CU3_4_end: 164 165 .section .debug_types.dwo,"",@progbits 166# DWARF v5 Type unit header. 167TU1_5_start: 168 .long TU1_5_end-TU1_5_version # Length of Unit 169TU1_5_version: 170 .short 5 # DWARF version number 171 .byte 2 # DWARF Unit Type 172 .byte 8 # Address Size (in bytes) 173 .long .debug_abbrev.dwo # Offset Into Abbrev. Section 174 .quad 0x0011223344556677 # Type Signature 175 .long TU1_5_type-TU1_5_start # Type offset 176# The type-unit DIE, which has a name. 177 .byte 2 # Abbreviation code 178 .byte 3 # Index of the unit type name string 179# The type DIE, which has a name. 180TU1_5_type: 181 .byte 3 # Abbreviation code 182 .byte 4 # Index of the type name string 183 .byte 0 # NULL 184 .byte 0 # NULL 185TU1_5_end: 186 187TU2_5_start: 188 .long TU2_5_end-TU2_5_version # Length of Unit 189TU2_5_version: 190 .short 5 # DWARF version number 191 .byte 2 # DWARF Unit Type 192 .byte 8 # Address Size (in bytes) 193 .long .debug_abbrev.dwo # Offset Into Abbrev. Section 194 .quad 0x00aabbccddeeff99 # Type Signature 195 .long TU2_5_type-TU2_5_start # Type offset 196# The type-unit DIE, which has a name. 197 .byte 2 # Abbreviation code 198 .byte 3 # Index of the unit type name string 199# The type DIE, which has a name. 200TU2_5_type: 201 .byte 3 # Abbreviation code 202 .byte 4 # Index of the type name string 203 .byte 0 # NULL 204 .byte 0 # NULL 205TU2_5_end: 206 207 .section .debug_cu_index,"",@progbits 208 # The index header 209 .long 2 # Version 210 .long 3 # Columns of contribution matrix 211 .long 3 # number of units 212 .long 3 # number of hash buckets in table 213 214 # The signatures for all CUs. 215 .quad 0xddeeaaddbbaabbee # signature 1 216 .quad 0xff00ffeeffaaff00 # signature 2 217 .quad 0xf00df00df00df00d # signature 2 218 # The indexes for both CUs. 219 .long 1 # index 1 220 .long 2 # index 2 221 .long 3 # index 3 222 # The sections to which all CUs contribute. 223 .long 1 # DW_SECT_INFO 224 .long 3 # DW_SECT_ABBREV 225 .long 6 # DW_SECT_STR_OFFSETS 226 227 # The starting offsets of all CU's contributions to info, 228 # abbrev and string offsets table. 229 .long CU1_5_start-.debug_info.dwo 230 .long 0 231 .long .debug_str_offsets_object_file1_start-.debug_str_offsets.dwo 232 .long CU2_5_start-.debug_info.dwo 233 .long 0 234 .long .debug_str_offsets_object_file2_start-.debug_str_offsets.dwo 235 .long CU3_4_start-.debug_info.dwo 236 .long 0 237 .long .debug_str_offsets_object_file3_start-.debug_str_offsets.dwo 238 239 # The lengths of all CU's contributions to info, abbrev and 240 # string offsets table. 241 .long CU1_5_end-CU1_5_start 242 .long abbrev_end-.debug_abbrev.dwo 243 .long .debug_str_offsets_object_file1_end-.debug_str_offsets_object_file1_start 244 .long CU2_5_end-CU2_5_start 245 .long abbrev_end-.debug_abbrev.dwo 246 .long .debug_str_offsets_object_file2_end-.debug_str_offsets_object_file2_start 247 .long CU3_4_end-CU3_4_start 248 .long abbrev_end-.debug_abbrev.dwo 249 .long .debug_str_offsets_object_file3_end-.debug_str_offsets_object_file3_start 250 251 .section .debug_tu_index,"",@progbits 252 # The index header 253 .long 2 # Version 254 .long 3 # Columns of contribution matrix 255 .long 2 # number of units 256 .long 2 # number of hash buckets in table 257 258 # The signatures for both TUs. 259 .quad 0xeeaaddbbaabbeedd # signature 1 260 .quad 0x00ffeeffaaff00ff # signature 2 261 # The indexes for both TUs. 262 .long 1 # index 1 263 .long 2 # index 2 264 # The sections to which both TUs contribute. 265 .long 2 # DW_SECT_TYPES 266 .long 3 # DW_SECT_ABBREV 267 .long 6 # DW_SECT_STR_OFFSETS 268 269 # The starting offsets of both TU's contributions to info, 270 # abbrev and string offsets table. 271 .long TU1_5_start-.debug_types.dwo 272 .long 0 273 .long .debug_str_offsets_object_file1_start-.debug_str_offsets.dwo 274 .long TU2_5_start-.debug_types.dwo 275 .long 0 276 .long .debug_str_offsets_object_file2_start-.debug_str_offsets.dwo 277 278 # The lengths of both TU's contributions to info, abbrev and 279 # string offsets table. 280 .long TU1_5_end-TU1_5_start 281 .long abbrev_end-.debug_abbrev.dwo 282 .long .debug_str_offsets_object_file1_end-.debug_str_offsets_object_file1_start 283 .long TU2_5_end-TU2_5_start 284 .long abbrev_end-.debug_abbrev.dwo 285 .long .debug_str_offsets_object_file2_end-.debug_str_offsets_object_file2_start 286 287 288# Verify that the correct strings from each unit are displayed and that the 289# index for the .debug_str_offsets section has the right values. 290 291# CHECK: Compile Unit 292# CHECK-NOT: NULL 293# CHECK: DW_TAG_compile_unit 294# CHECK-NEXT: DW_AT_producer [DW_FORM_strx] ( indexed (00000000) string = "Handmade DWARF producer") 295# CHECK-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000001) string = "Compile_Unit_1") 296# CHECK-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000002) string = "/home/test/CU1") 297# CHECK-NOT: NULL 298 299# CHECK: Compile Unit 300# CHECK-NOT: NULL 301# CHECK: DW_TAG_compile_unit 302# CHECK-NEXT: DW_AT_producer [DW_FORM_strx] ( indexed (00000000) string = "Handmade DWARF producer") 303# CHECK-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000001) string = "Compile_Unit_2") 304# CHECK-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000002) string = "/home/test/CU2") 305# 306# CHECK: Type Unit 307# CHECK-NOT: NULL 308# CHECK: DW_TAG_type_unit 309# CHECK-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000003) string = "Type_Unit_1") 310# CHECK-NOT: NULL 311# CHECK: DW_TAG_structure_type 312# CHECK-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000004) string = "MyStruct_1") 313# 314# CHECK: Type Unit 315# CHECK-NOT: NULL 316# CHECK: DW_TAG_type_unit 317# CHECK-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000003) string = "Type_Unit_2") 318# CHECK-NOT: NULL 319# CHECK: DW_TAG_structure_type 320# CHECK-NEXT: DW_AT_name [DW_FORM_strx] ( indexed (00000004) string = "MyStruct_2") 321 322# Verify the correct offets of the compile and type units contributions in the 323# index tables. 324 325# CHECK: .debug_cu_index contents: 326# CHECK-NOT: contents: 327# CHECK: 1 0xddeeaaddbbaabbee [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) 328# CHECK-SAME: [0x00000000 329# CHECK-NEXT: 2 0xff00ffeeffaaff00 [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) 330# CHECK-SAME: [0x0000001c 331 332# CHECK: .debug_tu_index contents: 333# CHECK-NOT: contents: 334# CHECK: 1 0xeeaaddbbaabbeedd [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) 335# CHECK-SAME: [0x00000000 336# CHECK-NEXT: 2 0x00ffeeffaaff00ff [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) 337# CHECK: [0x0000001c 338