Skip to content

Commit

Permalink
src: use getauxval in node_main.cc
Browse files Browse the repository at this point in the history
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 <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
danbev committed Jun 5, 2020
1 parent 9027f5f commit 7232c2a
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,7 @@ int wmain(int argc, wchar_t* wargv[]) {
#else
// UNIX
#ifdef __linux__
#include <elf.h>
#ifdef __LP64__
#define Elf_auxv_t Elf64_auxv_t
#else
#define Elf_auxv_t Elf32_auxv_t
#endif // __LP64__
extern char** environ;
#include <sys/auxv.h>
#endif // __linux__
#if defined(__POSIX__) && defined(NODE_SHARED_MODE)
#include <string.h>
Expand Down Expand Up @@ -124,15 +118,7 @@ int main(int argc, char* argv[]) {
#endif

#if defined(__linux__)
char** envp = environ;
while (*envp++ != nullptr) {}
Elf_auxv_t* auxv = reinterpret_cast<Elf_auxv_t*>(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.)
Expand Down

1 comment on commit 7232c2a

@s-fedosov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now i have to revert this and all other shit related to sys/auxv.h because there is such thing in centos-6.

Please sign in to comment.