Skip to content

Commit b17fc23

Browse files
committed
syscalls2: aarch64 fixes
1 parent a103cd5 commit b17fc23

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

panda/plugins/syscalls2/syscalls2.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -514,28 +514,28 @@ target_ulong calc_retaddr_linux_arm(CPUState* cpu, target_ulong pc) {
514514
offset = 4; // Note: this is NOT 8 for AARCH64!
515515
}
516516

517-
// 32-bit specific
518-
#if !defined(TARGET_AARCH64)
517+
#if defined(TARGET_AARCH64)
518+
//64-bit specific
519+
// if (!in_thumb_mode) {
520+
// unsigned char buf[4] = {};
521+
// panda_virtual_memory_rw(cpu, pc, buf, 4, 0);
522+
// if (!((buf[0] == 0x01) && (buf[1] == 0) && (buf[2] == 0) && (buf[3] == 0xd4))) {
523+
// assert((1==0) && "Tried to calculate AARCH64 ret addr when instr was not a syscall!");
524+
// }
525+
// }
526+
#else
527+
// 32-bit specific
519528
// TODO: check syscall encoding here?
520529
// If so, check both EABI and OABI!
521530

522-
// 64-bit specific
523-
#else
524-
if (!in_thumb_mode) {
525-
unsigned char buf[4] = {};
526-
panda_virtual_memory_rw(cpu, pc, buf, 4, 0);
527-
if (!((buf[0] == 0x01) && (buf[1] == 0) && (buf[2] == 0) && (buf[3] == 0xd4))) {
528-
assert((1==0) && "Tried to calculate AARCH64 ret addr when instr was not a syscall!");
529-
}
530-
}
531-
#endif
532531
if (in_thumb_mode) {
533532
unsigned char buf[2] = {};
534533
panda_virtual_memory_rw(cpu, pc, buf, 2, 0);
535534
if (!(buf[1] == 0xDF && buf[0] == 0)) {
536535
assert((1==0) && "Tried to calculate THUMB ret addr when instr was not a syscall!");
537536
}
538537
}
538+
#endif
539539

540540
return mask_retaddr_to_pc(pc + offset);
541541
#else
@@ -1074,7 +1074,7 @@ target_ulong doesBlockContainSyscall(CPUState *cpu, TranslationBlock *tb, int* s
10741074
return pc;
10751075
}
10761076

1077-
#else
1077+
#endif
10781078
// ARM32
10791079
// Check for ARM mode syscall
10801080
CPUArchState *env = (CPUArchState*)cpu->env_ptr;
@@ -1105,7 +1105,6 @@ target_ulong doesBlockContainSyscall(CPUState *cpu, TranslationBlock *tb, int* s
11051105
return pc;
11061106
}
11071107
}
1108-
#endif
11091108
// Arm32/aarch64 - not a match
11101109
return 0;
11111110
#elif defined(TARGET_MIPS)

0 commit comments

Comments
 (0)