summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-10-29 15:59:35 -0700
committerGabe Black <gabeblack@google.com>2019-10-30 22:29:23 +0000
commitc98fc78926213b3c0d0daa5acc11b4126e2e4912 (patch)
tree02299166d5e35bf57a8390f3ae4ac90d3e22c0f7
parent4444e88e5b4af1f49b501f13bd13133c6422374e (diff)
downloadgem5-c98fc78926213b3c0d0daa5acc11b4126e2e4912.tar.xz
arch,sim: Make copyStringArray take an explicit endianness.
Change-Id: I5cf4291b19dd2d2bdbbf145ad8e00994fabf5547 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22366 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Brandon Potter <Brandon.Potter@amd.com> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
-rw-r--r--src/arch/alpha/process.cc6
-rw-r--r--src/arch/arm/process.cc6
-rw-r--r--src/arch/mips/process.cc6
-rw-r--r--src/arch/power/process.cc6
-rw-r--r--src/arch/sparc/process.cc6
-rw-r--r--src/arch/x86/process.cc6
-rw-r--r--src/sim/process_impl.hh4
7 files changed, 26 insertions, 14 deletions
diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc
index 9311a6415..11fa187b1 100644
--- a/src/arch/alpha/process.cc
+++ b/src/arch/alpha/process.cc
@@ -156,8 +156,10 @@ AlphaProcess::argsInit(int intSize, int pageSize)
initVirtMem.writeBlob(memState->getStackMin(), &argc, intSize);
- copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
- copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
+ copyStringArray(argv, argv_array_base, arg_data_base,
+ LittleEndianByteOrder, initVirtMem);
+ copyStringArray(envp, envp_array_base, env_data_base,
+ LittleEndianByteOrder, initVirtMem);
//Copy the aux stuff
Addr auxv_array_end = auxv_array_base;
diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc
index d9b714c44..cacbe3ad5 100644
--- a/src/arch/arm/process.cc
+++ b/src/arch/arm/process.cc
@@ -434,8 +434,10 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex)
initVirtMem.write(auxv_array_end, zero);
auxv_array_end += sizeof(zero);
- copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
- copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+ copyStringArray(envp, envp_array_base, env_data_base,
+ LittleEndianByteOrder, initVirtMem);
+ copyStringArray(argv, argv_array_base, arg_data_base,
+ LittleEndianByteOrder, initVirtMem);
initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc
index 8e1e22b66..f5aae732c 100644
--- a/src/arch/mips/process.cc
+++ b/src/arch/mips/process.cc
@@ -165,9 +165,11 @@ MipsProcess::argsInit(int pageSize)
initVirtMem.writeBlob(memState->getStackMin(), &argc, intSize);
- copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+ copyStringArray(argv, argv_array_base, arg_data_base,
+ LittleEndianByteOrder, initVirtMem);
- copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
+ copyStringArray(envp, envp_array_base, env_data_base,
+ LittleEndianByteOrder, initVirtMem);
// Copy the aux vector
Addr auxv_array_end = auxv_array_base;
diff --git a/src/arch/power/process.cc b/src/arch/power/process.cc
index 7b53d7038..30685f0ba 100644
--- a/src/arch/power/process.cc
+++ b/src/arch/power/process.cc
@@ -254,8 +254,10 @@ PowerProcess::argsInit(int intSize, int pageSize)
initVirtMem.write(auxv_array_end, zero);
auxv_array_end += sizeof(zero);
- copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
- copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+ copyStringArray(envp, envp_array_base, env_data_base,
+ BigEndianByteOrder, initVirtMem);
+ copyStringArray(argv, argv_array_base, arg_data_base,
+ BigEndianByteOrder, initVirtMem);
initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc
index 048c7e957..33ae68975 100644
--- a/src/arch/sparc/process.cc
+++ b/src/arch/sparc/process.cc
@@ -375,8 +375,10 @@ SparcProcess::argsInit(int pageSize)
initVirtMem.write(auxv_array_end, zero);
auxv_array_end += sizeof(zero);
- copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
- copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+ copyStringArray(envp, envp_array_base, env_data_base,
+ BigEndianByteOrder, initVirtMem);
+ copyStringArray(argv, argv_array_base, arg_data_base,
+ BigEndianByteOrder, initVirtMem);
initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc
index 11b46c824..f90c764ee 100644
--- a/src/arch/x86/process.cc
+++ b/src/arch/x86/process.cc
@@ -1017,8 +1017,10 @@ X86Process::argsInit(int pageSize,
initVirtMem.writeString(aux_data_base, platform.c_str());
- copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
- copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+ copyStringArray(envp, envp_array_base, env_data_base,
+ LittleEndianByteOrder, initVirtMem);
+ copyStringArray(argv, argv_array_base, arg_data_base,
+ LittleEndianByteOrder, initVirtMem);
initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
diff --git a/src/sim/process_impl.hh b/src/sim/process_impl.hh
index 75134121b..da51c7f84 100644
--- a/src/sim/process_impl.hh
+++ b/src/sim/process_impl.hh
@@ -42,11 +42,11 @@ template<class AddrType>
void
copyStringArray(std::vector<std::string> &strings,
AddrType array_ptr, AddrType data_ptr,
- PortProxy& memProxy)
+ const ByteOrder bo, PortProxy& memProxy)
{
AddrType data_ptr_swap;
for (std::vector<std::string>::size_type i = 0; i < strings.size(); ++i) {
- data_ptr_swap = TheISA::htog(data_ptr);
+ data_ptr_swap = htog(data_ptr, bo);
memProxy.writeBlob(array_ptr, &data_ptr_swap, sizeof(AddrType));
memProxy.writeString(data_ptr, strings[i].c_str());
array_ptr += sizeof(AddrType);