[Bug target/125049] [loongarch] SSP fallback leaves __stack_chk_guard live in $r12 at `jr $r1`
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 3 16:50:06 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:
https://gcc.gnu.org/g:572318619e354711c97a5216d262d22e1d604657
commit r14-12637-g572318619e354711c97a5216d262d22e1d604657
Author: Xi Ruoyao <xry111@xry111.site>
Date: Tue Apr 28 20:32:38 2026 +0800
LoongArch: harden SSP canary set and test routines [PR 125049]
Add the stack_protect_combined_{set,test} expanders to expand the
routines as unsplitable insns which does not leave any sensitive data
(the canary value, the canary address, and all the intermediate values
used materializing the address) in a register. This prevents the
attacker from defeating SSP by probing the canary value from the
register context or overwriting the address spilled onto the stack.
PR target/125049
gcc/
* config/loongarch/predicates.md (ssp_operand): New
define_predicate.
(ssp_normal_operand): New define_predicate.
* config/loongarch/constraints.md (ZE): New define_constraint.
(ZF): New define_constraint.
* config/loongarch/loongarch.md (UNSPEC_SSP): New unspec.
(cbranch4): Add "@" to create gen_cbranch4(machine_mode, ...).
(@stack_protect_combined_set_normal_<mode>): New define_insn.
(@stack_protect_combined_set_extreme_<mode>): New define_insn.
(@stack_protect_combined_test_internal_<mode>): New define_insn.
(stack_protect_combined_set): New define_expand.
(stack_protect_combined_test): New define_expand.
* config/loongarch/loongarch-protos.h
(loongarch_output_asm_load_canary): Declare.
* config/loongarch/loongarch.cc (loongarch_print_operand): Allow
'v' to print d/w for DImode/SImode.
(loongarch_output_asm_load_canary): Implement.
gcc/testsuite/
* gcc.target/loongarch/pr125049.c: New test.
(cherry picked from commit 62fdbd084f7ab04cb7a97d6186ffe70acfc70f1b)
More information about the Gcc-bugs
mailing list