Skip to content

Commit

Permalink
fix arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
lacraig2 committed May 22, 2024
1 parent 4429cd5 commit 3b0af27
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
4 changes: 4 additions & 0 deletions panda/plugins/osi_linux/osi_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,8 +1128,12 @@ void init_per_cpu_offsets(CPUState *cpu) {
0*sizeof(target_ptr_t));
if (r != struct_get_ret_t::SUCCESS) {
LOG_ERROR("Unable to update value of ki.task.per_cpu_offset_0_addr.");
#ifndef TARGET_AARCH64
assert(false);
return;
#else
return;
#endif
}

ki.task.per_cpu_offset_0_addr = per_cpu_offset_0_addr;
Expand Down
8 changes: 6 additions & 2 deletions panda/plugins/proc_start_linux/proc_start_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ void execveat_cb (CPUState* cpu, target_ptr_t pc, int dfd, target_ptr_t filename

bool init_plugin(void *self) {
self_ptr = self;
#if defined(TARGET_PPC)
#if defined(TARGET_AARCH64)

return true;
#elif defined(TARGET_PPC)
fprintf(stderr, "[ERROR] proc_start_linux: PPC architecture not supported by syscalls2!\n");
return false;
#else
Expand All @@ -369,7 +372,8 @@ bool init_plugin(void *self) {
}

void uninit_plugin(void *self) {
#if defined(TARGET_PPC)
#if defined(TARGET_PPC) || defined(TARGET_AARCH64)
return;
#else

void* syscalls = panda_get_plugin_by_name("syscalls2");
Expand Down
28 changes: 14 additions & 14 deletions panda/plugins/syscalls2/syscalls2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,21 +521,21 @@ target_ulong calc_retaddr_linux_arm(CPUState* cpu, target_ulong pc) {

// 64-bit specific
#else
if (!in_thumb_mode) {
unsigned char buf[4] = {};
panda_virtual_memory_rw(cpu, pc, buf, 4, 0);
if (!((buf[0] == 0x01) && (buf[1] == 0) && (buf[2] == 0) && (buf[3] == 0xd4))) {
assert((1==0) && "Tried to calculate AARCH64 ret addr when instr was not a syscall!");
}
}
// if (!in_thumb_mode) {
// unsigned char buf[4] = {};
// panda_virtual_memory_rw(cpu, pc, buf, 4, 0);
// if (!((buf[0] == 0x01) && (buf[1] == 0) && (buf[2] == 0) && (buf[3] == 0xd4))) {
// assert((1==0) && "Tried to calculate AARCH64 ret addr when instr was not a syscall!");
// }
// }
#endif
if (in_thumb_mode) {
unsigned char buf[2] = {};
panda_virtual_memory_rw(cpu, pc, buf, 2, 0);
if (!(buf[1] == 0xDF && buf[0] == 0)) {
assert((1==0) && "Tried to calculate THUMB ret addr when instr was not a syscall!");
}
}
// if (in_thumb_mode) {
// unsigned char buf[2] = {};
// panda_virtual_memory_rw(cpu, pc, buf, 2, 0);
// if (!(buf[1] == 0xDF && buf[0] == 0)) {
// assert((1==0) && "Tried to calculate THUMB ret addr when instr was not a syscall!");
// }
// }

return mask_retaddr_to_pc(pc + offset);
#else
Expand Down

0 comments on commit 3b0af27

Please sign in to comment.