[Bug target/83641] New: -fstack-clash-protection generates incorrect CFI on i386

fw at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Dec 31 21:34:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83641

            Bug ID: 83641
           Summary: -fstack-clash-protection generates incorrect CFI on
                    i386
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fw at gcc dot gnu.org
  Target Milestone: ---
            Target: i386

Created attachment 42995
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42995&action=edit
unwind.i

The attached unwind.i file, when compiled with -O2 -fstack-clash-protection
-m32 -fPIC, produces incorrect CFI information:

__GI___pthread_unwind:
.LFB55:
        .cfi_startproc
        pushl   %esi
        .cfi_def_cfa_offset 8
        .cfi_offset 6, -8
        pushl   %ebx
        .cfi_def_cfa_offset 12
        .cfi_offset 3, -12
        pushl   %esi
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        popl    %esi
        .cfi_restore 6
        .cfi_def_cfa_offset 12
        xorl    %edx, %edx
        call    __x86.get_pc_thunk.bx
        addl    $_GLOBAL_OFFSET_TABLE_, %ebx
#APP
# 114 "unwind.c" 1
        movl %gs:8,%ecx
# 0 "" 2
#NO_APP
        subl    $8, %esp
        .cfi_def_cfa_offset 20
        movl    %eax, %esi

The “.cfi_restore 6” directive claims that %esi has the same value as in the
caller in the following code, but “movl %eax, %esi” clobbers it.

I believe this is the reason why the libgcc unwinder cannot restore %esi to its
original value when pthread_exit is called and glibc has been compiled with a
GCC that has this bug.


More information about the Gcc-bugs mailing list