From: Gabe Black Date: Wed, 18 Mar 2020 06:35:05 +0000 (-0700) Subject: mips: Add the AT_RANDOM aux vector to the initial stack. X-Git-Tag: v20.0.0.0~275 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0864696b734d2d39b867060d95b3fe95e3b72f1f;p=gem5.git mips: Add the AT_RANDOM aux vector to the initial stack. This is blindly used by at least modern glibc-s Change-Id: I8fb904d487d0cb5f7747d063a6ed84894ee6b905 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26828 Reviewed-by: Gabe Black Maintainer: Gabe Black Tested-by: kokoro --- diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc index c38808758..539c7a52b 100644 --- a/src/arch/mips/process.cc +++ b/src/arch/mips/process.cc @@ -115,6 +115,7 @@ MipsProcess::argsInit(int pageSize) auxv.emplace_back(M5_AT_EUID, euid()); auxv.emplace_back(M5_AT_GID, gid()); auxv.emplace_back(M5_AT_EGID, egid()); + auxv.emplace_back(M5_AT_RANDOM, 0); } // Calculate how much space we need for arg & env & auxv arrays. @@ -126,6 +127,10 @@ MipsProcess::argsInit(int pageSize) for (vector::size_type i = 0; i < argv.size(); ++i) { arg_data_size += argv[i].size() + 1; } + + const int numRandomBytes = 16; + int aux_data_size = numRandomBytes; + int env_data_size = 0; for (vector::size_type i = 0; i < envp.size(); ++i) { env_data_size += envp[i].size() + 1; @@ -136,6 +141,7 @@ MipsProcess::argsInit(int pageSize) envp_array_size + auxv_array_size + arg_data_size + + aux_data_size + env_data_size; // set bottom of stack @@ -152,7 +158,8 @@ MipsProcess::argsInit(int pageSize) IntType envp_array_base = argv_array_base + argv_array_size; IntType auxv_array_base = envp_array_base + envp_array_size; IntType arg_data_base = auxv_array_base + auxv_array_size; - IntType env_data_base = arg_data_base + arg_data_size; + IntType aux_data_base = arg_data_base - arg_data_size; + IntType env_data_base = aux_data_base + aux_data_size; // write contents to stack IntType argc = argv.size(); @@ -167,6 +174,12 @@ MipsProcess::argsInit(int pageSize) copyStringArray(envp, envp_array_base, env_data_base, LittleEndianByteOrder, *initVirtMem); + // Fix up the aux vectors which point to data. + for (auto &aux: auxv) { + if (aux.type == M5_AT_RANDOM) + aux.val = aux_data_base; + } + // Copy the aux vector Addr auxv_array_end = auxv_array_base; for (const auto &aux: auxv) {