title: How to delete stack point when using "riscv32/64-unknown-elf-gcc"?
body: <p>I designed RISCV32IM processor, and i used &quot;riscv32/64-unknown-elf-gcc&quot; to generate code for test.</p>
  <p>It is an OS-less system, and the stack pointer is unnecessary in the instruction code.
  However, when compiling as follows, stack point operation is created, and the initial SP value is ZERO, so it malfunctions during instruction code execution.</p>
  <pre><code>riscv64-unknown-elf-gcc -march=rv32im -mabi=ilp32 -nostartfiles -fno-toplevel-reorder -fno-omit-frame-pointer -funwind-tables -O0 -x c  -Ttext 40000000 -Tdata 70000100 -Tbss 70000200 -o main.o main.c
  </code></pre>
  <p>The C code is as follows.</p>
  <pre><code>void    irq1 (void);
  void    irq2 (void);
  void    irq3 (void);
  void    irq4 (void);
  void    irq5 (void);
  void    irq6 (void);
  void    _start(void);
  
  void _start (void)
  {
      int     irq;
  
      IRQ0      = 0;
      DMEM_ROM4 = 0;
      while (1) {
              irq = (int) IRQ0;
  
              switch (irq) {
                      case 1  : irq1(); break;
                      case 2  : irq2(); break;
                      case 3  : irq3(); break;
                      case 4  : irq4(); break;
                      case 5  : irq5(); break;
                      case 6  : irq6(); break;
                      default : irq1();
              }
      }
  }
  </code></pre>
  <p>The instruction code generated by compiling is as follows.
  In operation &quot;4000005c&quot;, it jumps out of the instruction memory area and malfunctions.</p>
  <p>I want to delete the SP behavior, how can I do that?
  Or is there a way to work normally even with SP?</p>
  <pre><code>40000000 &lt;_start&gt;:
  40000000:       fe010113                addi    sp,sp,-32
  40000004:       00112e23                sw      ra,28(sp)
  40000008:       00812c23                sw      s0,24(sp)
  4000000c:       02010413                addi    s0,sp,32
  40000010:       700007b7                lui     a5,0x70000
  40000014:       02078793                addi    a5,a5,32 # 70000020 &lt;irq6+0x2ffff854&gt;
  40000018:       0007a023                sw      zero,0(a5)
  4000001c:       700007b7                lui     a5,0x70000
  40000020:       01078793                addi    a5,a5,16 # 70000010 &lt;irq6+0x2ffff844&gt;
  40000024:       0007a023                sw      zero,0(a5)
  40000028:       700007b7                lui     a5,0x70000
  4000002c:       02078793                addi    a5,a5,32 # 70000020 &lt;irq6+0x2ffff854&gt;
  40000030:       0007a783                lw      a5,0(a5)
  40000034:       fef42623                sw      a5,-20(s0)
  40000038:       fec42703                lw      a4,-20(s0)
  4000003c:       00600793                li      a5,6
  40000040:       04e7e863                bltu    a5,a4,40000090 &lt;_start+0x90&gt;
  40000044:       fec42783                lw      a5,-20(s0)
  40000048:       00279713                slli    a4,a5,0x2
  4000004c:       400017b7                lui     a5,0x40001
  40000050:       b6078793                addi    a5,a5,-1184 # 40000b60 &lt;irq6+0x394&gt;
  40000054:       00f707b3                add     a5,a4,a5
  40000058:       0007a783                lw      a5,0(a5)
  4000005c:       00078067                jr      a5
  40000060:       038000ef                jal     ra,40000098 &lt;irq1&gt;
  40000064:       0300006f                j       40000094 &lt;_start+0x94&gt;
  40000068:       180000ef                jal     ra,400001e8 &lt;irq2&gt;
  4000006c:       0280006f                j       40000094 &lt;_start+0x94&gt;
  </code></pre>