[llvm-bugs] [Bug 34148] New: wrong code generated for extern_weak relocation with -pic-level 2 -pic-is-pie -mpie-copy-relocations

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 10 18:16:23 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34148

            Bug ID: 34148
           Summary: wrong code generated for extern_weak relocation with
                    -pic-level 2 -pic-is-pie -mpie-copy-relocations
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: llvm-bugs at lists.llvm.org

Testcase:

extern "C" int printf(const char*, ...);
extern __attribute__((weak)) int n;
int main() { printf("%p\n", &n); }

Built with -pic-level 2 -pic-is-pie -mpie-copy-relocations, we generate this
bogus code:

        leaq    .L.str(%rip), %rdi
        leaq    n(%rip), %rsi
        xorl    %eax, %eax
        callq   printf at PLT

Note the %rip-relative lea for n: this is wrong, that relocation type cannot
represent the possibility that &n is 0, which happens when the symbol is not
defined.

-- 
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/20170811/ca5dd24d/attachment.html>


More information about the llvm-bugs mailing list