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

            Bug ID: 84150
           Summary: Wrong pointer size used in builtin setjmp/longjmp with
                    -maddress-mode=long
           Product: gcc
           Version: 6.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: igor.v.tsimbalist at intel dot com, ubizjak at gmail dot com
  Target Milestone: ---
            Target: x32

[hjl@gnu-6 gcc]$ cat /tmp/foo.c
void *buf[5];

void raise0(void)
{
  __builtin_longjmp (buf, 1);
}

void execute(int cmd)
{
  __builtin_setjmp (buf);
}
[hjl@gnu-6 gcc]$ gcc -S -O3 -mx32 /tmp/foo.c
[hjl@gnu-6 gcc]$ cat foo.s
        .file   "foo.c"
        .text
        .p2align 4,,15
        .globl  raise0
        .type   raise0, @function
raise0:
.LFB0:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movl    buf+4(%rip), %eax
        movl    %esp, %ebp
        .cfi_def_cfa_register 6
        movl    buf(%rip), %ebp
        movl    buf+8(%rip), %esp
        jmp     *%rax
        .cfi_endproc
.LFE0:
        .size   raise0, .-raise0
        .p2align 4,,15
        .globl  execute
        .type   execute, @function
execute:
.LFB1:
        .cfi_startproc
        movl    %esp, buf(%rip)
        movl    $.L5, buf+4(%rip)
        movl    %esp, buf+8(%rip)
        ret
.L5:
        .cfi_endproc
.LFE1:
        .size   execute, .-execute
        .comm   buf,20,16
[hjl@gnu-6 gcc]$ gcc -S -O3 -mx32 /tmp/foo.c  -maddress-mode=long
[hjl@gnu-6 gcc]$ cat foo.s
        .file   "foo.c"
        .text
        .p2align 4,,15
        .globl  raise0
        .type   raise0, @function
raise0:
.LFB0:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    buf+8(%rip), %rax
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        movq    buf(%rip), %rbp
        movq    buf+16(%rip), %rsp
        jmp     *%rax
        .cfi_endproc
.LFE0:
        .size   raise0, .-raise0
        .p2align 4,,15
        .globl  execute
        .type   execute, @function
execute:
.LFB1:
        .cfi_startproc
        movq    %rsp, buf(%rip) <<<<<<<<<<< Pointer size should be 4 bytes.
        movq    $.L5, buf+8(%rip)
        movq    %rsp, buf+16(%rip)
        ret
.L5:
        .cfi_endproc
.LFE1:
        .size   execute, .-execute
        .comm   buf,20,16

Reply via email to