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


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@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

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to