sea: split sea binary manipulation code · nodejs/node@957292e · GitHub
Skip to content

Commit 957292e

Browse files
joyeecheungaduh95
authored andcommitted
sea: split sea binary manipulation code
Split the sea binary manipulation code to a seperate file so that adding more low-level binary manipulation code doesn't clobber the higher-level code. PR-URL: #61167 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent fbe4da5 commit 957292e

4 files changed

Lines changed: 68 additions & 39 deletions

File tree

node.gyp

Lines changed: 1 addition & 0 deletions

src/node_sea.cc

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@
1414
#include "simdjson.h"
1515
#include "util-inl.h"
1616

17-
// The POSTJECT_SENTINEL_FUSE macro is a string of random characters selected by
18-
// the Node.js project that is present only once in the entire binary. It is
19-
// used by the postject_has_resource() function to efficiently detect if a
20-
// resource has been injected. See
21-
// https://github.com/nodejs/postject/blob/35343439cac8c488f2596d7c4c1dddfec1fddcae/postject-api.h#L42-L45.
22-
#define POSTJECT_SENTINEL_FUSE "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2"
23-
#include "postject-api.h"
24-
#undef POSTJECT_SENTINEL_FUSE
25-
2617
#include <memory>
2718
#include <string_view>
2819
#include <tuple>
@@ -233,33 +224,6 @@ SeaResource SeaDeserializer::Read() {
233224
exec_argv};
234225
}
235226

236-
std::string_view FindSingleExecutableBlob() {
237-
#if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
238-
CHECK(IsSingleExecutable());
239-
static const std::string_view result = []() -> std::string_view {
240-
size_t size;
241-
#ifdef __APPLE__
242-
postject_options options;
243-
postject_options_init(&options);
244-
options.macho_segment_name = "NODE_SEA";
245-
const char* blob = static_cast<const char*>(
246-
postject_find_resource("NODE_SEA_BLOB", &size, &options));
247-
#else
248-
const char* blob = static_cast<const char*>(
249-
postject_find_resource("NODE_SEA_BLOB", &size, nullptr));
250-
#endif
251-
return {blob, size};
252-
}();
253-
per_process::Debug(DebugCategory::SEA,
254-
"Found SEA blob %p, size=%zu\n",
255-
result.data(),
256-
result.size());
257-
return result;
258-
#else
259-
UNREACHABLE();
260-
#endif // !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
261-
}
262-
263227
} // anonymous namespace
264228

265229
bool SeaResource::use_snapshot() const {
@@ -283,9 +247,6 @@ SeaResource FindSingleExecutableResource() {
283247
return sea_resource;
284248
}
285249

286-
bool IsSingleExecutable() {
287-
return postject_has_resource();
288-
}
289250

290251
void IsSea(const FunctionCallbackInfo<Value>& args) {
291252
args.GetReturnValue().Set(IsSingleExecutable());

src/node_sea.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct SeaResource {
5454
};
5555

5656
bool IsSingleExecutable();
57+
std::string_view FindSingleExecutableBlob();
5758
SeaResource FindSingleExecutableResource();
5859
std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv);
5960
node::ExitCode BuildSingleExecutableBlob(

src/node_sea_bin.cc

Lines changed: 66 additions & 0 deletions

0 commit comments

Comments
 (0)