title: Whisper simulator for RISC-V: C++ Program either gets caught in infinite loop or get aborted
body: <p>I have a <strong>multi-file</strong> (3 .cpp files and 2 .h files) C++ code that uses <strong>new</strong>, <strong>new[]</strong>, <strong>delete</strong>, and <strong>delete[]</strong> operators to allocate large chunks of memory and performs some floating point operations (requires division by sqrt()). The program compiles and runs well with regular g++ and produces the required output. I now want to convert it to RISC-V instructions.</p>
  <ol>
  <li><p>I first used the GNU RISC-V compiler toolchain to compile the program with following command:</p>
  <p><code>riscv32-unknown-elf-g++ -w -march=rv32imafc -mabi=ilp32f -DPREALLOCATE=1 -mcmodel=medany -fno-common -static -Iinclude/ f1.cpp f2.cpp f3.cpp -o executable</code></p>
  <p>here <em>executable</em> is the compiled binary file.</p>
  </li>
  <li><p>Since no errors are thrown at compile time, I proceeded to run the whisper simulator as follows:</p>
  <p><code>whisper --isa imafc --target executable --logfile mylog --profileinst prfl</code></p>
  <p>where <em>mylog</em> and <em>prfl</em> are output file paths.</p>
  </li>
  <li><p>The log file generated exceeds 6 GB in size and it doesn't terminate, so I assume that it is stuck in some infinite loop.</p>
  </li>
  <li><p>I tried adding the <strong>_start()</strong> function and <strong>tohost variable</strong> which didn't work either (same problem as 3 above). [based on suggestion <a href="https://github.com/westerndigitalcorporation/swerv-ISS" rel="nofollow noreferrer">here]
  </a></p>
  </li>
  <li><p>I generated an object dump for <em>executable</em> and captured the (hex) addresses of <em>starting address</em> of <strong>main()</strong>, its <em>ending address</em> and <em>address of tohost</em> and passed them as parameters to <code>--startpc</code>, <code>--endpc</code> and <code>--tohost</code> respectively, in which case, the program was aborted after 64 illegal operations and ~300 MB of log file.</p>
  </li>
  </ol>
  <p>I think I am making some mistake. Kindly help me fix this issue or share the correct steps to generate the RISC-V assembly instructions for my C++ program.</p>