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: unassignedb...@nondot.org
          Reporter: m...@veg.by
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to