<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 - __register_frame should accept CIE as well as FDE"
   href="https://bugs.llvm.org/show_bug.cgi?id=47750">47750</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__register_frame should accept CIE as well as FDE
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Runtime 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>libunwind
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nick@wasmer.io
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Related to <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Add option for the behavior of __register_frame/__deregister_frame in ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp"
   href="show_bug.cgi?id=44074">bug 44074</a>.

libgcc_s's __register_frame accepts a CIE as the argument and registers all the
FDEs inside it. I'm not convinced it even works if you give it an FDE, I tried
to call it with each FDE entry in my CIE but it appeared to be a no-op. It's
possible this is supposed to work, though I found the code in libgcc/ difficult
to follow. At least the comments talk about __register_frame's input pointer
being ".eh_frame" which would be a CIE, not an FDE.

libunwind's __register_frame only accepts FDEs and when given a CIE it emits a
warning and ignores the contents of the CIE.

Please accept CIEs in __register_frame by registering each FDE in the CIE
provided.

Alternatively stop providing an implementation of __register_frame because it
is incompatible with libgcc's and (unless I'm mistaken) impossible for callers
to satisfy the API requirements of both libunwind and libgcc.


If you'd like to see the CIE and its FDEs I was working with, here's the hex:

const char eh_frame[] = {0x14, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
0x1, 0x78, 0x10, 0xc, 0x7, 0x8, 0x90, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c,
0x0, 0x0, 0x0, 0x1c, 0x0, 0x0, 0x0, 0x20, 0x70, 0x51, 0x45, 0xf5, 0x7f, 0x0,
0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x42, 0xe, 0x10, 0x86, 0x2, 0x43,
0xd, 0x6, 0x24, 0x0, 0x0, 0x0, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x70, 0x51, 0x45,
0xf5, 0x7f, 0x0, 0x0, 0x15, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x42, 0xe, 0x10,
0x86, 0x2, 0x43, 0xd, 0x6, 0x4f, 0xc, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0};

(Side feature request, it'd be helpful if llvm-dwarfdump could parse a detached
eh_frame like this.)</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>