1# REQUIRES: x86, system-linux 2# RUN: rm -rf %t && mkdir %t && cd %t 3 4## Test errors in the header. 5# RUN: sed '/Header: version/s/5/4/' %S/Inputs/debug-names-a.s > bad-version.s 6# RUN: llvm-mc -filetype=obj -triple=x86_64 bad-version.s -o bad-version.o 7# RUN: not ld.lld --debug-names bad-version.o 2>&1 | FileCheck %s --check-prefix=BAD-VERSION --implicit-check-not=error: 8 9# BAD-VERSION: error: bad-version.o:(.debug_names): unsupported version: 4 10 11# RUN: sed '/Header: name count/s/[0-9]/4/' %S/Inputs/debug-names-a.s > bad-name-count.s 12# RUN: llvm-mc -filetype=obj -triple=x86_64 bad-name-count.s -o bad-name-count.o 13# RUN: not ld.lld --debug-names bad-name-count.o 2>&1 | FileCheck %s --check-prefix=BAD-NAME-COUNT --implicit-check-not=error: 14 15## Test errors in offsets. 16# BAD-NAME-COUNT: error: bad-name-count.o:(.debug_names): Section too small: cannot read abbreviations. 17 18# RUN: sed '/Offset in Bucket/s/long/byte/' %S/Inputs/debug-names-a.s > entry-offset-in-byte.s 19# RUN: llvm-mc -filetype=obj -triple=x86_64 entry-offset-in-byte.s -o entry-offset-in-byte.o 20# RUN: not ld.lld --debug-names entry-offset-in-byte.o 2>&1 | FileCheck %s --check-prefix=ENTRY-OFFSET-IN-BYTE --implicit-check-not=error: 21 22# ENTRY-OFFSET-IN-BYTE-COUNT-2: error: entry-offset-in-byte.o:(.debug_names): index entry is out of bounds 23 24## Test errors in the abbrev table. 25# RUN: sed -E '/DW_IDX_parent/{n;s/[0-9]+.*DW_FORM_flag_present/16/}' %S/Inputs/debug-names-a.s > bad-parent-form.s 26# RUN: llvm-mc -filetype=obj -triple=x86_64 bad-parent-form.s -o bad-parent-form.o 27# RUN: not ld.lld --debug-names bad-parent-form.o 2>&1 | FileCheck %s --check-prefix=BAD-PARENT-FORM --implicit-check-not=error: 28 29# BAD-PARENT-FORM: error: bad-parent-form.o:(.debug_names): invalid form for DW_IDX_parent 30 31# RUN: sed -E '/DW_IDX_die_offset/{n;s/[0-9]+.*DW_FORM_ref4/16/}' %S/Inputs/debug-names-a.s > bad-die-form.s 32# RUN: llvm-mc -filetype=obj -triple=x86_64 bad-die-form.s -o bad-die-form.o 33# RUN: not ld.lld --debug-names bad-die-form.o 2>&1 | FileCheck %s --check-prefix=BAD-DIE-FORM --implicit-check-not=error: 34 35# BAD-DIE-FORM: error: bad-die-form.o:(.debug_names): unrecognized form encoding 16 in abbrev table 36 37## Test errors in the entry pool. 38# RUN: sed -E '/Lnames.:/{n;n;s/[0-9]+/3/}' %S/Inputs/debug-names-a.s > bad-abbrev-code.s 39# RUN: llvm-mc -filetype=obj -triple=x86_64 bad-abbrev-code.s -o bad-abbrev-code.o 40# RUN: not ld.lld --debug-names bad-abbrev-code.o 2>&1 | FileCheck %s --check-prefix=BAD-ABBREV-CODE --implicit-check-not=error: 41# RUN: ld.lld --debug-names bad-abbrev-code.o -o bad-abbrev-code --noinhibit-exec 42# RUN: llvm-dwarfdump --debug-names bad-abbrev-code | FileCheck %s --check-prefix=BAD-ABBREV-CODE-DWARF 43 44# BAD-ABBREV-CODE: error: bad-abbrev-code.o:(.debug_names): abbrev code not found in abbrev table: 3 45 46# BAD-ABBREV-CODE-DWARF: Abbreviations [ 47# BAD-ABBREV-CODE-DWARF-NEXT: Abbreviation 0x1 { 48# BAD-ABBREV-CODE-DWARF-NEXT: Tag: DW_TAG_subprogram 49# BAD-ABBREV-CODE-DWARF-NEXT: DW_IDX_die_offset: DW_FORM_ref4 50# BAD-ABBREV-CODE-DWARF-NEXT: DW_IDX_parent: DW_FORM_flag_present 51# BAD-ABBREV-CODE-DWARF-NEXT: DW_IDX_compile_unit: DW_FORM_data1 52# BAD-ABBREV-CODE-DWARF-NEXT: } 53# BAD-ABBREV-CODE-DWARF-NEXT: Abbreviation 0x2 { 54# BAD-ABBREV-CODE-DWARF-NEXT: Tag: DW_TAG_structure_type 55# BAD-ABBREV-CODE-DWARF-NEXT: DW_IDX_die_offset: DW_FORM_ref4 56# BAD-ABBREV-CODE-DWARF-NEXT: DW_IDX_parent: DW_FORM_flag_present 57# BAD-ABBREV-CODE-DWARF-NEXT: DW_IDX_compile_unit: DW_FORM_data1 58# BAD-ABBREV-CODE-DWARF-NEXT: } 59# BAD-ABBREV-CODE-DWARF-NEXT: ] 60# BAD-ABBREV-CODE-DWARF: Bucket 0 61# BAD-ABBREV-CODE-DWARF-NOT: Entry 62 63# RUN: sed -E '/Lnames0:/{n;n;n;s/.*DW_IDX_die_offset.*//}' %S/Inputs/debug-names-a.s > missing-die-offset0.s 64# RUN: llvm-mc -filetype=obj -triple=x86_64 missing-die-offset0.s -o missing-die-offset0.o 65# RUN: ld.lld --debug-names missing-die-offset0.o --noinhibit-exec -o missing-die-offset0 2>&1 | FileCheck %s --check-prefix=MISSING-DIE-OFFSET0 66 67# MISSING-DIE-OFFSET0: warning: missing-die-offset0.o:(.debug_names): index entry is out of bounds 68 69# RUN: sed -E '/Lnames1:/{n;n;n;s/.*DW_IDX_die_offset.*//}' %S/Inputs/debug-names-a.s > missing-die-offset1.s 70# RUN: llvm-mc -filetype=obj -triple=x86_64 missing-die-offset1.s -o missing-die-offset1.o 71# RUN: ld.lld --debug-names missing-die-offset1.o -o missing-die-offset1 72# RUN: llvm-dwarfdump --debug-names missing-die-offset1 | FileCheck %s --check-prefix=MISSING-DIE-OFFSET1 73 74# MISSING-DIE-OFFSET1: Bucket 0 [ 75# MISSING-DIE-OFFSET1-NEXT: Name 1 { 76# MISSING-DIE-OFFSET1-NEXT: Hash: 0x59796A 77# MISSING-DIE-OFFSET1-NEXT: String: {{.*}} "t1" 78# MISSING-DIE-OFFSET1-NEXT: Entry @ 0x65 { 79# MISSING-DIE-OFFSET1-NEXT: Abbrev: 0x2 80# MISSING-DIE-OFFSET1-NEXT: Tag: DW_TAG_structure_type 81# MISSING-DIE-OFFSET1-NEXT: DW_IDX_die_offset: 0x00230200 82# MISSING-DIE-OFFSET1-NEXT: DW_IDX_parent: <parent not indexed> 83# MISSING-DIE-OFFSET1-NEXT: DW_IDX_compile_unit: 0x00 84# MISSING-DIE-OFFSET1-NEXT: } 85# MISSING-DIE-OFFSET1-NEXT: } 86# MISSING-DIE-OFFSET1-NEXT: Name 2 { 87# MISSING-DIE-OFFSET1-NEXT: Hash: 0xEDDB6232 88# MISSING-DIE-OFFSET1-NEXT: String: {{.*}} "_start" 89# MISSING-DIE-OFFSET1-NEXT: Entry @ 0x6c { 90# MISSING-DIE-OFFSET1-NEXT: Abbrev: 0x1 91# MISSING-DIE-OFFSET1-NEXT: Tag: DW_TAG_subprogram 92# MISSING-DIE-OFFSET1-NEXT: DW_IDX_die_offset: 0x00000023 93# MISSING-DIE-OFFSET1-NEXT: DW_IDX_parent: <parent not indexed> 94# MISSING-DIE-OFFSET1-NEXT: DW_IDX_compile_unit: 0x00 95# MISSING-DIE-OFFSET1-NEXT: } 96# MISSING-DIE-OFFSET1-NEXT: } 97# MISSING-DIE-OFFSET1-NEXT: ] 98