[Bug target/94736] New: Missing ENDBR at label
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Apr 23 18:55:05 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94736
Bug ID: 94736
Summary: Missing ENDBR at label
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
CC: crazylht at gmail dot com
Target Milestone: ---
Target: i386,x86-64
[hjl@gnu-cfl-2 gcc]$ cat /tmp/foo.c
#include <stdlib.h>
typedef void *(*func_t) (void);
void *p;
void
__attribute__ ((noclone, noinline))
foo (int a)
{
switch (a)
{
case 0:
a0:
return;
case 1:
a1:
p = &&a1;
case 2:
a2:
p = &&a2;
case 3:
a3:
p = &&a3;
case 4:
a4:
p = &&a4;
case 5:
a5:
p = &&a5;
case 6:
a6:
p = &&a6;
case 7:
a7:
p = &&a7;
case 8:
a8:
p = &&a8;
case 9:
a9:
p = &&a9;
case 10:
a10:
p = &&a10;
default:
p = &&a0;
}
goto *p;
}
int
main ()
{
foo (20);
if (p == NULL)
abort ();
((func_t) p) ();
return 0;
}
[hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S -O2 -fcf-protection /tmp/foo.c
[hjl@gnu-cfl-2 gcc]$ cat foo.s
.file "foo.c"
.text
.p2align 4
.globl foo
.type foo, @function
foo:
.LFB11:
.cfi_startproc
endbr64
testl %edi, %edi
je .L1
.L3:
endbr64
.L4:
.L5:
.L6:
.L7:
.L8:
.L9:
.L10:
.L11:
.L12:
movq $.L2, p(%rip)
.L2:
.L1: <<<<<<<< Missing ENDBR
ret
.cfi_endproc
.LFE11:
.size foo, .-foo
.section .text.unlikely,"ax",@progbits
.LCOLDB0:
.section .text.startup,"ax",@progbits
.LHOTB0:
.p2align 4
.globl main
.type main, @function
main:
.LFB12:
.cfi_startproc
endbr64
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $20, %edi
call foo
movq p(%rip), %rax
testq %rax, %rax
je .L19
call *%rax
xorl %eax, %eax
addq $8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.section .text.unlikely
.cfi_startproc
.type main.cold, @function
main.cold:
.LFSB12:
.L19:
.cfi_def_cfa_offset 16
call abort
.cfi_endproc
.LFE12:
.section .text.startup
.size main, .-main
.section .text.unlikely
.size main.cold, .-main.cold
.LCOLDE0:
.section .text.startup
.LHOTE0:
.globl p
.bss
.align 8
.type p, @object
.size p, 8
p:
.zero 8
.ident "GCC: (GNU) 10.0.1 20200422 (experimental)"
.section .note.GNU-stack,"",@progbits
.section .note.gnu.property,"a"
.align 8
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 8
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 8
4:
[hjl@gnu-cfl-2 gcc]$
More information about the Gcc-bugs
mailing list