[llvm-bugs] [Bug 37598] New: clang emitting RIP-relative relocation for weak external on Windows x86-64
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 25 17:10:50 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37598
Bug ID: 37598
Summary: clang emitting RIP-relative relocation for weak
external on Windows x86-64
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: smeenai at fb.com
CC: compnerd at compnerd.org, llvm-bugs at lists.llvm.org,
rnk at google.com
% cat reduced.ll
@Weak = extern_weak global i32
define i32* @getWeak() {
ret i32* @Weak
}
% clang -target x86_64-windows-msvc -S -o - reduced.ll
.text
.def getWeak;
.scl 2;
.type 32;
.endef
.globl getWeak # -- Begin function getWeak
.p2align 4, 0x90
getWeak: # @getWeak
# %bb.0:
leaq Weak(%rip), %rax
retq
# -- End function
.weak Weak
The issue is that LLVM implements weak symbols for COFF through the weak
external mechanism, and it emits an absolute symbol with the value of 0 to
serve as the fallback symbol. We'll therefore end up with a RIP-relative
relocation against an absolute symbol in the case where Weak isn't defined.
link errors out for this:
error LNK2016: absolute symbol 'Weak' used as target of REL32 relocation in
section 1
LLD accepts it silently; I'll file a separate bug for that.
--
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/20180526/5e93defb/attachment-0001.html>
More information about the llvm-bugs
mailing list