https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125077
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Xi Ruoyao <[email protected]>: https://gcc.gnu.org/g:a1fc8045881850df83c5143ea6d9311ce3a0c540 commit r17-1834-ga1fc8045881850df83c5143ea6d9311ce3a0c540 Author: Xi Ruoyao <[email protected]> Date: Sun May 24 21:24:37 2026 +0800 MIPS: harden SSP set and test routines [PR 125077] 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/125077 gcc/ * config/mips/predicates.md (ssp_gp_operand): New define_predicate. (ssp_operand): New define_predicate. (ssp_normal_operand): New define_predicate. * config/mips/constraints.md (ZA): New define_constraint. (ZB): New define_constraint. * config/mips/mips.md (UNSPEC_SSP): New unspec. (UNSPEC_SSP_GP): New unspec. (cbranch<mode>4): Add '@' to generate the helper function taking mode as a parameter. (@stack_protect_combined_set_normal_<mode>): New define_insn. (stack_protect_combined_set_abs64): 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/mips/mips-protos.h (mips_canary_expose_gp_use): Declare. (mips_output_asm_load_canary): Declare. * config/mips/mips.cc (mips_small_data_pattern_1): Don't rewrite GP-relative symbol wrapped in UNSPEC_SSP_GP. (mips_canary_expose_gp_use): Implement. (mips_output_asm_load_canary): Implement. (mips_print_operand): Allow 'w' to print d/w for DImode/SImode.
