From 2d1fc4375f3885f0ee0ffcb58fc554530cd74ef2 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 29 Mar 2018 13:47:57 +0000 Subject: [PATCH] .debug_names: Parse DW_IDX_die_offset as a reference Before this patch we were parsing the attributes as section offsets, as that is what apple_names is doing. However, this is not correct as DWARF v5 specifies that this attribute should use the Reference form class. This also updates all the testcases (except the ones that deliberately pass a different form) to use the correct form class. llvm-svn: 328773 --- .../DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 2 +- llvm/test/DebugInfo/X86/dwarfdump-debug-names.s | 16 ++++++++-------- .../tools/llvm-dwarfdump/X86/debug-names-find.s | 4 ++-- .../X86/debug-names-verify-abbrev-duplicate.s | 4 ++-- .../X86/debug-names-verify-abbrev-forms.s | 2 +- .../X86/debug-names-verify-buckets.s | 2 +- .../X86/debug-names-verify-unhashed-names.s | 2 +- .../X86/debug-names-verify-wrong-hash.s | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp index 3b9662067c3c..40174119b0aa 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -535,7 +535,7 @@ DWARFDebugNames::Entry::lookup(dwarf::Index Index) const { Optional DWARFDebugNames::Entry::getDIEUnitOffset() const { if (Optional Off = lookup(dwarf::DW_IDX_die_offset)) - return Off->getAsSectionOffset(); + return Off->getAsReferenceUVal(); return None; } diff --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-names.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-names.s index 0291591f4ab3..2b28c07533d7 100644 --- a/llvm/test/DebugInfo/X86/dwarfdump-debug-names.s +++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-names.s @@ -44,7 +44,7 @@ .byte 46 # Abbrev code .byte 46 # DW_TAG_subprogram .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 0 # End of abbrev list @@ -52,11 +52,11 @@ .Lnames_entries0: .Lnames0: .byte 46 # Abbrev code - .long .Ldie0 # DW_IDX_die_offset + .long .Ldie0-.Lcu_begin0 # DW_IDX_die_offset .long 0 # End of list: foo .Lnames1: .byte 46 # Abbrev code - .long .Ldie0 # DW_IDX_die_offset + .long .Ldie0-.Lcu_begin0 # DW_IDX_die_offset .long 0 # End of list: _Z3foov .p2align 2 .Lnames_end0: @@ -81,7 +81,7 @@ .byte 52 # Abbrev code .byte 52 # DW_TAG_variable .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 0 # End of abbrev list @@ -89,7 +89,7 @@ .Lnames_entries1: .Lnames2: .byte 52 # Abbrev code - .long .Ldie1 # DW_IDX_die_offset + .long .Ldie1-.Lcu_begin1 # DW_IDX_die_offset .long 0 # End of list: bar .p2align 2 .Lnames_end1: @@ -113,7 +113,7 @@ # CHECK-NEXT: Abbreviations [ # CHECK-NEXT: Abbreviation 0x2e { # CHECK-NEXT: Tag: DW_TAG_subprogram -# CHECK-NEXT: DW_IDX_die_offset: DW_FORM_data4 +# CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4 # CHECK-NEXT: } # CHECK-NEXT: ] # CHECK-NEXT: Bucket 0 [ @@ -159,7 +159,7 @@ # CHECK-NEXT: Abbreviations [ # CHECK-NEXT: Abbreviation 0x34 { # CHECK-NEXT: Tag: DW_TAG_variable -# CHECK-NEXT: DW_IDX_die_offset: DW_FORM_data4 +# CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4 # CHECK-NEXT: } # CHECK-NEXT: ] # CHECK-NEXT: Bucket 0 [ @@ -169,7 +169,7 @@ # CHECK-NEXT: Entry @ 0xa3 { # CHECK-NEXT: Abbrev: 0x34 # CHECK-NEXT: Tag: DW_TAG_variable -# CHECK-NEXT: DW_IDX_die_offset: 0x00000003 +# CHECK-NEXT: DW_IDX_die_offset: 0x00000001 # CHECK-NEXT: } # CHECK-NEXT: } # CHECK-NEXT: ] diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-find.s b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-find.s index e65ede13c3b1..d21ba6df254c 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-find.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-find.s @@ -121,7 +121,7 @@ .byte 46 # Abbrev code .byte 46 # DW_TAG_subprogram .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 0 # End of abbrev list @@ -163,7 +163,7 @@ .byte 46 # Abbrev code .byte 46 # DW_TAG_subprogram .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 0 # End of abbrev list diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-abbrev-duplicate.s b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-abbrev-duplicate.s index 5c5075ca25f4..03b1af982de8 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-abbrev-duplicate.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-abbrev-duplicate.s @@ -50,13 +50,13 @@ .byte 46 # Abbrev code .byte 46 # DW_TAG_subprogram .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 46 # Abbrev code .byte 46 # DW_TAG_subprogram .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 0 # End of abbrev list diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-abbrev-forms.s b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-abbrev-forms.s index 9aaa4c4dd2c2..910431c6206e 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-abbrev-forms.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-abbrev-forms.s @@ -65,7 +65,7 @@ .byte 17 # DW_FORM_ref1 .byte 2 # DW_IDX_type_unit .byte 17 # DW_FORM_ref1 - .byte 2 # DW_IDX_die_offset + .byte 2 # DW_IDX_type_unit .byte 5 # DW_FORM_data2 .byte 5 # DW_IDX_type_hash .byte 6 # DW_FORM_data4 diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-buckets.s b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-buckets.s index 5934d6d820ac..551e51c59ed3 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-buckets.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-buckets.s @@ -69,7 +69,7 @@ .byte 46 # Abbrev code .byte 46 # DW_TAG_subprogram .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 0 # End of abbrev list diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-unhashed-names.s b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-unhashed-names.s index cd9bbcdffe33..72ee6d7ef37e 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-unhashed-names.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-unhashed-names.s @@ -97,7 +97,7 @@ .byte 46 # Abbrev code .byte 46 # DW_TAG_subprogram .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 0 # End of abbrev list diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-wrong-hash.s b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-wrong-hash.s index baffaece8423..b0e01813ca1e 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-wrong-hash.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug-names-verify-wrong-hash.s @@ -79,7 +79,7 @@ .byte 46 # Abbrev code .byte 46 # DW_TAG_subprogram .byte 3 # DW_IDX_die_offset - .byte 6 # DW_FORM_data4 + .byte 19 # DW_FORM_ref4 .byte 0 # End of abbrev .byte 0 # End of abbrev .byte 0 # End of abbrev list