From: Gabe Black Date: Wed, 18 Mar 2020 04:13:04 +0000 (-0700) Subject: sparc: Add the AT_RANDOM aux vector to the initial stack. X-Git-Tag: v20.0.0.0~295 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9877dc66ab7a5956effcecfb53ef81781b478580;p=gem5.git sparc: Add the AT_RANDOM aux vector to the initial stack. This is blindly used by at least modern glibc-s Change-Id: I175ce5f1495e367badf0fab32f5837e3cdfa955a Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26824 Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com> Reviewed-by: Bobby R. Bruce Maintainer: Gabe Black --- diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc index 816df4f47..c55e9cbbc 100644 --- a/src/arch/sparc/process.cc +++ b/src/arch/sparc/process.cc @@ -251,6 +251,8 @@ SparcProcess::argsInit(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); } // Figure out how big the initial stack needs to be @@ -262,6 +264,9 @@ SparcProcess::argsInit(int pageSize) // It's purpose is to let the user space linker examine the original file. int file_name_size = filename.size() + 1; + const int numRandomBytes = 16; + int aux_data_size = numRandomBytes; + int env_data_size = 0; for (int i = 0; i < envp.size(); ++i) { env_data_size += envp[i].size() + 1; @@ -303,6 +308,7 @@ SparcProcess::argsInit(int pageSize) int space_needed = info_block_size + + aux_data_size + aux_padding + frame_size; @@ -319,8 +325,8 @@ SparcProcess::argsInit(int pageSize) IntType file_name_base = sentry_base - file_name_size; IntType env_data_base = file_name_base - env_data_size; IntType arg_data_base = env_data_base - arg_data_size; - IntType auxv_array_base = arg_data_base - - info_block_padding - aux_array_size - aux_padding; + IntType aux_data_base = arg_data_base - info_block_padding - aux_data_size; + IntType auxv_array_base = aux_data_base - aux_array_size - aux_padding; IntType envp_array_base = auxv_array_base - envp_array_size; IntType argv_array_base = envp_array_base - argv_array_size; IntType argc_base = argv_array_base - argc_size; @@ -356,6 +362,12 @@ SparcProcess::argsInit(int pageSize) // Write the file name initVirtMem->writeString(file_name_base, filename.c_str()); + // 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 stuff Addr auxv_array_end = auxv_array_base; for (const auto &aux: auxv) {