The current behavior of --verify is that it only verifies debug_info, debug_abbrev and debug_names. This seems fairly arbitrary and might have been unintentional, as originally the absence of any section flags implied "all". This patch changes the behavior so that the verifier now verifies everything by default. It revealed two tests that had potentially invalid DWARF: 1. dwarfdump-str-offsets.s is adding padding between two debug_str_offset contributions. The standard does not explicitly allow this behavior. See issue https://github.com/llvm/llvm-project/issues/81558 2. dwarf5-macro.test uses a checked-in binary that has invalid debug_str_offsets. One of its entries points to the _middle_ of the string section: error: .debug_str_offsets: contribution 0x0: index 0x4: invalid string offset *0x18 == 0x455D, is neither zero nor immediately following a null character If we look at the closest offset to 0x455D in debug_str: ``` 0x0000454e: "__SLONG32_TYPE int" ``` 0x455D points to "int".
171 lines
8.3 KiB
YAML
171 lines
8.3 KiB
YAML
# RUN: yaml2obj %s | not llvm-dwarfdump --verify - | FileCheck %s --implicit-check-not=error:
|
|
|
|
# CHECK: error: DIE has DW_AT_decl_file with invalid encoding{{[[:space:]]}}
|
|
# CHECK-NEXT: 0x0000001a: DW_TAG_subprogram
|
|
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000000d] = "main")
|
|
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001000)
|
|
# CHECK-NEXT: DW_AT_high_pc [DW_FORM_addr] (0x0000000000002000)
|
|
# CHECK-NEXT: DW_AT_decl_file [DW_FORM_strp] ( .debug_str[0x00000012] = "")
|
|
# CHECK-NEXT: DW_AT_call_line [DW_FORM_data1] (5){{[[:space:]]}}
|
|
# CHECK-NEXT: error: DIE has DW_AT_call_file with invalid encoding{{[[:space:]]}}
|
|
# CHECK-NEXT: 0x00000034: DW_TAG_inlined_subroutine
|
|
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000013] = "inline1")
|
|
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001100)
|
|
# CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000100)
|
|
# CHECK-NEXT: DW_AT_call_file [DW_FORM_strp] ( .debug_str[0x00000012] = "")
|
|
# CHECK-NEXT: DW_AT_call_line [DW_FORM_data1] (10){{[[:space:]]}}
|
|
# CHECK-NEXT: error: DIE has DW_AT_decl_file with invalid encoding{{[[:space:]]}}
|
|
# CHECK-NEXT: 0x0000004a: DW_TAG_subprogram
|
|
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000001b] = "foo")
|
|
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000002000)
|
|
# CHECK-NEXT: DW_AT_high_pc [DW_FORM_addr] (0x0000000000003000)
|
|
# CHECK-NEXT: DW_AT_decl_file [DW_FORM_sdata] (2)
|
|
# CHECK-NEXT: DW_AT_decl_line [DW_FORM_sdata] (3)
|
|
# CHECK-NEXT: DW_AT_call_file [DW_FORM_sdata] (4)
|
|
# CHECK-NEXT: DW_AT_call_line [DW_FORM_sdata] (5){{[[:space:]]}}
|
|
# CHECK-NEXT: error: DIE has DW_AT_decl_line with invalid encoding{{[[:space:]]}}
|
|
# CHECK-NEXT: 0x0000004a: DW_TAG_subprogram
|
|
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000001b] = "foo")
|
|
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000002000)
|
|
# CHECK-NEXT: DW_AT_high_pc [DW_FORM_addr] (0x0000000000003000)
|
|
# CHECK-NEXT: DW_AT_decl_file [DW_FORM_sdata] (2)
|
|
# CHECK-NEXT: DW_AT_decl_line [DW_FORM_sdata] (3)
|
|
# CHECK-NEXT: DW_AT_call_file [DW_FORM_sdata] (4)
|
|
# CHECK-NEXT: DW_AT_call_line [DW_FORM_sdata] (5){{[[:space:]]}}
|
|
# CHECK-NEXT: error: DIE has DW_AT_call_file with invalid encoding{{[[:space:]]}}
|
|
# CHECK-NEXT: 0x0000004a: DW_TAG_subprogram
|
|
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000001b] = "foo")
|
|
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000002000)
|
|
# CHECK-NEXT: DW_AT_high_pc [DW_FORM_addr] (0x0000000000003000)
|
|
# CHECK-NEXT: DW_AT_decl_file [DW_FORM_sdata] (2)
|
|
# CHECK-NEXT: DW_AT_decl_line [DW_FORM_sdata] (3)
|
|
# CHECK-NEXT: DW_AT_call_file [DW_FORM_sdata] (4)
|
|
# CHECK-NEXT: DW_AT_call_line [DW_FORM_sdata] (5){{[[:space:]]}}
|
|
# CHECK-NEXT: error: DIE has DW_AT_call_line with invalid encoding{{[[:space:]]}}
|
|
# CHECK-NEXT: 0x0000004a: DW_TAG_subprogram
|
|
# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000001b] = "foo")
|
|
# CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000002000)
|
|
# CHECK-NEXT: DW_AT_high_pc [DW_FORM_addr] (0x0000000000003000)
|
|
# CHECK-NEXT: DW_AT_decl_file [DW_FORM_sdata] (2)
|
|
# CHECK-NEXT: DW_AT_decl_line [DW_FORM_sdata] (3)
|
|
# CHECK-NEXT: DW_AT_call_file [DW_FORM_sdata] (4)
|
|
# CHECK-NEXT: DW_AT_call_line [DW_FORM_sdata] (5){{[[:space:]]}}
|
|
# CHECK-NEXT: Verifying dwo Units...
|
|
# CHECK-NEXT: Verifying .debug_line...
|
|
# CHECK-NEXT: Verifying .debug_str_offsets...
|
|
# CHECK-NEXT: error: Aggregated error counts:
|
|
# CHECK-NEXT: error: Invalid encoding in DW_AT_decl_file occurred 4 time(s).
|
|
# CHECK-NEXT: error: Invalid file index in DW_AT_call_line occurred 1 time(s).
|
|
# CHECK-NEXT: error: Invalid file index in DW_AT_decl_line occurred 1 time(s).
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_EXEC
|
|
Machine: EM_X86_64
|
|
DWARF:
|
|
debug_str:
|
|
- ''
|
|
- '/tmp/main.c'
|
|
- main
|
|
- ''
|
|
- inline1
|
|
- foo
|
|
debug_abbrev:
|
|
- Table:
|
|
- Code: 0x0000000000000001
|
|
Tag: DW_TAG_compile_unit
|
|
Children: DW_CHILDREN_yes
|
|
Attributes:
|
|
- Attribute: DW_AT_name
|
|
Form: DW_FORM_strp
|
|
- Attribute: DW_AT_language
|
|
Form: DW_FORM_data2
|
|
- Attribute: DW_AT_low_pc
|
|
Form: DW_FORM_addr
|
|
- Code: 0x0000000000000002
|
|
Tag: DW_TAG_subprogram
|
|
Children: DW_CHILDREN_yes
|
|
Attributes:
|
|
- Attribute: DW_AT_name
|
|
Form: DW_FORM_strp
|
|
- Attribute: DW_AT_low_pc
|
|
Form: DW_FORM_addr
|
|
- Attribute: DW_AT_high_pc
|
|
Form: DW_FORM_addr
|
|
- Attribute: DW_AT_decl_file
|
|
Form: DW_FORM_strp
|
|
- Attribute: DW_AT_call_line
|
|
Form: DW_FORM_data1
|
|
- Code: 0x0000000000000003
|
|
Tag: DW_TAG_inlined_subroutine
|
|
Children: DW_CHILDREN_no
|
|
Attributes:
|
|
- Attribute: DW_AT_name
|
|
Form: DW_FORM_strp
|
|
- Attribute: DW_AT_low_pc
|
|
Form: DW_FORM_addr
|
|
- Attribute: DW_AT_high_pc
|
|
Form: DW_FORM_data4
|
|
- Attribute: DW_AT_call_file
|
|
Form: DW_FORM_strp
|
|
- Attribute: DW_AT_call_line
|
|
Form: DW_FORM_data1
|
|
- Code: 0x0000000000000004
|
|
Tag: DW_TAG_subprogram
|
|
Children: DW_CHILDREN_no
|
|
Attributes:
|
|
- Attribute: DW_AT_name
|
|
Form: DW_FORM_strp
|
|
- Attribute: DW_AT_low_pc
|
|
Form: DW_FORM_addr
|
|
- Attribute: DW_AT_high_pc
|
|
Form: DW_FORM_addr
|
|
- Attribute: DW_AT_decl_file
|
|
Form: DW_FORM_sdata
|
|
- Attribute: DW_AT_decl_line
|
|
Form: DW_FORM_sdata
|
|
- Attribute: DW_AT_call_file
|
|
Form: DW_FORM_sdata
|
|
- Attribute: DW_AT_call_line
|
|
Form: DW_FORM_sdata
|
|
debug_info:
|
|
- Length: 0x0000000000000061
|
|
Version: 4
|
|
AbbrOffset: 0x0000000000000000
|
|
AddrSize: 8
|
|
Entries:
|
|
- AbbrCode: 0x00000001
|
|
Values:
|
|
- Value: 0x0000000000000001
|
|
- Value: 0x0000000000000002
|
|
- Value: 0x0000000000000000
|
|
- AbbrCode: 0x00000002
|
|
Values:
|
|
- Value: 0x000000000000000D
|
|
- Value: 0x0000000000001000
|
|
- Value: 0x0000000000002000
|
|
- Value: 0x0000000000000012
|
|
- Value: 0x0000000000000005
|
|
- AbbrCode: 0x00000003
|
|
Values:
|
|
- Value: 0x0000000000000013
|
|
- Value: 0x0000000000001100
|
|
- Value: 0x0000000000000100
|
|
- Value: 0x0000000000000012
|
|
- Value: 0x000000000000000A
|
|
- AbbrCode: 0x00000004
|
|
Values:
|
|
- Value: 0x000000000000001B
|
|
- Value: 0x0000000000002000
|
|
- Value: 0x0000000000003000
|
|
- Value: 0x0000000000000002
|
|
- Value: 0x0000000000000003
|
|
- Value: 0x0000000000000004
|
|
- Value: 0x0000000000000005
|
|
- AbbrCode: 0x00000000
|
|
Values: []
|
|
- AbbrCode: 0x00000000
|
|
Values: []
|
|
...
|