https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116174
Bug ID: 116174
Summary: Alignment request is added before endbr with
-fcf-protection=branch
Product: gcc
Version: 14.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: gcc at breakpoint dot cc
Target Milestone: ---
The file lib_str.c:
char *stpcpy(char *dest, const char *src)
{
while ((*dest++ = *src++) != '\0')
/* nothing */;
return --dest;
}
gcc -nostdinc -fno-common -fno-PIE \
-fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1
-falign-loops=1 \
-fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern \
-mfunction-return=thunk-extern -O2 \
-S -o lib_str.s lib_str.c
-
Output:
.text
.p2align 4
.globl stpcpy
.type stpcpy, @function
stpcpy:
.p2align 5
endbr64
.L2:
movzbl (%rsi), %eax
…
--
The problem is that this .p2align macro before endbr64 results in 16 nops (11
byte nop + 5 byte nop) before endbr on function entry.
I see this with
- gcc version 14.1.0 (Debian 14.1.0-5)
- gcc version 15.0.0 20240717 (experimental) [master r15-2089-gecc2c3cb723]
(Debian 20240717-1)
I don't see this with gcc-13.
Sebastian