<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - lld-link silently accepts AMD64_REL32 against absolute symbol"
   href="https://bugs.llvm.org/show_bug.cgi?id=37599">37599</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lld-link silently accepts AMD64_REL32 against absolute symbol
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>COFF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>smeenai@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>compnerd@compnerd.org, llvm-bugs@lists.llvm.org, rnk@google.com, ruiu@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>% 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.)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>