This was found after Evgeniy's refactoring of the CFI tests in r301016. The failing tests: Failing Tests (4): cfi-devirt-lld-thinlto :: simple-pass.cpp cfi-devirt-thinlto :: simple-pass.cpp cfi-standalone-lld-thinlto :: simple-pass.cpp cfi-standalone-thinlto :: simple-pass.cpp Example build: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/10028/ LLD crashes when attempting to emit a COFF object after ThinLTO optimization: $ "C:/b/slave/sanitizer-windows/build/./bin/clang.exe" "-fuse-ld=lld" "-Wl,-nopdb" "-flto=thin" "-fsanitize=cfi" "-fvisibility=hidden" "-o" "C:\b\slave\sanitizer-windows\build\projects\compiler-rt\test\cfi\Standalone-thinlto\Output\simple-pass.cpp.tmp" "C:\b\slave\sanitizer-windows\llvm\projects\compiler-rt\test\cfi\simple-pass.cpp" # command stderr: unsupported relocation type UNREACHABLE executed at C:\b\slave\sanitizer-windows\llvm\lib\Target\X86\MCTargetDesc\X86WinCOFFObjectWriter.cpp:92!
ThinLTO + CFI may use 8-bit relocations (R_X86_64_8 in ELF) to absolute symbols whose values are in range 0-255. Absolute symbols exist in COFF, but there is no direct analog for the relocation. That is what I suspect the cause of the assertion failure to be. The solution I had in mind was to use IMAGE_REL_AMD64_SECREL7, and have LLD extend its meaning to allow for 8-bit values and absolute symbols (this may not work with /msvclto though).
Disabled the tests for now in r301235
I got test failures at r301243 still: https://codereview.chromium.org/2843513003 And it looks like the bot from #0 is still red.
Ouch. r301257. I love CMake.
It looks like the MSVC linker rejects SECRELs pointing to absolute symbols, so this probably won't work with /msvclto. C:\src\secrel7>type 1.s .text .data .globl p # @p .p2align 3 .zero 128 p: .byte 0x12 .byte 0x34 .byte 0x56 .byte 0x78 .long i@secrel32 C:\src\secrel7>type 2.s .globl i i = 42 C:\src\secrel7>\src\llvm-project\ra\bin\llvm-mc -filetype=obj -o 1.obj 1.s C:\src\secrel7>\src\llvm-project\ra\bin\llvm-mc -filetype=obj -o 2.obj 2.s C:\src\secrel7>link 1.obj 2.obj /entry:ExitProcess kernel32.lib /subsystem:console Microsoft (R) Incremental Linker Version 14.00.24215.1 Copyright (C) Microsoft Corporation. All rights reserved. 1.obj : error LNK2016: absolute symbol 'i' used as target of SECREL relocation in section 2 LINK : fatal error LNK1165: link failed because of fixup errors
I ended up fixing this another way at least for now, by avoiding the use of absolute symbols on everything except x86 + ELF. https://reviews.llvm.org/D37883 should re-enable the tests.
The change to re-enable the tests landed in r313379.