From 63b2d16ea3985b62be372ea1da7987dc32ddcc3b Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 2 Jun 2020 05:33:25 +0200 Subject: [PATCH 3/3] 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: https://github.com/nodejs/node/pull/33693 Refs: https://github.com/nodejs/node/pull/12548 Reviewed-By: Ben Noordhuis Reviewed-By: David Carlier Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/node_main.cc | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/node_main.cc b/src/node_main.cc index e92c0df94297e2ece43dbdf71166e555713ef6f2..70be5b83fafcde596e65086b08305aa89702fd52 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -72,17 +72,11 @@ int wmain(int argc, wchar_t* wargv[]) { return node::Start(argc, argv); } #else // UNIX #ifdef __linux__ -#include -#ifdef __LP64__ -#define Elf_auxv_t Elf64_auxv_t -#else -#define Elf_auxv_t Elf32_auxv_t -#endif // __LP64__ -extern char** environ; +#include #endif // __linux__ #if defined(__POSIX__) && defined(NODE_SHARED_MODE) #include #include #endif @@ -107,19 +101,11 @@ int main(int argc, char* argv[]) { sigaction(SIGPIPE, &act, nullptr); } #endif #if defined(__linux__) - char** envp = environ; - while (*envp++ != nullptr) {} - Elf_auxv_t* auxv = reinterpret_cast(envp); - for (; auxv->a_type != AT_NULL; auxv++) { - if (auxv->a_type == AT_SECURE) { - node::per_process::linux_at_secure = auxv->a_un.a_val; - break; - } - } + node::per_process::linux_at_secure = getauxval(AT_SECURE); #endif // Disable stdio buffering, it interacts poorly with printf() // calls elsewhere in the program (e.g., any logging from V8.) setvbuf(stdout, nullptr, _IONBF, 0); setvbuf(stderr, nullptr, _IONBF, 0); -- 2.30.1