Browse Source

Only accept statically linked binaries (#176)

pull/177/head
Luís Marques 7 years ago
committed by Andrew Waterman
parent
commit
099c99482f
  1. 3
      pk/elf.c
  2. 1
      pk/elf.h

3
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;

1
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

Loading…
Cancel
Save