#!/usr/bin/env python3 # Set p_paddr = p_vaddr in every program header so qemu -kernel loads # the ELF at its link address. riscv vmlinux.lds sets LMA=VMA-LOAD_OFFSET # for the Image target; we want qemu to honour VMA instead. import sys, struct with open(sys.argv[1], 'r+b') as f: f.seek(0x20); phoff, = struct.unpack('