Skip to content

Commit

Permalink
Merge pull request #44 from RinHizakura/master
Browse files Browse the repository at this point in the history
Fix set PC restriction when RV32C is enabled
  • Loading branch information
jserv authored Aug 22, 2022
2 parents b612aad + 4dd4298 commit 45c19bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ bool elf_get_data_section_range(elf_t *e, uint32_t *start, uint32_t *end)

bool elf_load(elf_t *e, struct riscv_t *rv, memory_t *mem)
{
rv_set_pc(rv, e->hdr->e_entry); /* set the entry point */
/* set the entry point */
if (!rv_set_pc(rv, e->hdr->e_entry))
return false;

/* loop over all of the program headers */
for (int p = 0; p < e->hdr->e_phnum; ++p) {
Expand Down
4 changes: 4 additions & 0 deletions emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,11 @@ riscv_user_t rv_userdata(struct riscv_t *rv)
bool rv_set_pc(struct riscv_t *rv, riscv_word_t pc)
{
assert(rv);
#ifdef ENABLE_RV32C
if (pc & 1)
#else
if (pc & 3)
#endif
return false;

rv->PC = pc;
Expand Down

0 comments on commit 45c19bb

Please sign in to comment.