https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Xi Ruoyao <[email protected]>: https://gcc.gnu.org/g:4d7d4d282de299ab3f09134b880f9595f60db30a commit r13-10356-g4d7d4d282de299ab3f09134b880f9595f60db30a Author: Xi Ruoyao <[email protected]> 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_symbol_extreme_p): Declare. (loongarch_output_asm_load_canary): Declare. * config/loongarch/loongarch.cc (loongarch_print_operand): Allow 'v' to print d/w for DImode/SImode. (loongarch_symbol_extreme_p): Remove static. (loongarch_output_asm_load_canary): Implement. gcc/testsuite/ * gcc.target/loongarch/pr125049.c: New test. (cherry picked from commit 62fdbd084f7ab04cb7a97d6186ffe70acfc70f1b)
