int i;
static int j;
extern int bar (void);
int foo (void)
{
return i + j + bar ();
}
-m32 -O2 -fpic -mtune=generic -fexceptions generates:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
movl %esp, %ebp
.cfi_offset 5, -8
.cfi_def_cfa_register 5
subl $8, %esp
movl %ebx, (%esp)
call __i686.get_pc_thunk.bx
addl $_GLOBAL_OFFSET_TABLE_, %ebx
.cfi_offset 3, -16
...
__i686.get_pc_thunk.bx:
movl (%esp), %ebx
ret
.cfi_offset 3, -16 is in incorrect spot though, it must come before the call
__i686.get_pc_thunk.bx, because already in the thunk %ebx is clobbered and thus
it doesn't hold caller's value. Similarly with -mtune=i486 or -mtune=i586 or
-mtune=core2 instead, even when there is just call .L1; .L1: popl %ebx; addl
something, %ebx; then already the popl modifies the register and so if e.g. the
debugger stops after popl %ebx, but before addl, it will assume the caller has
different %ebx value from what it should have. For -mtune=i586
-fomit-frame-pointer there is another bug - the call pushes a word to stack,
but there is no corresponding cfa adjustment (and the pop restores it).
And, I guess __i686.get_pc_thunk.* should get unwind info too (I guess probably
just .cfi_startproc before and .cfi_endproc after it would be ok).
--
Summary: Invalid unwind info for i?86 -fpic
Product: gcc
Version: 4.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43293