1# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o 2# RUN: not llvm-dwarfdump -verify %t.o | FileCheck --check-prefix=VERIFY %s 3 4# Check that the verifier correctly diagnoses various error conditions with 5# the usage of string indices and string offsets tables. 6 7 .section .debug_str,"MS",@progbits,1 8str_producer: 9 .asciz "Handmade DWARF producer" 10 11 .section .debug_str_offsets,"",@progbits 12# The string offsets table 13 .long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+4 14 .short 5 # DWARF version 15 .short 0 # Padding 16.debug_str_offsets_base0: 17 .long str_producer 18 .long 1000 # Invalid string address. 19.debug_str_offsets_segment0_end: 20 21# A simple abbrev section with a basic compile unit DIE. 22 .section .debug_abbrev,"",@progbits 23 .byte 0x01 # Abbrev code 24 .byte 0x11 # DW_TAG_compile_unit 25 .byte 0x00 # DW_CHILDREN_no 26 .byte 0x25 # DW_AT_producer 27 .byte 0x1a # DW_FORM_strx 28 .byte 0x72 # DW_AT_str_offsets_base 29 .byte 0x17 # DW_FORM_sec_offset 30 .byte 0x00 # EOM(1) 31 .byte 0x00 # EOM(2) 32 33 .section .debug_info,"",@progbits 34 35# The first unit's CU DIE has an invalid DW_AT_str_offsets_base which 36# renders any string index unresolvable. 37 38# DWARF v5 CU header. 39 .long CU1_5_end-CU1_5_version # Length of Unit 40CU1_5_version: 41 .short 5 # DWARF version number 42 .byte 1 # DWARF Unit Type 43 .byte 8 # Address Size (in bytes) 44 .long .debug_abbrev # Offset Into Abbrev. Section 45# The compile-unit DIE, which has DW_AT_producer and DW_AT_str_offsets. 46 .byte 1 # Abbreviation code 47 .byte 0 # Index of string for DW_AT_producer. 48 .long 1000 # Bad value for DW_AT_str_offsets_base 49 .byte 0 # NULL 50CU1_5_end: 51 52# The second unit's CU DIE uses an invalid string index. 53 54# DWARF v5 CU header 55 .long CU2_5_end-CU2_5_version # Length of Unit 56CU2_5_version: 57 .short 5 # DWARF version number 58 .byte 1 # DWARF Unit Type 59 .byte 8 # Address Size (in bytes) 60 .long .debug_abbrev # Offset Into Abbrev. Section 61# The compile-unit DIE, which has DW_AT_producer and DW_AT_str_offsets. 62 .byte 1 # Abbreviation code 63 .byte 100 # Invalid string index 64 .long .debug_str_offsets_base0 65 .byte 0 # NULL 66CU2_5_end: 67 68# The third unit's CU DIE uses a valid string index but the entry in the 69# string offsets table is invalid. 70 71# DWARF v5 CU header 72 .long CU3_5_end-CU3_5_version # Length of Unit 73CU3_5_version: 74 .short 5 # DWARF version number 75 .byte 1 # DWARF Unit Type 76 .byte 8 # Address Size (in bytes) 77 .long .debug_abbrev # Offset Into Abbrev. Section 78# The compile-unit DIE, which has DW_AT_producer and DW_AT_str_offsets. 79 .byte 1 # Abbreviation code 80 .byte 1 # Index of string for DW_AT_producer. 81 .long .debug_str_offsets_base0 82 .byte 0 # NULL 83CU3_5_end: 84 85# VERIFY-DAG: error: DW_FORM_strx used without a valid string offsets table: 86# VERIFY-DAG: error: DW_FORM_strx uses index 100, which is too large: 87# VERIFY-DAG: error: DW_FORM_strx uses index 1, but the referenced string offset 88# VERIFY-DAG-SAME: is beyond .debug_str bounds: 89