aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-08-09 16:55:36 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-08-09 16:55:36 -0700
commit7520a474199df8b9ef7cee32eebcea7577813814 (patch)
tree7ad7d3f2bad15327d223117c633c05651c5e10dd /pk
parent55982bd0192a41d76b13ba92b3c1f3ef80f7e029 (diff)
downloadpk-7520a474199df8b9ef7cee32eebcea7577813814.zip
pk-7520a474199df8b9ef7cee32eebcea7577813814.tar.gz
pk-7520a474199df8b9ef7cee32eebcea7577813814.tar.bz2
Disallow execution of RVC binaries on non-RVC pk
Diffstat (limited to 'pk')
-rw-r--r--pk/elf.c4
-rw-r--r--pk/elf.h2
2 files changed, 6 insertions, 0 deletions
diff --git a/pk/elf.c b/pk/elf.c
index 2740319..ba2dd1d 100644
--- a/pk/elf.c
+++ b/pk/elf.c
@@ -29,6 +29,10 @@ void load_elf(const char* fn, elf_info* info)
assert(IS_ELF32(eh));
#endif
+#ifndef __riscv_compressed
+ assert(!(eh.e_flags & EF_RISCV_RVC));
+#endif
+
uintptr_t min_vaddr = -1;
size_t phdr_size = eh.e_phnum * sizeof(Elf_Phdr);
if (phdr_size > info->phdr_size)
diff --git a/pk/elf.h b/pk/elf.h
index df876e9..c3fa1c3 100644
--- a/pk/elf.h
+++ b/pk/elf.h
@@ -23,6 +23,8 @@
#define ET_EXEC 2
#define ET_DYN 3
+#define EF_RISCV_RVC 1
+
#define PT_LOAD 1
#define AT_NULL 0