Skip to content

Commit 7232c2a

Browse files
committed
src: use getauxval in node_main.cc
This commit suggests using getauxval in node_main.cc. The motivation for this is that getauxval was introduced in glibc 2.16 and looking at BUILDING.md, in the 'Platform list' section, it looks like we now support glibc >= 2.17 and perhaps this change would be alright now. PR-URL: #33693 Refs: #12548 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 9027f5f commit 7232c2a

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

Diff for: src/node_main.cc

+2-16
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,7 @@ int wmain(int argc, wchar_t* wargv[]) {
8989
#else
9090
// UNIX
9191
#ifdef __linux__
92-
#include <elf.h>
93-
#ifdef __LP64__
94-
#define Elf_auxv_t Elf64_auxv_t
95-
#else
96-
#define Elf_auxv_t Elf32_auxv_t
97-
#endif // __LP64__
98-
extern char** environ;
92+
#include <sys/auxv.h>
9993
#endif // __linux__
10094
#if defined(__POSIX__) && defined(NODE_SHARED_MODE)
10195
#include <string.h>
@@ -124,15 +118,7 @@ int main(int argc, char* argv[]) {
124118
#endif
125119

126120
#if defined(__linux__)
127-
char** envp = environ;
128-
while (*envp++ != nullptr) {}
129-
Elf_auxv_t* auxv = reinterpret_cast<Elf_auxv_t*>(envp);
130-
for (; auxv->a_type != AT_NULL; auxv++) {
131-
if (auxv->a_type == AT_SECURE) {
132-
node::per_process::linux_at_secure = auxv->a_un.a_val;
133-
break;
134-
}
135-
}
121+
node::per_process::linux_at_secure = getauxval(AT_SECURE);
136122
#endif
137123
// Disable stdio buffering, it interacts poorly with printf()
138124
// calls elsewhere in the program (e.g., any logging from V8.)

0 commit comments

Comments
 (0)