Skip to content

Fix set PC restriction when RV32C is enabled #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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