target_ulong calc_retaddr_linux_arm(CPUState* env, target_ulong pc) { #if defined(TARGET_ARM) // Normal syscalls: return addr is stored in LR // Except that we haven't run the SWI instruction yet! LR is where libc will return to! //return mask_retaddr_to_pc(env->regs[14]); // Fork, exec uint8_t offset = 0; if(env->thumb == 0){ offset = 4; } else { offset = 2; } return mask_retaddr_to_pc(pc + offset); #else // shouldnt happen assert (1==0); #endif }
static target_ulong calc_retaddr(CPUState* env, target_ulong pc){ #if defined(TARGET_ARM) // Normal syscalls: return addr is stored in LR // Except that we haven't run the SWI instruction yet! LR is where libc will return to! //return mask_retaddr_to_pc(env->regs[14]); // Fork, exec uint8_t offset = 0; if(env->thumb == 0){ offset = 4; } else { offset = 2; } return mask_retaddr_to_pc(pc + offset); #elif defined(TARGET_I386) // syscall and sysenter x86 instructions are both 2 bytes // on linux this is true. different for different systems. return pc+11; /*// ABI from http://wiki.osdev.org/SYSENTER // Return address is set by user code before the syscall/sysenter instr is executed unsigned char buf[2]; panda_virtual_memory_rw(env, pc, buf, 2, 0); // Check if the instruction is syscall (0F 05) if (buf[0]== 0x0F && buf[1] == 0x05) { return ECX; } // Check if the instruction is sysenter (0F 34) else if (buf[0]== 0x0F && buf[1] == 0x34) { return EDX; } else { // Not a syscall or sysenter!? assert(0); }*/ #else #error "return address calculation not implemented for this architecture in fdtracker" #endif }
static void vmi_do_mmap2_callback(CPUState *env, target_ulong pc, uint32_t addr,uint32_t len,uint32_t prot,uint32_t flags,uint32_t fd,uint32_t pgoff) { mmap_returns.push_back(ReturnPoint(mask_retaddr_to_pc(env->regs[14]), get_asid(env, pc))); }
static void vmi_sys_prctl_callback(CPUState *env, target_ulong pc, uint32_t option,uint32_t arg2,uint32_t arg3,uint32_t arg4,uint32_t arg5) { prctl_returns.push_back(ReturnPoint(mask_retaddr_to_pc(env->regs[14]), get_asid(env, pc))); }
static void vmi_clone_callback(CPUState* env,target_ulong pc,uint32_t clone_flags,uint32_t newsp, target_ulong parent_tidptr,int32_t tls_val, target_ulong child_tidptr,target_ulong regs) { clone_returns.push_back(ReturnPoint(mask_retaddr_to_pc(env->regs[14]), get_asid(env, pc))); }