Skip to content

Commit f8d4bf8

Browse files
nodejs-github-botdanielleadams
authored andcommitted
deps,test: update postject to 1.0.0-alpha.5
PR-URL: #46934 Fixes: nodejs/postject#76 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent b8cdd15 commit f8d4bf8

File tree

8 files changed

+56
-23
lines changed

8 files changed

+56
-23
lines changed

β€Ždeps/postject/postject-api.h

+16-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#elif defined(__linux__)
1313
#include <elf.h>
1414
#include <link.h>
15-
#include <sys/auxv.h>
1615
#include <sys/param.h>
1716
#elif defined(_WIN32)
1817
#include <windows.h>
@@ -44,6 +43,16 @@ static inline bool postject_has_resource() {
4443
return sentinel[sizeof(POSTJECT_SENTINEL_FUSE)] == '1';
4544
}
4645

46+
#if defined(__linux__)
47+
static int postject__dl_iterate_phdr_callback(struct dl_phdr_info* info,
48+
size_t size,
49+
void* data) {
50+
// Snag the dl_phdr_info struct for the main program, then stop iterating
51+
*((struct dl_phdr_info*)data) = *info;
52+
return 1;
53+
}
54+
#endif
55+
4756
static const void* postject_find_resource(
4857
const char* name,
4958
size_t* size,
@@ -114,9 +123,12 @@ static const void* postject_find_resource(
114123
name = options->elf_section_name;
115124
}
116125

117-
uintptr_t p = getauxval(AT_PHDR);
118-
size_t n = getauxval(AT_PHNUM);
119-
uintptr_t base_addr = p - sizeof(ElfW(Ehdr));
126+
struct dl_phdr_info main_program_info;
127+
dl_iterate_phdr(postject__dl_iterate_phdr_callback, &main_program_info);
128+
129+
uintptr_t p = (uintptr_t)main_program_info.dlpi_phdr;
130+
size_t n = main_program_info.dlpi_phnum;
131+
uintptr_t base_addr = main_program_info.dlpi_addr;
120132

121133
// iterate program header
122134
for (; n > 0; n--, p += sizeof(ElfW(Phdr))) {

β€Žtest/fixtures/postject-copy/node_modules/.package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtest/fixtures/postject-copy/node_modules/postject/dist/api.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtest/fixtures/postject-copy/node_modules/postject/dist/cli.js

+12-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtest/fixtures/postject-copy/node_modules/postject/dist/postject-api.h

+16-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtest/fixtures/postject-copy/node_modules/postject/package.json

+3-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtest/fixtures/postject-copy/package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žtest/fixtures/postject-copy/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"author": "",
1111
"license": "ISC",
1212
"dependencies": {
13-
"postject": "^1.0.0-alpha.4"
13+
"postject": "^1.0.0-alpha.5"
1414
}
1515
}

0 commit comments

Comments
Β (0)