<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 - LLD ICF needs to consider exception tables in .xdata as part of .text equivalence"
   href="https://bugs.llvm.org/show_bug.cgi?id=35337">35337</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD ICF needs to consider exception tables in .xdata as part of .text equivalence
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>COFF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>LLD mislinks this program because the .text contents of these two functions are
the same, but the .xdata exception handler table is different:

extern "C" void __ImageBase() noexcept(false);
void __declspec(dllexport) foo() {
  try {
    __ImageBase();
  } catch (int) {
  }
}
void __declspec(dllexport) baz() {
  try {
    __ImageBase();
  } catch (double) {
  }
}

Compile and link like so, and observe that the export RVAs are the same:

$ clang-cl -EHsc -O1 -MD t.cpp -c && lld-link t.obj -dll -noentry -opt:icf
-force
C:\src\llvm-project\build\bin\lld-link.exe: warning: t.obj: undefined symbol:
__CxxFrameHandler3
C:\src\llvm-project\build\bin\lld-link.exe: warning:
msvcrt.lib(delete_scalar.obj): undefined symbol: free

$ llvm-readobj -coff-exports t.dll

File: t.dll
Format: COFF-x86-64
Arch: x86_64
AddressSize: 64bit
Export {
  Ordinal: 0
  Name:
  RVA: 0x0
}
Export {
  Ordinal: 1
  Name: ?baz@@YAXXZ
  RVA: 0x6000
}
Export {
  Ordinal: 2
  Name: ?foo@@YAXXZ
  RVA: 0x6000
}

If this were a full working program, bar would not be able to catch exceptions
of type double thrown from __ImageBase and would incorrectly catch 'int'
exceptions.</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>