<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 - wrong code for hidden undefined weak symbol access"
   href="https://bugs.llvm.org/show_bug.cgi?id=34824">34824</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>wrong code for hidden undefined weak symbol access
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </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, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given 

@foo = extern_weak hidden global i32, align 4
define i32* @_start() nounwind {                
  ret i32* @foo                                 
}
!llvm.module.flags = !{!1, !2}                  
!1 = !{i32 7, !"PIC Level", i32 2}              
!2 = !{i32 7, !"PIE Level", i32 2}  

llc for 32 bit x86 produces

        calll   .L0$pb                          
.L0$pb:                                         
        popl    %eax                            
.Ltmp0:                                         
        addl    $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax                    
        leal    foo@GOTOFF(%eax), %eax          
        retl 

The problem is that given the undefined weak, there will be no relocations in
the final position independent executable and the above sequence will resolve
to the load base instead of 0.

We have code in x86_64 to avoid this, but I think it is a general problem. We
should disable it for all architectures.</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>