[llvm-bugs] [Bug 39826] New: merge:.rdata=.text produces broken executable

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 28 09:18:38 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=39826

            Bug ID: 39826
           Summary: merge:.rdata=.text produces broken executable
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: me at veg.by
                CC: llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181128/66294236/attachment.html>


More information about the llvm-bugs mailing list