1# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o 2# RUN: llvm-dwarfdump -v %t.o 2> %t.err | FileCheck --check-prefixes=COMMON,SPLIT,OFFSETS %s 3 4# FIXME: the verifier does not accept padding between debug-str-offset 5# sections, which this test uses. 6# RUN: llvm-dwarfdump -verify --debug-info %t.o | FileCheck --check-prefix=VERIFY %s 7# RUN: llvm-dwarfdump -debug-str-offsets %t.o | FileCheck --check-prefix=OFFSETS %s 8# 9# Check that we don't report an error on a non-existent range list table. 10# RUN: FileCheck -allow-empty --check-prefix ERR %s < %t.err 11 12# Test object to verify dwarfdump handles v5 string offset tables. 13# We have 2 v5 CUs, a v5 TU, and a split v5 CU and TU. 14# 15 16 .section .debug_str,"MS",@progbits,1 17str_producer: 18 .asciz "Handmade DWARF producer" 19str_CU1: 20 .asciz "Compile_Unit_1" 21str_CU1_dir: 22 .asciz "/home/test/CU1" 23str_CU2: 24 .asciz "Compile_Unit_2" 25str_CU2_dir: 26 .asciz "/home/test/CU2" 27str_TU: 28 .asciz "Type_Unit" 29str_TU_type: 30 .asciz "MyStruct" 31str_Subprogram: 32 .asciz "MyFunc" 33str_Variable1: 34 .asciz "MyVar1" 35str_Variable2: 36 .asciz "MyVar2" 37str_Variable3: 38 .asciz "MyVar3" 39 40# Every unit contributes to the string_offsets table. 41 .section .debug_str_offsets,"",@progbits 42# CU1's contribution 43 .long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+4 44 .short 5 # DWARF version 45 .short 0 # Padding 46.debug_str_offsets_base0: 47 .long str_producer 48 .long str_CU1 49 .long str_CU1_dir 50 .long str_Subprogram 51 .long str_Variable1 52 .long str_Variable2 53 .long str_Variable3 54.debug_str_offsets_segment0_end: 55# A 4-byte gap. 56 .long 0 57# CU2's contribution in DWARF64 format 58 .long 0xffffffff 59 .quad .debug_str_offsets_segment1_end-.debug_str_offsets_base1+4 60 .short 5 # DWARF version 61 .short 0 # Padding 62.debug_str_offsets_base1: 63 .quad str_producer 64 .quad str_CU2 65 .quad str_CU2_dir 66.debug_str_offsets_segment1_end: 67# The TU's contribution 68 .long .debug_str_offsets_segment2_end-.debug_str_offsets_base2+4 69 .short 5 # DWARF version 70 .short 0 # Padding 71.debug_str_offsets_base2: 72 .long str_TU 73 .long str_TU_type 74.debug_str_offsets_segment2_end: 75 76 .section .debug_str.dwo,"MSe",@progbits,1 77dwo_str_CU_5_producer: 78 .asciz "Handmade split DWARF producer" 79dwo_str_CU_5_name: 80 .asciz "V5_split_compile_unit" 81dwo_str_CU_5_comp_dir: 82 .asciz "/home/test/splitCU" 83dwo_str_TU_5: 84 .asciz "V5_split_type_unit" 85dwo_str_TU_5_type: 86 .asciz "V5_split_Mystruct" 87 88 .section .debug_str_offsets.dwo,"e",@progbits 89# One contribution only in a .dwo file 90 .long .debug_dwo_str_offsets_segment0_end-.debug_dwo_str_offsets_base0+4 91 .short 5 # DWARF version 92 .short 0 # Padding 93.debug_dwo_str_offsets_base0: 94 .long dwo_str_CU_5_producer-.debug_str.dwo 95 .long dwo_str_CU_5_name-.debug_str.dwo 96 .long dwo_str_CU_5_comp_dir-.debug_str.dwo 97 .long dwo_str_TU_5-.debug_str.dwo 98 .long dwo_str_TU_5_type-.debug_str.dwo 99.debug_dwo_str_offsets_segment0_end: 100 101# All CUs/TUs use the same abbrev section for simplicity. 102 .section .debug_abbrev,"",@progbits 103 .byte 0x01 # Abbrev code 104 .byte 0x11 # DW_TAG_compile_unit 105 .byte 0x01 # DW_CHILDREN_yes 106 .byte 0x25 # DW_AT_producer 107 .byte 0x1a # DW_FORM_strx 108 .byte 0x03 # DW_AT_name 109 .byte 0x1a # DW_FORM_strx 110 .byte 0x72 # DW_AT_str_offsets_base 111 .byte 0x17 # DW_FORM_sec_offset 112 .byte 0x1b # DW_AT_comp_dir 113 .byte 0x1a # DW_FORM_strx 114 .byte 0x00 # EOM(1) 115 .byte 0x00 # EOM(2) 116 .byte 0x02 # Abbrev code 117 .byte 0x41 # DW_TAG_type_unit 118 .byte 0x01 # DW_CHILDREN_yes 119 .byte 0x03 # DW_AT_name 120 .byte 0x1a # DW_FORM_strx 121 .byte 0x72 # DW_AT_str_offsets_base 122 .byte 0x17 # DW_FORM_sec_offset 123 .byte 0x00 # EOM(1) 124 .byte 0x00 # EOM(2) 125 .byte 0x03 # Abbrev code 126 .byte 0x13 # DW_TAG_structure_type 127 .byte 0x00 # DW_CHILDREN_no (no members) 128 .byte 0x03 # DW_AT_name 129 .byte 0x1a # DW_FORM_strx 130 .byte 0x00 # EOM(1) 131 .byte 0x00 # EOM(2) 132 .byte 0x04 # Abbrev code 133 .byte 0x2e # DW_TAG_subprogram 134 .byte 0x01 # DW_CHILDREN_yes 135 .byte 0x03 # DW_AT_name 136 .byte 0x25 # DW_FORM_strx1 137 .byte 0x00 # EOM(1) 138 .byte 0x00 # EOM(2) 139 .byte 0x05 # Abbrev code 140 .byte 0x34 # DW_TAG_variable 141 .byte 0x00 # DW_CHILDREN_no 142 .byte 0x03 # DW_AT_name 143 .byte 0x26 # DW_FORM_strx2 144 .byte 0x49 # DW_AT_type 145 .byte 0x13 # DW_FORM_ref4 146 .byte 0x00 # EOM(1) 147 .byte 0x00 # EOM(2) 148 .byte 0x06 # Abbrev code 149 .byte 0x34 # DW_TAG_variable 150 .byte 0x00 # DW_CHILDREN_no 151 .byte 0x03 # DW_AT_name 152 .byte 0x27 # DW_FORM_strx3 153 .byte 0x49 # DW_AT_type 154 .byte 0x13 # DW_FORM_ref4 155 .byte 0x00 # EOM(1) 156 .byte 0x00 # EOM(2) 157 .byte 0x07 # Abbrev code 158 .byte 0x34 # DW_TAG_variable 159 .byte 0x00 # DW_CHILDREN_no 160 .byte 0x03 # DW_AT_name 161 .byte 0x28 # DW_FORM_strx4 162 .byte 0x49 # DW_AT_type 163 .byte 0x13 # DW_FORM_ref4 164 .byte 0x00 # EOM(1) 165 .byte 0x00 # EOM(2) 166 .byte 0x08 # Abbrev code 167 .byte 0x24 # DW_TAG_base_type 168 .byte 0x00 # DW_CHILDREN_no 169 .byte 0x3e # DW_AT_encoding 170 .byte 0x0b # DW_FORM_data1 171 .byte 0x00 # EOM(1) 172 .byte 0x00 # EOM(2) 173 .byte 0x09 # Abbrev code 174 .byte 0x11 # DW_TAG_compile_unit 175 .byte 0x00 # DW_CHILDREN_no 176 .byte 0x00 # EOM(1) 177 .byte 0x00 # EOM(2) 178 .byte 0x00 # EOM(3) 179 180# And a .dwo copy of a subset for the .dwo sections. 181 .section .debug_abbrev.dwo,"e",@progbits 182 .byte 0x01 # Abbrev code 183 .byte 0x11 # DW_TAG_compile_unit 184 .byte 0x00 # DW_CHILDREN_no 185 .byte 0x25 # DW_AT_producer 186 .byte 0x1a # DW_FORM_strx 187 .byte 0x03 # DW_AT_name 188 .byte 0x1a # DW_FORM_strx 189 .byte 0x1b # DW_AT_comp_dir 190 .byte 0x1a # DW_FORM_strx 191 .byte 0x00 # EOM(1) 192 .byte 0x00 # EOM(2) 193 .byte 0x02 # Abbrev code 194 .byte 0x41 # DW_TAG_type_unit 195 .byte 0x01 # DW_CHILDREN_yes 196 .byte 0x03 # DW_AT_name 197 .byte 0x1a # DW_FORM_strx 198 .byte 0x00 # EOM(1) 199 .byte 0x00 # EOM(2) 200 .byte 0x03 # Abbrev code 201 .byte 0x13 # DW_TAG_structure_type 202 .byte 0x00 # DW_CHILDREN_no (no members) 203 .byte 0x03 # DW_AT_name 204 .byte 0x1a # DW_FORM_strx 205 .byte 0x00 # EOM(1) 206 .byte 0x00 # EOM(2) 207 .byte 0x00 # EOM(3) 208 209 .section .debug_info,"",@progbits 210 211# DWARF v5 CU header. 212 .long CU1_5_end-CU1_5_version # Length of Unit 213CU1_5_version: 214 .short 5 # DWARF version number 215 .byte 1 # DWARF Unit Type 216 .byte 8 # Address Size (in bytes) 217 .long .debug_abbrev # Offset Into Abbrev. Section 218# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name, 219# DW_AT_str_offsets and DW_AT_compdir. 220 .byte 1 # Abbreviation code 221 .byte 0 # The index of the producer string 222 .byte 1 # The index of the CU name string 223 .long .debug_str_offsets_base0 224 .byte 2 # The index of the comp dir string 225# A subprogram DIE with DW_AT_name, using DW_FORM_strx1. 226 .byte 4 # Abbreviation code 227 .byte 3 # Subprogram name string (DW_FORM_strx1) 228# A variable DIE with DW_AT_name, using DW_FORM_strx2, and DW_AT_type. 229 .byte 5 # Abbreviation code 230 .short 0x0004 # Subprogram name string (DW_FORM_strx2) 231 .long TypeDie-.debug_info 232# A variable DIE with DW_AT_name, using DW_FORM_strx3, and DW_AT_type. 233 .byte 6 # Abbreviation code 234 .byte 5 # Subprogram name string (DW_FORM_strx3) 235 .short 0 # Subprogram name string (DW_FORM_strx3) 236 .long TypeDie-.debug_info 237# A variable DIE with DW_AT_name, using DW_FORM_strx4, and DW_AT_type. 238 .byte 7 # Abbreviation code 239 .long 6 # Subprogram name string (DW_FORM_strx4) 240 .long TypeDie-.debug_info 241 .byte 0 # NULL 242# A base type DIE with DW_AT_encoding. 243TypeDie: 244 .byte 8 # Abbreviation code 245 .byte 5 # DW_ATE_signed 246 .byte 0 # NULL 247 .byte 0 # NULL 248CU1_5_end: 249 250# DWARF v5 CU header 251 .long 0xffffffff 252 .quad CU2_5_end-CU2_5_version # Length of Unit 253CU2_5_version: 254 .short 5 # DWARF version number 255 .byte 1 # DWARF Unit Type 256 .byte 8 # Address Size (in bytes) 257 .quad .debug_abbrev # Offset Into Abbrev. Section 258# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name, 259# DW_AT_str_offsets and DW_AT_compdir. 260 .byte 1 # Abbreviation code 261 .byte 0 # The index of the producer string 262 .byte 1 # The index of the CU name string 263 .quad .debug_str_offsets_base1 264 .byte 2 # The index of the comp dir string 265 .byte 0 # NULL 266CU2_5_end: 267# DWARF v5 CU without str_offsets_base - this shouldn't produce an error/nor 268# prevent other str_offsets contributions from being dumped. 269 .long CU3_5_end-CU3_5_version # Length of Unit 270CU3_5_version: 271 .short 5 # DWARF version number 272 .byte 1 # DWARF Unit Type 273 .byte 8 # Address Size (in bytes) 274 .long .debug_abbrev # Offset Into Abbrev. Section 275# The compile-unit DIE with no attributes. 276 .byte 9 # Abbreviation code 277CU3_5_end: 278 279 280 281 282 283 284 .section .debug_types,"",@progbits 285# DWARF v5 Type unit header. 286TU_5_start: 287 .long TU_5_end-TU_5_version # Length of Unit 288TU_5_version: 289 .short 5 # DWARF version number 290 .byte 2 # DWARF Unit Type 291 .byte 8 # Address Size (in bytes) 292 .long .debug_abbrev # Offset Into Abbrev. Section 293 .quad 0x0011223344556677 # Type Signature 294 .long TU_5_type-TU_5_start # Type offset 295# The type-unit DIE, which has a name. 296 .byte 2 # Abbreviation code 297 .byte 0 # Index of the unit type name string 298 .long .debug_str_offsets_base2 # offset into the str_offsets section 299# The type DIE, which has a name. 300TU_5_type: 301 .byte 3 # Abbreviation code 302 .byte 1 # Index of the type name string 303 .byte 0 # NULL 304 .byte 0 # NULL 305TU_5_end: 306 307 .section .debug_info.dwo,"e",@progbits 308 309# DWARF v5 split CU header. 310 .long CU_split_5_end-CU_split_5_version # Length of Unit 311CU_split_5_version: 312 .short 5 # DWARF version number 313 .byte 1 # DWARF Unit Type 314 .byte 8 # Address Size (in bytes) 315 .long .debug_abbrev.dwo # Offset Into Abbrev Section 316# The compile-unit DIE, which has a DW_AT_producer, DW_AT_name, 317# DW_AT_str_offsets and DW_AT_compdir. 318 .byte 1 # Abbreviation code 319 .byte 0 # The index of the producer string 320 .byte 1 # The index of the CU name string 321 .byte 2 # The index of the comp dir string 322 .byte 0 # NULL 323CU_split_5_end: 324 325 .section .debug_types.dwo,"e",@progbits 326 327# DWARF v5 split type unit header. 328TU_split_5_start: 329 .long TU_split_5_end-TU_split_5_version # Length of Unit 330TU_split_5_version: 331 .short 5 # DWARF version number 332 .byte 6 # DWARF Unit Type 333 .byte 8 # Address Size (in bytes) 334 .long .debug_abbrev.dwo # Offset Into Abbrev Section 335 .quad 0x8899aabbccddeeff # Type Signature 336 .long TU_split_5_type-TU_split_5_start # Type offset 337# The type-unit DIE, which has a name. 338 .byte 2 # Abbreviation code 339 .byte 3 # The index of the type unit name string 340# The type DIE, which has a name. 341TU_split_5_type: 342 .byte 3 # Abbreviation code 343 .byte 4 # The index of the type name string 344 .byte 0 # NULL 345 .byte 0 # NULL 346TU_split_5_end: 347 348# We are using a hand-constructed object file and are interest in the correct 349# diplay of the DW_str_offsetsbase attribute, the correct display of strings 350# and the dump of the .debug_str_offsets[.dwo] table. 351 352# Abbreviation for DW_AT_str_offsets_base 353# COMMON: .debug_abbrev contents: 354# COMMON-NOT: contents: 355# COMMON: DW_TAG_compile_unit 356# COMMON-NOT: DW_TAG 357# COMMON: DW_AT_str_offsets_base DW_FORM_sec_offset 358# 359# Verify that strings are displayed correctly as indexed strings 360# COMMON: .debug_info contents: 361# COMMON-NOT: contents: 362# COMMON: DW_TAG_compile_unit 363# COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer") 364# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_1") 365# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008) 366# COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU1") 367# COMMON-NOT: NULL 368# COMMON: DW_TAG_subprogram 369# COMMON-NEXT: DW_AT_name [DW_FORM_strx1] (indexed (00000003) string = "MyFunc") 370# COMMON-NOT: NULL 371# COMMON: DW_TAG_variable 372# COMMON-NEXT: DW_AT_name [DW_FORM_strx2] (indexed (00000004) string = "MyVar1") 373# COMMON-NOT: NULL 374# COMMON: DW_TAG_variable 375# COMMON-NEXT: DW_AT_name [DW_FORM_strx3] (indexed (00000005) string = "MyVar2") 376# COMMON-NOT: NULL 377# COMMON: DW_TAG_variable 378# COMMON-NEXT: DW_AT_name [DW_FORM_strx4] (indexed (00000006) string = "MyVar3") 379# 380# Second compile unit (b.cpp) 381# COMMON: DW_TAG_compile_unit 382# COMMON-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer") 383# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_2") 384# COMMON-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x0000000000000038) 385# COMMON-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU2") 386# 387# The split CU 388# SPLIT: .debug_info.dwo contents: 389# SPLIT-NOT: contents: 390# SPLIT: DW_TAG_compile_unit 391# SPLIT-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade split DWARF producer") 392# SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "V5_split_compile_unit") 393# SPLIT-NEXT: DW_AT_comp_dir [DW_FORM_strx] (indexed (00000002) string = "/home/test/splitCU") 394# 395# The type unit 396# COMMON: .debug_types contents: 397# COMMON: DW_TAG_type_unit 398# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000000) string = "Type_Unit") 399# COMMON: DW_TAG_structure_type 400# COMMON-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "MyStruct") 401# 402# The split type unit 403# SPLIT: .debug_types.dwo contents: 404# SPLIT: DW_TAG_type_unit 405# SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000003) string = "V5_split_type_unit") 406# SPLIT: DW_TAG_structure_type 407# SPLIT-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000004) string = "V5_split_Mystruct") 408# 409# The .debug_str_offsets section 410# OFFSETS: .debug_str_offsets contents: 411# OFFSETS-NEXT: 0x00000000: Contribution size = 32, Format = DWARF32, Version = 5 412# OFFSETS-NEXT: 0x00000008: 00000000 "Handmade DWARF producer" 413# OFFSETS-NEXT: 0x0000000c: 00000018 "Compile_Unit_1" 414# OFFSETS-NEXT: 0x00000010: 00000027 "/home/test/CU1" 415# OFFSETS-NEXT: 0x00000014: 00000067 "MyFunc" 416# OFFSETS-NEXT: 0x00000018: 0000006e "MyVar1" 417# OFFSETS-NEXT: 0x0000001c: 00000075 "MyVar2" 418# OFFSETS-NEXT: 0x00000020: 0000007c "MyVar3" 419# OFFSETS-NEXT: Gap, length = 4 420# OFFSETS-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5 421# OFFSETS-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer" 422# OFFSETS-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2" 423# OFFSETS-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2" 424# OFFSETS-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5 425# OFFSETS-NEXT: 0x00000058: 00000054 "Type_Unit" 426# OFFSETS-NEXT: 0x0000005c: 0000005e "MyStruct" 427# 428# OFFSETS: .debug_str_offsets.dwo contents: 429# OFFSETS-NEXT: 0x00000000: Contribution size = 24, Format = DWARF32, Version = 5 430# OFFSETS-NEXT: 0x00000008: 00000000 "Handmade split DWARF producer" 431# OFFSETS-NEXT: 0x0000000c: 0000001e "V5_split_compile_unit" 432# OFFSETS-NEXT: 0x00000010: 00000034 "/home/test/splitCU" 433# OFFSETS-NEXT: 0x00000014: 00000047 "V5_split_type_unit" 434# OFFSETS-NEXT: 0x00000018: 0000005a "V5_split_Mystruct" 435 436# VERIFY: No errors. 437 438# ERR-NOT: parsing a range list table: 439