power: Add the AT_RANDOM aux vector to the initial stack.
authorGabe Black <gabeblack@google.com>
Wed, 18 Mar 2020 06:57:18 +0000 (23:57 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 24 Mar 2020 23:36:30 +0000 (23:36 +0000)
This is blindly used by at least modern glibc-s

Change-Id: I8ee7872c8072ee8aa1b3718e988679968ac172d0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26829
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/power/process.cc

index 6ebdd6f2ffd3944eab7625b0d3a21a56efac2ddd..9bb3b19a19f68a3c808e6f8e971376e78adfdee9 100644 (file)
@@ -131,6 +131,8 @@ PowerProcess::argsInit(int intSize, int pageSize)
         auxv.emplace_back(M5_AT_EGID, egid());
         //Whether to enable "secure mode" in the executable
         auxv.emplace_back(M5_AT_SECURE, 0);
+        //The address of 16 "random" bytes
+        auxv.emplace_back(M5_AT_RANDOM, 0);
         //The filename of the program
         auxv.emplace_back(M5_AT_EXECFN, 0);
         //The string "v51" with unknown meaning
@@ -151,6 +153,9 @@ PowerProcess::argsInit(int intSize, int pageSize)
     // string.
     int aux_data_size = filename.size() + 1;
 
+    const int numRandomBytes = 16;
+    aux_data_size += numRandomBytes;
+
     int env_data_size = 0;
     for (int i = 0; i < envp.size(); ++i) {
         env_data_size += envp[i].size() + 1;
@@ -235,8 +240,10 @@ PowerProcess::argsInit(int intSize, int pageSize)
             auxv[i].val = platform_base;
             initVirtMem->writeString(platform_base, platform.c_str());
         } else if (auxv[i].type == M5_AT_EXECFN) {
-            auxv[i].val = aux_data_base;
+            auxv[i].val = aux_data_base + numRandomBytes;
             initVirtMem->writeString(aux_data_base, filename.c_str());
+        } else if (auxv[i].type == M5_AT_RANDOM) {
+            auxv[i].val = aux_data_base;
         }
     }