aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorLuís Marques <luismarques@lowrisc.org>2019-10-01 12:13:28 +0100
committerAndrew Waterman <andrew@sifive.com>2019-10-01 13:13:28 +0200
commit099c99482f7ac032bf04caad13a9ca1da7ce58ed (patch)
tree2e9efe7aa5ea35bf411fc4df16b41f7a34738404 /pk
parenta3e4ac61d2b1ff37a22b9193b85d3b94273e80cb (diff)
downloadriscv-pk-099c99482f7ac032bf04caad13a9ca1da7ce58ed.zip
riscv-pk-099c99482f7ac032bf04caad13a9ca1da7ce58ed.tar.gz
riscv-pk-099c99482f7ac032bf04caad13a9ca1da7ce58ed.tar.bz2
Only accept statically linked binaries (#176)
Diffstat (limited to 'pk')
-rw-r--r--pk/elf.c3
-rw-r--r--pk/elf.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/pk/elf.c b/pk/elf.c
index 43810ec..3a47e7e 100644
--- a/pk/elf.c
+++ b/pk/elf.c
@@ -71,6 +71,9 @@ void load_elf(const char* fn, elf_info* info)
info->entry = eh.e_entry + bias;
int flags = MAP_FIXED | MAP_PRIVATE;
for (int i = eh.e_phnum - 1; i >= 0; i--) {
+ if(ph[i].p_type == PT_INTERP) {
+ panic("not a statically linked ELF program");
+ }
if(ph[i].p_type == PT_LOAD && ph[i].p_memsz) {
uintptr_t prepad = ph[i].p_vaddr % RISCV_PGSIZE;
uintptr_t vaddr = ph[i].p_vaddr + bias;
diff --git a/pk/elf.h b/pk/elf.h
index 99b2aee..3d1fae1 100644
--- a/pk/elf.h
+++ b/pk/elf.h
@@ -26,6 +26,7 @@
#define EF_RISCV_RVC 1
#define PT_LOAD 1
+#define PT_INTERP 3
#define AT_NULL 0
#define AT_PHDR 3