<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - .pdata sections for associative comdat functions are rejected by MSVC 2015 incremental linker"
   href="https://llvm.org/bugs/show_bug.cgi?id=27424">27424</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>.pdata sections for associative comdat functions are rejected by MSVC 2015 incremental linker
          </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>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>MC
          </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>david.majnemer@gmail.com, llvm-bugs@lists.llvm.org, nicolasweber@gmx.de, rafael.espindola@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This was encountered in Chromium:
<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=595702">https://bugs.chromium.org/p/chromium/issues/detail?id=595702</a>

A C test case:
void f();
int main() {
  __try {
    f();
  } __finally {
    f();
  }
}

Given this code, clang will produce two .text sections: one for main and one
for the finally funclet. The finally funclet is COMDAT associative with the
main .text section. Our COFF section uniquing table is keyed on section name,
comdat selection type, and associative comdat symbol. When we go to create
.pdata sections for those .text sections, we end up reusing the same .pdata
section for both.

In a non-incremental linking scenario, this appears to be OK: the .text and
.pdata sections will all be included in or discarded from the executable
together. However, when linking incrementally, the new 2015 linker appears to
expect each .pdata section to only contain relocations against a single .text
section, i.e. there is a one-to-one mapping from .pdata section to .text
section. LLVM doesn't currently do that.

Here's a reduced LLVM IR test case that we should presumably emit two .pdata
sections for but don't today:

$f = comdat any
define weak_odr void @f() comdat($f) {
  call void @g()
  ret void
}
define internal void @g() comdat($f) {
  ret void
}

How should we solve this? We could implement support for .section ...,unique,ID
like we have for ELF, and then teach MC to use this functionality to implement
.seh_handlerdata. However, all that assembler support is totally unnecessary
for the problem at hand, because .pdata is emitted late by the .seh_handlerdata
directive.

It's also worth pointing out that C++ EH funclets currently do not use separate
.text sections, and in that case we should have one .pdata and .xdata section
with an entry for each funclet. If we bypassed the uniquing map and directly
created a new .pdata section every time we need it, we will end up with more
sections than we need in this case.</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>