[PATCH] D79962: Fix the verification of DIEs with DW_AT_ranges.

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 14 13:36:22 PDT 2020


clayborg created this revision.
clayborg added reviewers: aprantl, labath, probinson, JDevlieghere.
Herald added subscribers: cmtice, MaskRay, hiraditya.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.
clayborg added reviewers: dblaikie, compnerd.
clayborg added a comment.

The verification for:

  0x0000000b: DW_TAG_compile_unit
                DW_AT_name        ("/tmp/main.c")
                DW_AT_language    (DW_LANG_C_plus_plus)
                DW_AT_low_pc      (0x0000000000000000)
                DW_AT_ranges      (0x00000000
                   [0x0000000000000000, 0x0000000000000020)
                   [0x0000000000000000, 0x0000000000000030)
                   [0x0000000000001000, 0x0000000000002000))
                DW_AT_stmt_list   (0x00000000)
  
  0x00000022:   DW_TAG_subprogram
                  DW_AT_name      ("stripped1")
                  DW_AT_low_pc    (0x0000000000000000)
                  DW_AT_high_pc   (0x0000000000000020)
  
  0x00000033:   DW_TAG_subprogram
                  DW_AT_name      ("stripped2")
                  DW_AT_low_pc    (0x0000000000000000)
                  DW_AT_high_pc   (0x0000000000000030)
  
  0x00000048:   DW_TAG_subprogram
                  DW_AT_name      ("main")
                  DW_AT_low_pc    (0x0000000000001000)
                  DW_AT_high_pc   (0x0000000000002000)
  
  0x00000059:   NULL

Now looks like:

  $ ../debug/bin/llvm-dwarfdump --verify /tmp/a.out
  Verifying /tmp/a.out:   file format Mach-O 64-bit x86-64
  Verifying .debug_abbrev...
  Verifying .debug_info Unit Header Chain...
  error: DIE has overlapping ranges in DW_AT_ranges attribute: [0x0000000000000000, 0x0000000000000020) and [0x0000000000000000, 0x0000000000000030)
  0x0000000b:   DW_TAG_compile_unit
                  DW_AT_name      ("/tmp/main.c")
                  DW_AT_language  (DW_LANG_C_plus_plus)
                  DW_AT_low_pc    (0x0000000000000000)
                  DW_AT_ranges    (0x00000000
                     [0x0000000000000000, 0x0000000000000020)
                     [0x0000000000000000, 0x0000000000000030)
                     [0x0000000000001000, 0x0000000000002000))
                  DW_AT_stmt_list (0x00000000)
  
  error: DIEs have overlapping address ranges:
  0x00000033: DW_TAG_subprogram
                DW_AT_name        ("stripped2")
                DW_AT_low_pc      (0x0000000000000000)
                DW_AT_high_pc     (0x0000000000000030)
  
  0x00000022: DW_TAG_subprogram
                DW_AT_name        ("stripped1")
                DW_AT_low_pc      (0x0000000000000000)
                DW_AT_high_pc     (0x0000000000000020)
  
  Verifying .debug_info references...
  Verifying .debug_types Unit Header Chain...
  Errors detected.


Previous code would try to verify DW_AT_ranges and if any ranges would overlap, it would stop attributing any ranges after this to the DIE which caused incorrect errors to be reported that a DIE's address ranges were not contained in the parent DIE's ranges. Added a fix and a test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79962

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/test/tools/llvm-dwarfdump/X86/verify_overlapping_cu_ranges.yaml

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79962.264077.patch
Type: text/x-patch
Size: 16806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200514/bc575506/attachment.bin>


More information about the llvm-commits mailing list