<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 - cfi, cross-dso, wrong operation of -fno-sanitize-cfi-cross-dso"
   href="https://bugs.llvm.org/show_bug.cgi?id=48635">48635</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>cfi, cross-dso, wrong operation of -fno-sanitize-cfi-cross-dso
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>qwertytmp1@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24328" name="attach_24328" title="Reproducible example">attachment 24328</a> <a href="attachment.cgi?id=24328&action=edit" title="Reproducible example">[details]</a></span>
Reproducible example

Clang compiler doesn't ignore cross-dso calls for the following conditions:
- CFI is enabled;
- -fno-sanitize-cfi-cross-dso is used;
- optimization level is -O2;
- LLVM's ld.lld linker is used.

"Compiler-time" problem rises if one try to execute the function from the
shared object (.so) from the other executable binary (main).

Instead, compiler generates binary code with undefined instruction on the place
where cross-dso is used, for example:
```
  int exec_func_from_dso(void)
  {
      fptr_t fptr = get_fptr();
    201751:       e8 5a 00 00 00          callq  2017b0 <get_fptr@plt>
      fptr();
    201756:       0f 0b                   ud2
```

At the same time, there is no problem with the source code (please, see
attached cfi_cross_dso_problem_report.tar).

Clang's help says:
```
-fno-sanitize-cfi-cross-dso
    Disable control flow integrity (CFI) checks for cross-DSO calls.
```

As a user of the Clang I understand that if to use
"-fno-sanitize-cfi-cross-dso", cross-dso places will not be taken into account
during CFI operation (compilation and run-time execution).</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>