<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 - missing error on reference to undefined weak symbol"
   href="https://bugs.llvm.org/show_bug.cgi?id=34058">34058</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>missing error on reference to undefined weak 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>Linux
          </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>ELF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rafael.espindola@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>bfd ld with -shared will produce an error on

leaq    foo(%rip), %rax
.weak foo
.hidden foo

That is reasonable. The value of foo is zero, and we will not be able to
compute that a runtime. The intention of the leaq was probably to check the
value of foo in the first place.

The problem is that it should *not* produce an error if the leaq is replaced
with a call. The logic being that the call will be guarded:

if (foo)
  foo();

Unfortunately, on x86_64 at least, both constructs produce the same relocation.
It just seems too fuzzy to have the linker parse the instruction using the
relocation.

I am reporting the bug in case someone has a better idea on how to implement
this or if some other architecture does have different relocations.</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>