https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Xi Ruoyao <[email protected]>:

https://gcc.gnu.org/g:7704f03d8a65874cedfb0b29a155213dcd822283

commit r15-11185-g7704f03d8a65874cedfb0b29a155213dcd822283
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_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)

Reply via email to