[llvm-bugs] [Bug 41779] New: [CFI] Compilation error in Windows

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 6 17:05:23 PDT 2019


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

            Bug ID: 41779
           Summary: [CFI] Compilation error in Windows
           Product: new-bugs
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: xiaoyang.xu at utdallas.edu
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 21900
  --> https://bugs.llvm.org/attachment.cgi?id=21900&action=edit
A C++ program that makes function calls through function pointers

I was testing LLVM Control Flow Integrity (CFI) on x64 Windows 10. The c++
source code attached makes a function call through a function pointer in an
intensive loop. Which function will be called is based on the parity of a
random integer. With CFI enabled (using flags -fsanitize=cfi and -flto), such
function calls should be compiled to indirect calls. This works perfectly in
Linux, but I got a compilation error in Windows using the same command:

C:\Users\Xiaoyang\Dropbox\CFIBenchmarks\fptr>clang++ -fsanitize=cfi -flto -o
fptr.exe fptr.cpp
C:\Users\Xiaoyang\AppData\Local\Temp\fptr-3c8ec9.o : fatal error LNK1107:
invalid or corrupt file: cannot read at 0x1CB0
clang++.exe: error: linker command failed with exit code 1107 (use -v to see
invocation)

If I remove the CFI and link-time optimization flags, I can successfully
compile and run this program:

C:\Users\Xiaoyang\Dropbox\CFIBenchmarks\fptr>clang++ fptr.cpp -o fptr.exe
C:\Users\Xiaoyang\Dropbox\CFIBenchmarks\fptr>fptr.exe
49893 odd numbers
50107 even numbers

I got this error in both LLVM 8.0.0 and 7.0.1.

-- 
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/20190507/d67748b6/attachment.html>


More information about the llvm-bugs mailing list