<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 - merge:.rdata=.text produces broken executable"
   href="https://bugs.llvm.org/show_bug.cgi?id=39826">39826</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>merge:.rdata=.text produces broken executable
          </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>release blocker
          </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>me@veg.by
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The issue is easy to reproduce using clang 8.0.0 from trunk.

1. Create test.cpp with these contents:

#include <stdio.h>
int wmain(int argc, wchar_t* argv[])
{
        printf("Hello, world!");
        return 0;
}

2. Compile it using this command:

clang -std=c++17 -m32 -fuse-ld=lld -Oz
-Wl,-subsystem:console,-merge:.rdata=.text,-out:test.exe test.cpp

3. Try to run test.exe, you will see this error:

---------------------------
test.exe - System Error
---------------------------
The program can't start because KERNEL32.dllММММ  is missing from your
computer. Try reinstalling the program to fix this problem. 
---------------------------
OK   
---------------------------

If you look into test.exe, you will notice that all the strings from the merged
.rdata section use 0xCC for padding, and 0xCC is used instead of 0 at the end
of strings like KERNEL32.DLL or function names.

I believe that when you merge a data section into code section, it should not
change padding byte from 0x00 to 0xCC, it should just merge sections without
changing actual contents of the sections.

LLVM v7 didn't have the issue.</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>