diff options
| author | Aymeric Vincent <aymeric.vincent@cea.fr> | 2018-02-16 15:50:40 +0100 |
|---|---|---|
| committer | Aymeric Vincent <aymeric.vincent@cea.fr> | 2018-02-16 15:50:40 +0100 |
| commit | bc593098f878168ab974f4ae5e23f14edffcb775 (patch) | |
| tree | dd825f615d0043c98b5bc505c2d71eca07634813 | |
| parent | e933c0c31742ddb9dcfd9b46d93fe2a47553af5e (diff) | |
| download | miasm-bc593098f878168ab974f4ae5e23f14edffcb775.tar.gz miasm-bc593098f878168ab974f4ae5e23f14edffcb775.zip | |
Enforce correct endianness of PLT entries
If given by the ELF file, use its endianness to set the PLT entries accordingly.
| -rw-r--r-- | miasm2/jitter/loader/elf.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/miasm2/jitter/loader/elf.py b/miasm2/jitter/loader/elf.py index db0f1cb7..336f522a 100644 --- a/miasm2/jitter/loader/elf.py +++ b/miasm2/jitter/loader/elf.py @@ -42,8 +42,13 @@ def preload_elf(vm, e, runtime_lib, patch_vm_imp=True): dyn_funcs[libname_s] = ad_libfunc if patch_vm_imp: log.debug('patch 0x%x 0x%x %s', ad, ad_libfunc, libfunc) - vm.set_mem( - ad, struct.pack(cstruct.size2type[e.size], ad_libfunc)) + set_endianness = { elf_csts.ELFDATA2MSB: ">", + elf_csts.ELFDATA2LSB: "<", + elf_csts.ELFDATANONE: "" }[e.sex] + vm.set_mem(ad, + struct.pack(set_endianness + + cstruct.size2type[e.size], + ad_libfunc)) return runtime_lib, dyn_funcs |