Skip to content

-mlong-calls generates non-PIC code on ARM #39970

Open
@glandium

Description

@glandium
Bugzilla Link 40624
Version unspecified
OS Linux
CC @froydnj

Extended Description

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions