[oi-dev] gcc 4.7 issue

Alexander Pyhalov alp at rsu.ru
Sat Aug 3 17:27:00 UTC 2013


Hello, all.

I was trying to compile mariadb and got the following error...
$ /usr/gcc/4.7/bin/gcc   
-I/export/home/build/srcs/oi-userland/components/mariadb-55/build/i86/include 
-I/export/home/build/srcs/oi-userland/components/mariadb-55/mariadb-5.5.32/include 
-I/export/home/build/srcs/oi-userland/components/mariadb-55/mariadb-5.5.32/mysys 
-o my_context.c.o -c 
/export/home/build/srcs/oi-userland/components/mariadb-55/mariadb-5.5.32/mysys/my_context.c
/var/tmp//ccrTGWnh.s: Assembler messages:
/var/tmp//ccrTGWnh.s:35: Error: CFI instruction used without previous 
.cfi_startproc

If I use gcc 3.4 I don't receive this error message, so it' seems to be 
gcc 4.7 issue.
The generated assembler code in gcc 4.7 is the following:

.file   "my_context.c"
.text
.globl  my_context_spawn
.type   my_context_spawn, @function
my_context_spawn:
pushl   %ebp
movl    %esp, %ebp
pushl   %edi
pushl   %esi
pushl   %ebx
subl    $60, %esp
movl    12(%ebp), %eax
movl    %eax, -28(%ebp)
movl    16(%ebp), %eax
movl    %eax, -32(%ebp)
movl    8(%ebp), %eax
addl    $64, %eax
movl    %eax, (%esp)
call    dbug_swap_code_state
movl    8(%ebp), %eax
movl    56(%eax), %eax
movl    %eax, -44(%ebp)
movl    8(%ebp), %edi
movl    -28(%ebp), %ecx
movl    -32(%ebp), %edx
movl    %ecx, %esi
movl    %edx, %ebx
movl    %esi, %ecx
movl    %ebx, %edx
movl    -44(%ebp), %eax
/APP
/ 455 
"/export/home/build/srcs/oi-userland/components/mariadb-55/mariadb-5.5.32/mysys/my_context.c" 
1
movl %esp, (%edi)
movl %eax, %esp
.cfi_escape 0x07, 8
pushl %edx
movl %ebp, 4(%edi)
movl %ebx, 8(%edi)
movl %esi, 12(%edi)
movl %edi, 16(%edi)
call 1f
...

.cfi_* instructions don't appear in gcc 3.4 output. For me these ASM 
listings are meaningless, but I suppose that there should be 
.cfi_startproc and .cfi_endproc somewhere. This piece of code seems to 
come from
int my_context_spawn(struct my_context *c, void (*f)(void *), void *d) 
as an asm section...

/*
There are 4 callee-save registers we need to save and restore when
suspending and continuing, plus stack pointer %esp and instruction 
pointer
%eip.

However, if we never suspend, the user-supplied function will in any 
case
restore the 4 callee-save registers, so we can avoid restoring them in
this case.
*/
__asm__ __volatile__
(
"movl %%esp, (%[save])\n\t"
"movl %[stack], %%esp\n\t"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 && !defined(__INTEL_COMPILER)
/*
This emits a DWARF DW_CFA_undefined directive to make the return address
undefined. This indicates that this is the top of the stack frame, and
helps tools that use DWARF stack unwinding to obtain stack traces.
(I use numeric constant to avoid a dependency on libdwarf includes).
*/
".cfi_escape 0x07, 8\n\t"
#endif


Found similar issue 
https://lists.launchpad.net/maria-developers/msg04818.html , it was 
related to corrupted gcc 4.7 stack...

Haven't investigated further yet. Perhaps, someone has useful ideas...
-- 
System Administrator of Southern Federal University Computer Center




More information about the oi-dev mailing list