Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Armbe8 patches #1130

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/linux/frida-helper-backend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1988,8 +1988,8 @@ namespace Frida {
#elif ARM
target_address &= ~1;

uint32 arm_breakpoint_val = 0xe7f001f0U;
uint16 thumb_breakpoint_val = 0xde01;
uint32 arm_breakpoint_val = (0xe7f001f0U).to_little_endian ();
uint16 thumb_breakpoint_val = ((uint16) 0xde01).to_little_endian ();
bool is_thumb = (target & 1) != 0;
if (is_thumb)
breakpoint_data = (uint8[]) &thumb_breakpoint_val;
Expand Down
Binary file added src/linux/helpers/bootstrapper-armbe8.bin
Binary file not shown.
Binary file modified src/linux/helpers/loader-arm.bin
Binary file not shown.
Binary file modified src/linux/helpers/loader-arm64.bin
Binary file not shown.
Binary file added src/linux/helpers/loader-armbe8.bin
Binary file not shown.
Binary file modified src/linux/helpers/loader-mips.bin
Binary file not shown.
Binary file modified src/linux/helpers/loader-mips64.bin
Binary file not shown.
Binary file modified src/linux/helpers/loader-mips64el.bin
Binary file not shown.
Binary file modified src/linux/helpers/loader-mipsel.bin
Binary file not shown.
Binary file modified src/linux/helpers/loader-x86.bin
Binary file not shown.
Binary file modified src/linux/helpers/loader-x86_64.bin
Binary file not shown.
40 changes: 24 additions & 16 deletions src/linux/helpers/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,20 @@ frida_receive_chunk (int sockfd, void * buffer, size_t length, const FridaLibcAp
.iov_base = cursor,
.iov_len = remaining
};
struct msghdr msg = {
.msg_name = NULL,
.msg_namelen = 0,
.msg_iov = &io,
.msg_iovlen = 1,
.msg_control = NULL,
.msg_controllen = 0,
};
struct msghdr msg;
ssize_t n;

/*
* Avoid inline initialization to prevent the compiler attempting to insert
* a call to memset.
*/
msg.msg_name = NULL,
msg.msg_namelen = 0,
msg.msg_iov = &io,
msg.msg_iovlen = 1,
msg.msg_control = NULL,
msg.msg_controllen = 0,

n = libc->recvmsg (sockfd, &msg, 0);
if (n <= 0)
return false;
Expand All @@ -334,14 +338,18 @@ frida_receive_fd (int sockfd, const FridaLibcApi * libc)
.iov_len = sizeof (dummy)
};
FridaControlMessage control;
struct msghdr msg = {
.msg_name = NULL,
.msg_namelen = 0,
.msg_iov = &io,
.msg_iovlen = 1,
.msg_control = &control,
.msg_controllen = sizeof (control),
};
struct msghdr msg;

/*
* Avoid inline initialization to prevent the compiler attempting to insert
* a call to memset.
*/
msg.msg_name = NULL,
msg.msg_namelen = 0,
msg.msg_iov = &io,
msg.msg_iovlen = 1,
msg.msg_control = &control,
msg.msg_controllen = sizeof (control),

res = libc->recvmsg (sockfd, &msg, 0);
if (res == -1 || res == 0 || msg.msg_controllen == 0)
Expand Down
10 changes: 9 additions & 1 deletion src/linux/helpers/nolibc-tweaks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
index 1747ae125..5f30e6e0c 100644
--- a/tools/include/nolibc/std.h
+++ b/tools/include/nolibc/std.h
@@ -25,25 +25,53 @@ typedef unsigned short uint16_t;
@@ -25,25 +25,61 @@ typedef unsigned short uint16_t;
typedef signed short int16_t;
typedef unsigned int uint32_t;
typedef signed int int32_t;
Expand All @@ -211,6 +211,14 @@ index 1747ae125..5f30e6e0c 100644
typedef unsigned long uintptr_t;
typedef signed long intptr_t;
typedef signed long ptrdiff_t;
+#elif defined(__arm__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+typedef unsigned long long uint64_t;
+typedef signed long long int64_t;
+typedef unsigned int size_t;
+typedef signed int ssize_t;
+typedef unsigned long uintptr_t;
+typedef signed int intptr_t;
+typedef signed int ptrdiff_t;
+#else
+typedef unsigned long long uint64_t;
+typedef signed long long int64_t;
Expand Down
3 changes: 3 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ if have_local_backend
else
host_lowlevel_abi = host_abi
endif
if host_lowlevel_abi == 'arm' and host_machine.endian() == 'big'
host_lowlevel_abi = 'armbe8'
endif
fs = import('fs')
helper_backend_data = custom_target('frida-data-helper-backend',
input: [
Expand Down
Loading