Skip to content

Commit 45c19bb

Browse files
authored
Merge pull request #44 from RinHizakura/master
Fix set PC restriction when RV32C is enabled
2 parents b612aad + 4dd4298 commit 45c19bb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

elf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ bool elf_get_data_section_range(elf_t *e, uint32_t *start, uint32_t *end)
300300

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

305307
/* loop over all of the program headers */
306308
for (int p = 0; p < e->hdr->e_phnum; ++p) {

emulate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,11 @@ riscv_user_t rv_userdata(struct riscv_t *rv)
18511851
bool rv_set_pc(struct riscv_t *rv, riscv_word_t pc)
18521852
{
18531853
assert(rv);
1854+
#ifdef ENABLE_RV32C
1855+
if (pc & 1)
1856+
#else
18541857
if (pc & 3)
1858+
#endif
18551859
return false;
18561860

18571861
rv->PC = pc;

0 commit comments

Comments
 (0)