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

            Bug ID: 40624
           Summary: -mlong-calls generates non-PIC code on ARM
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: mh+l...@glandium.org
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

With the following source:
```
extern __attribute__((visibility("hidden"))) int foo();

int bar() { return foo(); };
```

clang generates the following with -fPIC -mlong-calls -O3
--target=armv7a-linux-gnueabi:
```
bar:
        ldr     r0, .LCPI0_0
        bx      r0
.LCPI0_0:
        .long   foo
```

That is not PIC, as that .LCPI0_0 label is in .text.

GCC generates the following:
```
bar:
        ldr     r3, .L3
.LPIC0:
        add     r3, pc, r3
        bx      r3
.L3:
        .word   foo-(.LPIC0+8)
```

(All courtesy of godbolt)

https://godbolt.org/z/gKwbiO

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to