Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFI tests using ThinLTO on Windows all fail with unsupported X86 relocation #32117

Closed
rnk opened this issue Apr 24, 2017 · 8 comments
Closed
Labels
bugzilla Issues migrated from bugzilla

Comments

@rnk
Copy link
Collaborator

rnk commented Apr 24, 2017

Bugzilla Link 32770
Resolution FIXED
Resolved on Sep 15, 2017 11:55
Version trunk
OS Windows NT
CC @eugenis,@zmodem,@pcc

Extended Description

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!

@pcc
Copy link
Contributor

pcc commented Apr 24, 2017

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).

@eugenis
Copy link
Contributor

eugenis commented Apr 24, 2017

Disabled the tests for now in r301235

@zmodem
Copy link
Collaborator

zmodem commented Apr 24, 2017

I got test failures at r301243 still: https://codereview.chromium.org/2843513003

And it looks like the bot from #​0 is still red.

@eugenis
Copy link
Contributor

eugenis commented Apr 24, 2017

Ouch. r301257. I love CMake.

@pcc
Copy link
Contributor

pcc commented Jun 21, 2017

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

@pcc
Copy link
Contributor

pcc commented Sep 15, 2017

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.

@pcc
Copy link
Contributor

pcc commented Sep 15, 2017

The change to re-enable the tests landed in r313379.

@pcc
Copy link
Contributor

pcc commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#32776

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

4 participants