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

            Bug ID: 96892
           Summary: wrong __stack_chk_guard for comparison
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dongjianqiang2 at huawei dot com
  Target Milestone: ---

Simpile testcase:

#include<stdio.h>
int main ()
{
  int i;
  char buf[20];
  for (i = 0; i < 20; i++)
  {
    buf[i] = 'a';
    printf("%c ,%d", buf[i], i);
  }
  return 0;
}

Compile with following command:
arm-linux-gnueabi-gcc -static -fno-PIE -no-pie main.c -fstack-protector-all -g3

gdb ./a.out

   0x000105f8 <+124>:   mov     r3, #0
   0x000105fc <+128>:   movw    r2, #11800      ; 0x2e18
   0x00010600 <+132>:   movt    r2, #6
   0x00010604 <+136>:   ldr     r1, [r2]
   0x00010608 <+140>:   ldr     r2, [r11, #-8]
=> 0x0001060c <+144>:   eors    r1, r2, r1
   0x00010610 <+148>:   beq     0x10618 <main+156>
   0x00010614 <+152>:   bl      0x3257c <__stack_chk_fail>
   0x00010618 <+156>:   mov     r0, r3
   0x0001061c <+160>:   sub     sp, r11, #4
   0x00010620 <+164>:   pop     {r11, pc}
End of assembler dump.
(gdb) p __stack_chk_guard
$8 = 3363780352      // this is canary value
(gdb) p /x $r1
$9 = 0x8ab20   // Comparing the address of __stack_chk_guard ???
(gdb) p /x $r2
$10 = 0x8ab20
(gdb) p &__stack_chk_guard   // address of __stack_chk_guard
$11 = (uintptr_t *) 0x8ab20 <__stack_chk_guard>

Confirmed as a 7.5 regression. The most likely change of those comparison is
pr85434.

Reply via email to