1# RUN: yaml2obj %s -o %t.o
2# RUN: ld.lld --gdb-index %t.o -o /dev/null
3
4## We used to crash if a DWARFAddressRange has invalid SectionIndex (-1).
5## Such DWARFAddressRange can be produced by clang -c -gdwarf-5 -gmlt before r360678.
6
7--- !ELF
8FileHeader:
9  Class:           ELFCLASS64
10  Data:            ELFDATA2LSB
11  Type:            ET_REL
12  Machine:         EM_X86_64
13Sections:
14  - Name:            .text
15    Type:            SHT_PROGBITS
16    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
17    AddressAlign:    0x0000000000000010
18    Content:         31C0C3
19  - Name:            .debug_str_offsets
20    Type:            SHT_PROGBITS
21    AddressAlign:    0x0000000000000001
22    Content:         '1000000005000000000000000000000000000000'
23  - Name:            .rela.debug_str_offsets
24    Type:            SHT_RELA
25    Link:            .symtab
26    AddressAlign:    0x0000000000000008
27    EntSize:         0x0000000000000018
28    Info:            .debug_str_offsets
29    Relocations:
30      - Offset:          0x0000000000000008
31        Symbol:          .debug_str
32        Type:            R_X86_64_32
33      - Offset:          0x000000000000000C
34        Symbol:          .debug_str
35        Type:            R_X86_64_32
36        Addend:          1
37      - Offset:          0x0000000000000010
38        Symbol:          .debug_str
39        Type:            R_X86_64_32
40        Addend:          6
41  - Name:            .debug_str
42    Type:            SHT_PROGBITS
43    Flags:           [ SHF_MERGE, SHF_STRINGS ]
44    AddressAlign:    0x0000000000000001
45    EntSize:         0x0000000000000001
46    Content:         00612E6363002F746D7000
47  - Name:            .debug_abbrev
48    Type:            SHT_PROGBITS
49    AddressAlign:    0x0000000000000001
50    Content:         011100252513050325721710171B25111B1206000000
51  - Name:            .debug_info
52    Type:            SHT_PROGBITS
53    AddressAlign:    0x0000000000000001
54    Content:         1B000000050001080000000001000400010000000000000000020003000000
55  - Name:            .rela.debug_info
56    Type:            SHT_RELA
57    Link:            .symtab
58    AddressAlign:    0x0000000000000008
59    EntSize:         0x0000000000000018
60    Info:            .debug_info
61    Relocations:
62      - Offset:          0x0000000000000008
63        Symbol:          .debug_abbrev
64        Type:            R_X86_64_32
65      - Offset:          0x0000000000000011
66        Symbol:          .debug_str_offsets
67        Type:            R_X86_64_32
68        Addend:          8
69      - Offset:          0x0000000000000015
70        Symbol:          .debug_line
71        Type:            R_X86_64_32
72  - Name:            .debug_addr
73    Type:            SHT_PROGBITS
74    AddressAlign:    0x0000000000000001
75    Content:         0C000000050008000000000000000000
76  - Name:            .rela.debug_addr
77    Type:            SHT_RELA
78    Link:            .symtab
79    AddressAlign:    0x0000000000000008
80    EntSize:         0x0000000000000018
81    Info:            .debug_addr
82    Relocations:
83      - Offset:          0x0000000000000008
84        Symbol:          .text
85        Type:            R_X86_64_64
86  - Name:            .debug_line
87    Type:            SHT_PROGBITS
88    AddressAlign:    0x0000000000000001
89    Content:         2D0000000500080025000000010101FB0E0D00010101010000000100000101011F010000000002011F020F010000000000
90  - Name:            .rela.debug_line
91    Type:            SHT_RELA
92    Link:            .symtab
93    AddressAlign:    0x0000000000000008
94    EntSize:         0x0000000000000018
95    Info:            .debug_line
96    Relocations:
97      - Offset:          0x0000000000000022
98        Symbol:          .debug_line_str
99        Type:            R_X86_64_32
100      - Offset:          0x000000000000002C
101        Symbol:          .debug_line_str
102        Type:            R_X86_64_32
103        Addend:          5
104  - Name:            .debug_line_str
105    Type:            SHT_PROGBITS
106    Flags:           [ SHF_MERGE, SHF_STRINGS ]
107    AddressAlign:    0x0000000000000001
108    EntSize:         0x0000000000000001
109    Content:         2F746D7000612E636300
110Symbols:
111  - Name:            a.ll
112    Type:            STT_FILE
113    Index:           SHN_ABS
114  - Name:            .text
115    Type:            STT_SECTION
116    Section:         .text
117  - Name:            .debug_str_offsets
118    Type:            STT_SECTION
119    Section:         .debug_str_offsets
120  - Name:            .debug_str
121    Type:            STT_SECTION
122    Section:         .debug_str
123  - Name:            .debug_abbrev
124    Type:            STT_SECTION
125    Section:         .debug_abbrev
126  - Name:            .debug_info
127    Type:            STT_SECTION
128    Section:         .debug_info
129  - Name:            .debug_line
130    Type:            STT_SECTION
131    Section:         .debug_line
132  - Name:            .debug_line_str
133    Type:            STT_SECTION
134    Section:         .debug_line_str
135  - Name:            foo
136    Type:            STT_FUNC
137    Section:         .text
138    Binding:         STB_GLOBAL
139    Size:            0x0000000000000003
140...
141