https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67215
--- Comment #4 from Andrew Senkevich <andrew.n.senkevich at gmail dot com> ---
-bash-4.2$ cat test.c
extern char* mem(int);
char* arr[32];
void proc(void)
{
int i;
for (i=0;i<32;i++)
arr[i] = mem(128);
}
gcc -pie -fpie -fno-plt -O2 -S test.c -o test_32.S -m32
gcc -pie -fpie -fno-plt -O2 -S test.c -o test_64.S
-bash-4.2$ cat test_32.S
. . .
proc:
.LFB0:
.cfi_startproc
call __x86.get_pc_thunk.ax
addl $_GLOBAL_OFFSET_TABLE_, %eax
pushl %edi
.cfi_def_cfa_offset 8
.cfi_offset 7, -8
pushl %esi
.cfi_def_cfa_offset 12
.cfi_offset 6, -12
pushl %ebx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movl arr@GOT(%eax), %ebx
movl mem@GOT(%eax), %esi
leal 128(%ebx), %edi
.p2align 4,,10
.p2align 3
.L2:
subl $12, %esp
.cfi_def_cfa_offset 28
addl $4, %ebx
pushl $128
.cfi_def_cfa_offset 32
call *%esi
movl %eax, -4(%ebx)
addl $16, %esp
.cfi_def_cfa_offset 16
cmpl %edi, %ebx
jne .L2
popl %ebx
.cfi_restore 3
.cfi_def_cfa_offset 12
popl %esi
.cfi_restore 6
.cfi_def_cfa_offset 8
popl %edi
.cfi_restore 7
.cfi_def_cfa_offset 4
ret
.cfi_endproc
.LFE0:
.size proc, .-proc
. . .
-bash-4.2$ cat test_64.S
. . .
proc:
.LFB0:
.cfi_startproc
pushq %r12
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
pushq %rbp
.cfi_def_cfa_offset 24
.cfi_offset 6, -24
pushq %rbx
.cfi_def_cfa_offset 32
.cfi_offset 3, -32
movq arr@GOTPCREL(%rip), %rbx
movq mem@GOTPCREL(%rip), %rbp
leaq 256(%rbx), %r12
.p2align 4,,10
.p2align 3
.L2:
movl $128, %edi
addq $8, %rbx
call *%rbp
movq %rax, -8(%rbx)
cmpq %r12, %rbx
jne .L2
popq %rbx
.cfi_def_cfa_offset 24
popq %rbp
.cfi_def_cfa_offset 16
popq %r12
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE0:
.size proc, .-proc
. . .