diff options
Diffstat (limited to 'qemu_mode/patches/elfload.diff')
-rw-r--r-- | qemu_mode/patches/elfload.diff | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/qemu_mode/patches/elfload.diff b/qemu_mode/patches/elfload.diff index 34ec4847..c8f6e80a 100644 --- a/qemu_mode/patches/elfload.diff +++ b/qemu_mode/patches/elfload.diff @@ -1,5 +1,7 @@ ---- qemu-2.10.0.orig/linux-user/elfload.c 2017-08-30 18:50:41.000000000 +0200 -+++ qemu-2.10.0/linux-user/elfload.c 2018-10-23 12:48:16.421879765 +0200 +diff --git a/linux-user/elfload.c b/linux-user/elfload.c +index 5bccd2e2..94e928a4 100644 +--- a/linux-user/elfload.c ++++ b/linux-user/elfload.c @@ -20,6 +20,8 @@ #define ELF_OSABI ELFOSABI_SYSV @@ -9,7 +11,7 @@ /* from personality.h */ /* -@@ -2085,6 +2087,8 @@ +@@ -2301,6 +2303,8 @@ static void load_elf_image(const char *image_name, int image_fd, info->brk = 0; info->elf_flags = ehdr->e_flags; @@ -18,7 +20,7 @@ for (i = 0; i < ehdr->e_phnum; i++) { struct elf_phdr *eppnt = phdr + i; if (eppnt->p_type == PT_LOAD) { -@@ -2118,9 +2122,11 @@ +@@ -2335,9 +2339,11 @@ static void load_elf_image(const char *image_name, int image_fd, if (elf_prot & PROT_EXEC) { if (vaddr < info->start_code) { info->start_code = vaddr; @@ -30,26 +32,3 @@ } } if (elf_prot & PROT_WRITE) { -@@ -2443,6 +2449,22 @@ - info, (elf_interpreter ? &interp_info : NULL)); - info->start_stack = bprm->p; - -+#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) -+ // On PowerPC64 the entry point is the _function descriptor_ -+ // of the entry function. For AFL to properly initialize, -+ // afl_entry_point needs to be set to the actual first instruction -+ // as opposed executed by the target program. This as opposed to -+ // where the function's descriptor sits in memory. -+ -+ // Shameless copy of PPC init_thread -+ info_report("Adjusting afl_entry_point"); -+ if (afl_entry_point && (get_ppc64_abi(info) < 2)) { -+ uint64_t val; -+ get_user_u64(val, afl_entry_point); -+ afl_entry_point = val + info->load_bias; -+ } -+#endif -+ - /* If we have an interpreter, set that as the program's entry point. - Copy the load_bias as well, to help PPC64 interpret the entry - point as a function descriptor. Do this after creating elf tables |