This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bizarre ARM PIC code generation


Recent versions of arm-linux GCC seem to want to call "bar" indirectly through 
registers in this code:

void
foo(void)
{
  void bar(void) __attribute__((weak));
  bar();
  asm("xx");
}

Compiling with -fPIC -O2 -fomit-frame-pointer gives:

foo:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, current_function_anonymous_args = 0
        stmfd   sp!, {sl, lr}
        ldr     sl, .L4
        ldr     r3, .L4+4
.L3:
        add     sl, pc, sl
        mov     lr, pc
        ldr     pc, [sl, r3]
        xx
        ldmfd   sp!, {sl, pc}
.L5:
        .align  2
.L4:
        .word   _GLOBAL_OFFSET_TABLE_ - (.L3+8)
        .word   bar(GOT)
.Lfe1:

whereas one would expect:

foo:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, current_function_anonymous_args = 0
        str     lr, [sp, #-4]!
        bl      bar(PLT)
        xx
        ldr     pc, [sp], #4

p.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]