Skip to content

Commit

Permalink
Fixes to loader and bootstrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
WorksButNotTested committed Jan 15, 2025
1 parent bb4a906 commit 38af3cb
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 17 deletions.
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

0 comments on commit 38af3cb

Please sign in to comment.