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: unassignedb...@nondot.org
          Reporter: smee...@fb.com
                CC: compn...@compnerd.org, llvm-bugs@lists.llvm.org,
                    r...@google.com, r...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to