[llvm-bugs] [Bug 37599] New: lld-link silently accepts AMD64_REL32 against absolute symbol
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 25 17:31:55 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37599
Bug ID: 37599
Summary: lld-link silently accepts AMD64_REL32 against absolute
symbol
Product: lld
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: COFF
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, ruiu at google.com
% cat reduced.s
.weak weak
.globl main
main:
leaq weak(%rip), %rax
retq
% llvm-mc -triple x86_64-windows-msvc -filetype=obj -o reduced.o reduced.s
% lld-link -entry:main reduced.o
Weak symbols are implemented for COFF on LLVM by using COFF weak externals and
creating an absolute symbol with the value 0 as the fallback symbol. Since we
don't define weak in this case, we'll end up falling back to the absolute
symbol. lld will then silently accept the AMD64_ADDR32 relocation against the
absolute symbol, which will produce the wrong result at runtime, whereas link
produces an error:
error LNK2016: absolute symbol 'foo' used as target of REL32 relocation in
section 1
(I used the weak external mechanism to demonstrate the issue because if I just
create an absolute symbol directly and try to create RIP-relative relocation
against that, clang won't actually emit the relocation in the object file.)
--
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/25446f74/attachment.html>
More information about the llvm-bugs
mailing list