# RUN: yaml2obj %s -o %t.o
# RUN: ld.lld --gdb-index %t.o -o /dev/null

## We used to crash if a DWARFAddressRange has invalid SectionIndex (-1).
## Such DWARFAddressRange can be produced by clang -c -gdwarf-5 -gmlt before r360678.

--- !ELF
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_REL
  Machine:         EM_X86_64
Sections:
  - Name:            .text
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    AddressAlign:    0x0000000000000010
    Content:         31C0C3
  - Name:            .debug_str_offsets
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         '1000000005000000000000000000000000000000'
  - Name:            .rela.debug_str_offsets
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    EntSize:         0x0000000000000018
    Info:            .debug_str_offsets
    Relocations:
      - Offset:          0x0000000000000008
        Symbol:          .debug_str
        Type:            R_X86_64_32
      - Offset:          0x000000000000000C
        Symbol:          .debug_str
        Type:            R_X86_64_32
        Addend:          1
      - Offset:          0x0000000000000010
        Symbol:          .debug_str
        Type:            R_X86_64_32
        Addend:          6
  - Name:            .debug_str
    Type:            SHT_PROGBITS
    Flags:           [ SHF_MERGE, SHF_STRINGS ]
    AddressAlign:    0x0000000000000001
    EntSize:         0x0000000000000001
    Content:         00612E6363002F746D7000
  - Name:            .debug_abbrev
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         011100252513050325721710171B25111B1206000000
  - Name:            .debug_info
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         1B000000050001080000000001000400010000000000000000020003000000
  - Name:            .rela.debug_info
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    EntSize:         0x0000000000000018
    Info:            .debug_info
    Relocations:
      - Offset:          0x0000000000000008
        Symbol:          .debug_abbrev
        Type:            R_X86_64_32
      - Offset:          0x0000000000000011
        Symbol:          .debug_str_offsets
        Type:            R_X86_64_32
        Addend:          8
      - Offset:          0x0000000000000015
        Symbol:          .debug_line
        Type:            R_X86_64_32
  - Name:            .debug_addr
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         0C000000050008000000000000000000
  - Name:            .rela.debug_addr
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    EntSize:         0x0000000000000018
    Info:            .debug_addr
    Relocations:
      - Offset:          0x0000000000000008
        Symbol:          .text
        Type:            R_X86_64_64
  - Name:            .debug_line
    Type:            SHT_PROGBITS
    AddressAlign:    0x0000000000000001
    Content:         2D0000000500080025000000010101FB0E0D00010101010000000100000101011F010000000002011F020F010000000000
  - Name:            .rela.debug_line
    Type:            SHT_RELA
    Link:            .symtab
    AddressAlign:    0x0000000000000008
    EntSize:         0x0000000000000018
    Info:            .debug_line
    Relocations:
      - Offset:          0x0000000000000022
        Symbol:          .debug_line_str
        Type:            R_X86_64_32
      - Offset:          0x000000000000002C
        Symbol:          .debug_line_str
        Type:            R_X86_64_32
        Addend:          5
  - Name:            .debug_line_str
    Type:            SHT_PROGBITS
    Flags:           [ SHF_MERGE, SHF_STRINGS ]
    AddressAlign:    0x0000000000000001
    EntSize:         0x0000000000000001
    Content:         2F746D7000612E636300
Symbols:
  - Name:            a.ll
    Type:            STT_FILE
    Index:           SHN_ABS
  - Name:            .text
    Type:            STT_SECTION
    Section:         .text
  - Name:            .debug_str_offsets
    Type:            STT_SECTION
    Section:         .debug_str_offsets
  - Name:            .debug_str
    Type:            STT_SECTION
    Section:         .debug_str
  - Name:            .debug_abbrev
    Type:            STT_SECTION
    Section:         .debug_abbrev
  - Name:            .debug_info
    Type:            STT_SECTION
    Section:         .debug_info
  - Name:            .debug_line
    Type:            STT_SECTION
    Section:         .debug_line
  - Name:            .debug_line_str
    Type:            STT_SECTION
    Section:         .debug_line_str
  - Name:            foo
    Type:            STT_FUNC
    Section:         .text
    Binding:         STB_GLOBAL
    Size:            0x0000000000000003
...
