[llvm-bugs] [Bug 34824] New: wrong code for hidden undefined weak symbol access

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 3 18:42:23 PDT 2017


            Bug ID: 34824
           Summary: wrong code for hidden undefined weak symbol access
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: rafael.espindola at gmail.com
                CC: llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk


@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                          
        popl    %eax                            
        addl    $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax                    
        leal    foo at GOTOFF(%eax), %eax          

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.

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/20171004/6f6b1c6c/attachment.html>

More information about the llvm-bugs mailing list