<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - llvm-dwarfdump with DWARF3: error: Unable to resolve DW_LLE_offset_pair: base address unknown"
   href="https://bugs.llvm.org/show_bug.cgi?id=44482">44482</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm-dwarfdump with DWARF3: error: Unable to resolve DW_LLE_offset_pair: base address unknown
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>meyer@absint.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, labath@google.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22995" name="attach_22995" title="test case">attachment 22995</a> <a href="attachment.cgi?id=22995&action=edit" title="test case">[details]</a></span>
test case

We have a test case built with CompCert, for which (I think ;-) llvm-dwarfdump
falsely emits an error on "llvm-dwarfdump -all -verify $attached_binary":
<span class="quote">> error: Unable to resolve DW_LLE_offset_pair: base address unknown</span >

This only happened after upgrading llvm to a newer trunk. Tested last week with
git/master cd2a73a9f01b2ec1b7e239ba83201199df0d7912 (the relevant code doesn't
seem to have changed since then).

The problem seems to be that some DWARF3 .debug_loc info is parsed as a DWARF5
DW_LLE_offset_pair, and in that case the parser (now) always expects a
DW_LLE_base_address to be set - else it emits the above error. For DWARF5 that
would be correct, however, for DWARF3 there are no DW_LLE_* codes, and the
parser should just use an offset of 0.

Some digging points to <a href="https://reviews.llvm.org/D70081">https://reviews.llvm.org/D70081</a> and commit
<a href="https://github.com/llvm/llvm-project/commit/ebe2f56030458e7a4c2375c6d92a48f0ed01eb5b">https://github.com/llvm/llvm-project/commit/ebe2f56030458e7a4c2375c6d92a48f0ed01eb5b</a>
- more specifically, the code around the "if (!Base)" at
<a href="https://github.com/llvm/llvm-project/blame/master/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp#L81">https://github.com/llvm/llvm-project/blame/master/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp#L81</a>

Hence adding labath to CC list.

Tool output:
<span class="quote">> Verifying [...]
> Verifying .debug_abbrev...
> Verifying .debug_info Unit Header Chain...
> error: Unable to resolve DW_LLE_offset_pair: base address unknown

> 0x00000297: DW_TAG_formal_parameter
>               DW_AT_name   ("x")
>               DW_AT_type   (0x0000000000000066 "int")
>               DW_AT_location       (0x00000000: 
>                  (0x000000000040ad80, 0x000000000040ad84): DW_OP_reg0)

> Verifying .debug_info references...
> Verifying .debug_types Unit Header Chain...
> Verifying .debug_line...
> Errors detected.</span >

debug_info (header), only a single CU, version is 3:
<span class="quote">>  Compilation Unit @ offset 0x0:
>   Length:        0x2a1 (32-bit)
>   Version:       3
>   Abbrev Offset: 0x0
>   Pointer Size:  8</span >

debug_info (for this entry the verification fails):
<span class="quote">> <2><297>: Abbrev Number: 13 (DW_TAG_formal_parameter)
>     <298>   DW_AT_name        : x
>     <29a>   DW_AT_type        : <0x66>
>     <29e>   DW_AT_location    : 0x0 (location list)</span >

debug_abbrev for the above entry:
<span class="quote">>   13      DW_TAG_formal_parameter    [no children]
>    DW_AT_name         DW_FORM_string
>    DW_AT_type         DW_FORM_ref_addr
>    DW_AT_location     DW_FORM_data4
>    DW_AT value: 0     DW_FORM value: 0</span >

debug_loc:
<span class="quote">>    Offset   Begin            End              Expression
>    00000000 000000000040ad80 000000000040ad84 (DW_OP_reg0 (x0))
>    00000013 <End of list</span >

The attached binary is built with (latest as of 30th Dec) CompCert for AArch64.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>