forked from ceclin/build-javet-node-android
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnode.patches
186 lines (178 loc) · 8.06 KB
/
node.patches
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
--- node-ref/android_configure.py 2022-12-01 13:20:44.838121296 +0000
+++ node/android_configure.py 2022-12-02 06:07:32.607692996 +0000
@@ -1,6 +1,7 @@
import platform
import sys
import os
+import shutil
# TODO: In next version, it will be a JSON file listing all the patches, and then it will iterate through to apply them.
def patch_android():
@@ -66,12 +67,16 @@
os.environ['CC'] = toolchain_path + "/bin/" + TOOLCHAIN_PREFIX + android_sdk_version + "-" + "clang"
os.environ['CXX'] = toolchain_path + "/bin/" + TOOLCHAIN_PREFIX + android_sdk_version + "-" + "clang++"
+os.environ['CC_host'] = shutil.which("gcc")
+os.environ['CXX_host'] = shutil.which("g++")
+
GYP_DEFINES = "target_arch=" + arch
-GYP_DEFINES += " v8_target_arch=" + arch
+GYP_DEFINES += " v8_target_arch=" + DEST_CPU
GYP_DEFINES += " android_target_arch=" + arch
GYP_DEFINES += " host_os=" + host_os + " OS=android"
GYP_DEFINES += " android_ndk_path=" + android_ndk_path
os.environ['GYP_DEFINES'] = GYP_DEFINES
if os.path.exists("./configure"):
- os.system("./configure --dest-cpu=" + DEST_CPU + " --dest-os=android --openssl-no-asm --cross-compiling")
+ extra_arguments = " --enable-static --with-intl=none"
+ os.system("./configure --dest-cpu=" + DEST_CPU + " --dest-os=android --openssl-no-asm --cross-compiling" + extra_arguments)
--- node-ref/common.gypi 2022-12-01 13:20:44.768120497 +0000
+++ node/common.gypi 2022-12-01 13:21:15.529851498 +0000
@@ -404,7 +404,7 @@
'ldflags': [ '-rdynamic' ],
'target_conditions': [
# The 1990s toolchain on SmartOS can't handle thin archives.
- ['_type=="static_library" and OS=="solaris"', {
+ ['_type=="static_library" and OS in "solaris android"', {
'standalone_static_library': 1,
}],
['OS=="openbsd"', {
--- node-ref/configure.py 2022-12-01 13:20:45.448128256 +0000
+++ node/configure.py 2022-12-01 13:21:15.529851498 +0000
@@ -1289,9 +1289,9 @@
o['variables']['want_separate_host_toolset'] = int(cross_compiling)
# Enable branch protection for arm64
- if target_arch == 'arm64':
- o['cflags']+=['-msign-return-address=all']
- o['variables']['arm_fpu'] = options.arm_fpu or 'neon'
+ # if target_arch == 'arm64':
+ # o['cflags']+=['-msign-return-address=all']
+ # o['variables']['arm_fpu'] = options.arm_fpu or 'neon'
if options.node_snapshot_main is not None:
if options.shared:
--- node-ref/deps/v8/src/codegen/arm/constants-arm.h 2022-12-01 13:20:43.258103267 +0000
+++ node/deps/v8/src/codegen/arm/constants-arm.h 2022-12-01 19:20:21.813175203 +0000
@@ -178,8 +178,14 @@
constexpr int U = 1 << 23; // Positive (or negative) offset/index.
constexpr int P =
1 << 24; // Offset/pre-indexed addressing (or post-indexed addressing).
constexpr int I = 1 << 25; // Immediate shifter operand (or not).
+#ifdef B0
+#undef B0
+// ensure safe undef
+#define B0 ~!@#$%^&*()_+{}|:"<>?`-=[]\;',./
+#else
constexpr int B0 = 1 << 0;
+#endif
constexpr int B4 = 1 << 4;
constexpr int B5 = 1 << 5;
constexpr int B6 = 1 << 6;
--- node-ref/deps/v8/src/heap/base/asm/x64/push_registers_asm.cc 2022-12-01 13:20:43.238103039 +0000
+++ node/deps/v8/src/heap/base/asm/x64/push_registers_asm.cc 2022-12-01 15:42:14.156089798 +0000
@@ -16,12 +16,15 @@
// GN toolchain (e.g. ChromeOS) and not provide them.
// _WIN64 Defined as 1 when the compilation target is 64-bit ARM or x64.
// Otherwise, undefined.
+
+#if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_X64)
#ifdef _WIN64
// We maintain 16-byte alignment at calls. There is an 8-byte return address
// on the stack and we push 232 bytes which maintains 16-byte stack alignment
// at the call.
// Source: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention
+
asm(".globl PushAllRegistersAndIterateStack \n"
"PushAllRegistersAndIterateStack: \n"
// rbp is callee-saved. Maintain proper frame pointer for debugging.
@@ -104,3 +107,39 @@
" ret \n");
#endif // !_WIN64
+#else
+asm(
+#ifdef _WIN32
+ ".globl _PushAllRegistersAndIterateStack \n"
+ "_PushAllRegistersAndIterateStack: \n"
+#else // !_WIN32
+ ".globl PushAllRegistersAndIterateStack \n"
+ ".type PushAllRegistersAndIterateStack, %function \n"
+ ".hidden PushAllRegistersAndIterateStack \n"
+ "PushAllRegistersAndIterateStack: \n"
+#endif // !_WIN32
+ // [ IterateStackCallback ]
+ // [ StackVisitor* ]
+ // [ Stack* ]
+ // [ ret ]
+ // ebp is callee-saved. Maintain proper frame pointer for debugging.
+ " push %ebp \n"
+ " movl %esp, %ebp \n"
+ " push %ebx \n"
+ " push %esi \n"
+ " push %edi \n"
+ // Save 3rd parameter (IterateStackCallback).
+ " movl 28(%esp), %ecx \n"
+ // Pass 3rd parameter as esp (stack pointer).
+ " push %esp \n"
+ // Pass 2nd parameter (StackVisitor*).
+ " push 28(%esp) \n"
+ // Pass 1st parameter (Stack*).
+ " push 28(%esp) \n"
+ " call *%ecx \n"
+ // Pop the callee-saved registers.
+ " addl $24, %esp \n"
+ // Restore rbp as it was used as frame pointer.
+ " pop %ebp \n"
+ " ret \n");
+#endif
--- node-ref/test/cctest/test_crypto_clienthello.cc 2022-12-01 13:20:44.988123007 +0000
+++ node/test/cctest/test_crypto_clienthello.cc 2022-12-01 13:21:15.529851498 +0000
@@ -18,6 +18,7 @@
#ifdef __linux__
#include <sys/mman.h>
#include <unistd.h>
+#include <malloc.h>
#if defined(_SC_PAGE_SIZE) && defined(PROT_NONE) && defined(PROT_READ) && \
defined(PROT_WRITE)
#define USE_MPROTECT
@@ -54,8 +55,8 @@
#ifdef USE_MPROTECT
// Place the packet right before a guard page, which, when accessed, causes
// a segmentation fault.
- alloc_base = static_cast<uint8_t*>(aligned_alloc(page, 2 * page));
- CHECK_NOT_NULL(alloc_base);
+ alloc_base = static_cast<uint8_t*>(memalign(page, 2 * page));
+ EXPECT_NE(alloc_base, nullptr);
uint8_t* second_page = alloc_base + page;
- CHECK_EQ(mprotect(second_page, page, PROT_NONE), 0);
+ EXPECT_EQ(mprotect(second_page, page, PROT_NONE), 0);
data_base = second_page - N;
--- node-ref/android-patches/trap-handler.h.patch 2021-10-08 19:08:46.000000000 +0530
+++ node/android-patches/trap-handler.h.patch 2021-10-09 19:43:08.715641214 +0530
@@ -1,5 +1,5 @@
--- trap-handler.h 2022-08-11 09:01:23.384000000 +0800
+++ fixed-trap-handler.h 2022-08-11 09:09:15.352000000 +0800
-@@ -17,23 +17,7 @@
+@@ -17,29 +17,7 @@ namespace v8 {
namespace internal {
namespace trap_handler {
@@ -13,8 +15,14 @@
-#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_ARM64 && V8_OS_DARWIN
-#define V8_TRAP_HANDLER_SUPPORTED true
-// Arm64 simulator on x64 on Linux, Mac, or Windows.
+-//
+-// The simulator case uses some inline assembly code, which cannot be
+-// compiled with MSVC, so don't enable the trap handler in that case.
+-// (MSVC #defines _MSC_VER, but so does Clang when targeting Windows, hence
+-// the check for __clang__.)
-#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && \
-- (V8_OS_LINUX || V8_OS_DARWIN)
+- (V8_OS_LINUX || V8_OS_DARWIN || V8_OS_WIN) && \
+- (!defined(_MSC_VER) || defined(__clang__))
-#define V8_TRAP_HANDLER_VIA_SIMULATOR
-#define V8_TRAP_HANDLER_SUPPORTED true
-// Everything else is unsupported.
@@ -22,5 +30,5 @@
#define V8_TRAP_HANDLER_SUPPORTED false
-#endif
- // Setup for shared library export.
- #if defined(BUILDING_V8_SHARED) && defined(V8_OS_WIN)
\ No newline at end of file
+ #if V8_OS_ANDROID && V8_TRAP_HANDLER_SUPPORTED
+ // It would require some careful security review before the trap handler