https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128960
Bug ID: 128960
Summary: using __attribute__((target("bmi2"))) drops effects of
-mstack-protector-guard=global
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
Target Milestone: ---
Target: x86_64-*-*
void sink(char *p);
__attribute__((target("bmi2")))
void with_bmi2(void) {
char buf[16];
sink(buf);
}
void without_bmi2(void) {
char buf[16];
sink(buf);
}
built with -O2 -fstack-protector-strong -mstack-protector-guard=global shows
with_bmi2:
.LFB0:
.cfi_startproc
subq $40, %rsp
.cfi_def_cfa_offset 48
movq %fs:40, %rax
movq %rax, 24(%rsp)
xorl %eax, %eax
movq %rsp, %rdi
call sink
movq 24(%rsp), %rax
subq %fs:40, %rax
jne .L5
addq $40, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.L5:
.cfi_restore_state
call __stack_chk_fail
.cfi_endproc
vs.
without_bmi2:
.LFB1:
.cfi_startproc
subq $40, %rsp
.cfi_def_cfa_offset 48
movq __stack_chk_guard(%rip), %rax
movq %rax, 24(%rsp)
xorl %eax, %eax
movq %rsp, %rdi
call sink
movq 24(%rsp), %rax
subq __stack_chk_guard(%rip), %rax
jne .L10
addq $40, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 8
ret
.L10:
.cfi_restore_state
call __stack_chk_fail