public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/94736] New: Missing ENDBR at label
@ 2020-04-23 18:55 hjl.tools at gmail dot com
2020-04-26 3:23 ` [Bug target/94736] " crazylht at gmail dot com
0 siblings, 1 reply; 2+ messages in thread
From: hjl.tools at gmail dot com @ 2020-04-23 18:55 UTC (permalink / raw)
To: gcc-bugs
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]$
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug target/94736] Missing ENDBR at label
2020-04-23 18:55 [Bug target/94736] New: Missing ENDBR at label hjl.tools at gmail dot com
@ 2020-04-26 3:23 ` crazylht at gmail dot com
0 siblings, 0 replies; 2+ messages in thread
From: crazylht at gmail dot com @ 2020-04-26 3:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94736
--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
Indirect jump `goto *p` is optimized off, so there's no indirect jump, either
no need for inserting endbr64
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-26 3:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 18:55 [Bug target/94736] New: Missing ENDBR at label hjl.tools at gmail dot com
2020-04-26 3:23 ` [Bug target/94736] " crazylht at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).