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

            Bug ID: 128179
           Summary: RISC-V Shadow stack support in restore_stack_nonlocal
                    appears broken
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: law at gcc dot gnu.org
  Target Milestone: ---

The shadow stack support in restore_stack looks broken.

First note cmp_4k_label:

      /* Adjust the ssp in a loop.  */
      rtx cmp_4k_label = gen_label_rtx ();
      emit_label (cmp_4k_label);
      LABEL_NUSES (cmp_4k_label) = 1;

But nothing ever references that label.

And this fragment:


      rtx cmp_ssp  = gen_reg_rtx (word_mode);
      cmp_ssp = expand_simple_binop (ptr_mode, MINUS,
                                     ssp_slot, cur_ssp,
                                     cmp_ssp, 1, OPTAB_DIRECT);

That looks like an uninitialized variable in the generated code.  We construct
a register for "cmp_ssp", then we use that register in the subtraction which is
effectively ssp_slot = cur_ssp - cmp_ssp.

Am I missing something here?

Reply via email to