1# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
2# RUN: llvm-dwarfdump -v %t.o | FileCheck --check-prefix=INVALIDLENGTH %s
3#
4# Test object to verify that llvm-dwarfdump handles an invalid string offsets
5# table.
6
7        .section .debug_str,"MS",@progbits,1
8str_producer:
9        .asciz "Handmade DWARF producer"
10str_CU1:
11        .asciz "Compile_Unit_1"
12
13# A rudimentary abbrev section.
14        .section .debug_abbrev,"",@progbits
15        .byte 0x01  # Abbrev code
16        .byte 0x11  # DW_TAG_compile_unit
17        .byte 0x00  # DW_CHILDREN_no
18        .byte 0x72  # DW_AT_str_offsets_base
19        .byte 0x17  # DW_FORM_sec_offset
20        .byte 0x00  # EOM(1)
21        .byte 0x00  # EOM(2)
22        .byte 0x00  # EOM(3)
23
24# A rudimentary compile unit to convince dwarfdump that we are dealing with a
25# DWARF v5 string offsets table.
26        .section .debug_info,"",@progbits
27
28# DWARF v5 CU header.
29        .long  CU1_5_end-CU1_5_version  # Length of Unit
30CU1_5_version:
31        .short 5               # DWARF version number
32        .byte 1                # DWARF Unit Type
33        .byte 8                # Address Size (in bytes)
34        .long .debug_abbrev    # Offset Into Abbrev. Section
35# A compile-unit DIE, which has no attributes.
36        .byte 1                # Abbreviation code
37        .long .debug_str_offsets_base0
38CU1_5_end:
39
40# Every unit contributes to the string_offsets table.
41        .section .debug_str_offsets,"",@progbits
42# CU1's contribution
43# The length is not a multiple of 4. Check that we don't read off the
44# end.
45        .long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+4
46        .short 5    # DWARF version
47        .short 0    # Padding
48.debug_str_offsets_base0:
49        .long str_producer
50        .long str_CU1
51        .byte 0
52.debug_str_offsets_segment0_end:
53
54# INVALIDLENGTH:             .debug_str_offsets contents:
55# INVALIDLENGTH-NOT:         contents:
56# INVALIDLENGTH:             error: invalid contribution to string offsets table in section .debug_str_offsets.
57