Skip to content

Commit

Permalink
Add information gathered through getauxval()
Browse files Browse the repository at this point in the history
Suggested by Wladimir van der Laan.
  • Loading branch information
sipa authored and xanimo committed May 7, 2024
1 parent 8405e3d commit b170da9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/randomenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
#include <sys/vmmeter.h>
#endif
#endif
#ifdef __linux__
#include <sys/auxv.h>
#endif

//! Necessary on some platforms
extern char** environ;
Expand Down Expand Up @@ -329,6 +332,28 @@ void RandAddStaticEnv(CSHA512& hasher)
// Bitcoin client version
hasher << CLIENT_VERSION;

#ifdef __linux__
// Information available through getauxval()
# ifdef AT_HWCAP
hasher << getauxval(AT_HWCAP);
# endif
# ifdef AT_HWCAP2
hasher << getauxval(AT_HWCAP2);
# endif
# ifdef AT_RANDOM
const unsigned char* random_aux = (const unsigned char*)getauxval(AT_RANDOM);
if (random_aux) hasher.Write(random_aux, 16);
# endif
# ifdef AT_PLATFORM
const char* platform_str = (const char*)getauxval(AT_PLATFORM);
if (platform_str) hasher.Write((const unsigned char*)platform_str, strlen(platform_str) + 1);
# endif
# ifdef AT_EXECFN
const char* exec_str = (const char*)getauxval(AT_EXECFN);
if (exec_str) hasher.Write((const unsigned char*)exec_str, strlen(exec_str) + 1);
# endif
#endif // __linux__

#ifdef HAVE_GETCPUID
AddAllCPUID(hasher);
#endif
Expand Down

0 comments on commit b170da9

Please sign in to comment.