process.cc (7172:2137885e2088) | process.cc (7414:0a05aa495903) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2010 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * |
|
2 * Copyright (c) 2007-2008 The Florida State University 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright --- 11 unchanged lines hidden (view full) --- 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Stephen Hines | 14 * Copyright (c) 2007-2008 The Florida State University 15 * All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions are 19 * met: redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer; 21 * redistributions in binary form must reproduce the above copyright --- 11 unchanged lines hidden (view full) --- 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Authors: Stephen Hines |
41 * Ali Saidi |
|
29 */ 30 31#include "arch/arm/isa_traits.hh" 32#include "arch/arm/process.hh" 33#include "arch/arm/types.hh" 34#include "base/loader/elf_object.hh" 35#include "base/loader/object_file.hh" 36#include "base/misc.hh" --- 76 unchanged lines hidden (view full) --- 113 Arm_Thumb = 1 << 2, 114 Arm_26Bit = 1 << 3, 115 Arm_FastMult = 1 << 4, 116 Arm_Fpa = 1 << 5, 117 Arm_Vfp = 1 << 6, 118 Arm_Edsp = 1 << 7, 119 Arm_Java = 1 << 8, 120 Arm_Iwmmxt = 1 << 9, | 42 */ 43 44#include "arch/arm/isa_traits.hh" 45#include "arch/arm/process.hh" 46#include "arch/arm/types.hh" 47#include "base/loader/elf_object.hh" 48#include "base/loader/object_file.hh" 49#include "base/misc.hh" --- 76 unchanged lines hidden (view full) --- 126 Arm_Thumb = 1 << 2, 127 Arm_26Bit = 1 << 3, 128 Arm_FastMult = 1 << 4, 129 Arm_Fpa = 1 << 5, 130 Arm_Vfp = 1 << 6, 131 Arm_Edsp = 1 << 7, 132 Arm_Java = 1 << 8, 133 Arm_Iwmmxt = 1 << 9, |
121 Arm_Crunch = 1 << 10 | 134 Arm_Crunch = 1 << 10, 135 Arm_ThumbEE = 1 << 11, 136 Arm_Neon = 1 << 12, 137 Arm_Vfpv3 = 1 << 13, 138 Arm_Vfpv3d16 = 1 << 14 |
122 }; 123 124 //Setup the auxilliary vectors. These will already have endian conversion. 125 //Auxilliary vectors are loaded only for elf formatted executables. 126 ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile); 127 if (elfObject) { 128 uint32_t features = 129 Arm_Swp | 130 Arm_Half | 131 Arm_Thumb | 132// Arm_26Bit | 133 Arm_FastMult | 134// Arm_Fpa | 135 Arm_Vfp | 136 Arm_Edsp | | 139 }; 140 141 //Setup the auxilliary vectors. These will already have endian conversion. 142 //Auxilliary vectors are loaded only for elf formatted executables. 143 ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile); 144 if (elfObject) { 145 uint32_t features = 146 Arm_Swp | 147 Arm_Half | 148 Arm_Thumb | 149// Arm_26Bit | 150 Arm_FastMult | 151// Arm_Fpa | 152 Arm_Vfp | 153 Arm_Edsp | |
137 Arm_Java | | 154// Arm_Java | |
138// Arm_Iwmmxt | 139// Arm_Crunch | | 155// Arm_Iwmmxt | 156// Arm_Crunch | |
157 Arm_ThumbEE | 158 Arm_Neon | 159 Arm_Vfpv3 | 160 Arm_Vfpv3d16 | |
|
140 0; 141 142 //Bits which describe the system hardware capabilities 143 //XXX Figure out what these should be 144 auxv.push_back(auxv_t(M5_AT_HWCAP, features)); 145 //The system page size 146 auxv.push_back(auxv_t(M5_AT_PAGESZ, ArmISA::VMPageSize)); 147 //Frequency at which times() increments --- 16 unchanged lines hidden (view full) --- 164 auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint())); 165 //Different user and group IDs 166 auxv.push_back(auxv_t(M5_AT_UID, uid())); 167 auxv.push_back(auxv_t(M5_AT_EUID, euid())); 168 auxv.push_back(auxv_t(M5_AT_GID, gid())); 169 auxv.push_back(auxv_t(M5_AT_EGID, egid())); 170 //Whether to enable "secure mode" in the executable 171 auxv.push_back(auxv_t(M5_AT_SECURE, 0)); | 161 0; 162 163 //Bits which describe the system hardware capabilities 164 //XXX Figure out what these should be 165 auxv.push_back(auxv_t(M5_AT_HWCAP, features)); 166 //The system page size 167 auxv.push_back(auxv_t(M5_AT_PAGESZ, ArmISA::VMPageSize)); 168 //Frequency at which times() increments --- 16 unchanged lines hidden (view full) --- 185 auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint())); 186 //Different user and group IDs 187 auxv.push_back(auxv_t(M5_AT_UID, uid())); 188 auxv.push_back(auxv_t(M5_AT_EUID, euid())); 189 auxv.push_back(auxv_t(M5_AT_GID, gid())); 190 auxv.push_back(auxv_t(M5_AT_EGID, egid())); 191 //Whether to enable "secure mode" in the executable 192 auxv.push_back(auxv_t(M5_AT_SECURE, 0)); |
193 194 // Pointer to 16 bytes of random data 195 auxv.push_back(auxv_t(M5_AT_RANDOM, 0)); 196 |
|
172 //The filename of the program 173 auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); | 197 //The filename of the program 198 auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); |
174 //The string "v51" with unknown meaning | 199 //The string "v71" -- ARM v7 architecture |
175 auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); 176 } 177 178 //Figure out how big the initial stack nedes to be 179 180 // A sentry NULL void pointer at the top of the stack. 181 int sentry_size = intSize; 182 | 200 auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); 201 } 202 203 //Figure out how big the initial stack nedes to be 204 205 // A sentry NULL void pointer at the top of the stack. 206 int sentry_size = intSize; 207 |
183 string platform = "v51"; | 208 string platform = "v71"; |
184 int platform_size = platform.size() + 1; 185 | 209 int platform_size = platform.size() + 1; 210 |
211 // Bytes for AT_RANDOM above, we'll just keep them 0 212 int aux_random_size = 16; // as per the specification 213 |
|
186 // The aux vectors are put on the stack in two groups. The first group are 187 // the vectors that are generated as the elf is loaded. The second group 188 // are the ones that were computed ahead of time and include the platform 189 // string. 190 int aux_data_size = filename.size() + 1; 191 192 int env_data_size = 0; 193 for (int i = 0; i < envp.size(); ++i) { 194 env_data_size += envp[i].size() + 1; 195 } 196 int arg_data_size = 0; 197 for (int i = 0; i < argv.size(); ++i) { 198 arg_data_size += argv[i].size() + 1; 199 } 200 201 int info_block_size = 202 sentry_size + env_data_size + arg_data_size + | 214 // The aux vectors are put on the stack in two groups. The first group are 215 // the vectors that are generated as the elf is loaded. The second group 216 // are the ones that were computed ahead of time and include the platform 217 // string. 218 int aux_data_size = filename.size() + 1; 219 220 int env_data_size = 0; 221 for (int i = 0; i < envp.size(); ++i) { 222 env_data_size += envp[i].size() + 1; 223 } 224 int arg_data_size = 0; 225 for (int i = 0; i < argv.size(); ++i) { 226 arg_data_size += argv[i].size() + 1; 227 } 228 229 int info_block_size = 230 sentry_size + env_data_size + arg_data_size + |
203 aux_data_size + platform_size; | 231 aux_data_size + platform_size + aux_random_size; |
204 205 //Each auxilliary vector is two 4 byte words 206 int aux_array_size = intSize * 2 * (auxv.size() + 1); 207 208 int envp_array_size = intSize * (envp.size() + 1); 209 int argv_array_size = intSize * (argv.size() + 1); 210 211 int argc_size = intSize; --- 23 unchanged lines hidden (view full) --- 235 roundUp(stack_size, pageSize)); 236 237 // map out initial stack contents 238 uint32_t sentry_base = stack_base - sentry_size; 239 uint32_t aux_data_base = sentry_base - aux_data_size; 240 uint32_t env_data_base = aux_data_base - env_data_size; 241 uint32_t arg_data_base = env_data_base - arg_data_size; 242 uint32_t platform_base = arg_data_base - platform_size; | 232 233 //Each auxilliary vector is two 4 byte words 234 int aux_array_size = intSize * 2 * (auxv.size() + 1); 235 236 int envp_array_size = intSize * (envp.size() + 1); 237 int argv_array_size = intSize * (argv.size() + 1); 238 239 int argc_size = intSize; --- 23 unchanged lines hidden (view full) --- 263 roundUp(stack_size, pageSize)); 264 265 // map out initial stack contents 266 uint32_t sentry_base = stack_base - sentry_size; 267 uint32_t aux_data_base = sentry_base - aux_data_size; 268 uint32_t env_data_base = aux_data_base - env_data_size; 269 uint32_t arg_data_base = env_data_base - arg_data_size; 270 uint32_t platform_base = arg_data_base - platform_size; |
243 uint32_t auxv_array_base = platform_base - aux_array_size - aux_padding; | 271 uint32_t aux_random_base = platform_base - aux_random_size; 272 uint32_t auxv_array_base = aux_random_base - aux_array_size - aux_padding; |
244 uint32_t envp_array_base = auxv_array_base - envp_array_size; 245 uint32_t argv_array_base = envp_array_base - argv_array_size; 246 uint32_t argc_base = argv_array_base - argc_size; 247 248 DPRINTF(Stack, "The addresses of items on the initial stack:\n"); 249 DPRINTF(Stack, "0x%x - aux data\n", aux_data_base); 250 DPRINTF(Stack, "0x%x - env data\n", env_data_base); 251 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base); | 273 uint32_t envp_array_base = auxv_array_base - envp_array_size; 274 uint32_t argv_array_base = envp_array_base - argv_array_size; 275 uint32_t argc_base = argv_array_base - argc_size; 276 277 DPRINTF(Stack, "The addresses of items on the initial stack:\n"); 278 DPRINTF(Stack, "0x%x - aux data\n", aux_data_base); 279 DPRINTF(Stack, "0x%x - env data\n", env_data_base); 280 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base); |
281 DPRINTF(Stack, "0x%x - random data\n", aux_random_base); |
|
252 DPRINTF(Stack, "0x%x - platform base\n", platform_base); 253 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base); 254 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base); 255 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base); 256 DPRINTF(Stack, "0x%x - argc \n", argc_base); 257 DPRINTF(Stack, "0x%x - stack min\n", stack_min); 258 259 // write contents to stack --- 10 unchanged lines hidden (view full) --- 270 //Fix up the aux vectors which point to other data 271 for (int i = auxv.size() - 1; i >= 0; i--) { 272 if (auxv[i].a_type == M5_AT_PLATFORM) { 273 auxv[i].a_val = platform_base; 274 initVirtMem->writeString(platform_base, platform.c_str()); 275 } else if (auxv[i].a_type == M5_AT_EXECFN) { 276 auxv[i].a_val = aux_data_base; 277 initVirtMem->writeString(aux_data_base, filename.c_str()); | 282 DPRINTF(Stack, "0x%x - platform base\n", platform_base); 283 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base); 284 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base); 285 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base); 286 DPRINTF(Stack, "0x%x - argc \n", argc_base); 287 DPRINTF(Stack, "0x%x - stack min\n", stack_min); 288 289 // write contents to stack --- 10 unchanged lines hidden (view full) --- 300 //Fix up the aux vectors which point to other data 301 for (int i = auxv.size() - 1; i >= 0; i--) { 302 if (auxv[i].a_type == M5_AT_PLATFORM) { 303 auxv[i].a_val = platform_base; 304 initVirtMem->writeString(platform_base, platform.c_str()); 305 } else if (auxv[i].a_type == M5_AT_EXECFN) { 306 auxv[i].a_val = aux_data_base; 307 initVirtMem->writeString(aux_data_base, filename.c_str()); |
308 } else if (auxv[i].a_type == M5_AT_RANDOM) { 309 auxv[i].a_val = aux_random_base; 310 // Just leave the value 0, we don't want randomness |
|
278 } 279 } 280 281 //Copy the aux stuff 282 for(int x = 0; x < auxv.size(); x++) 283 { 284 initVirtMem->writeBlob(auxv_array_base + x * 2 * intSize, 285 (uint8_t*)&(auxv[x].a_type), intSize); --- 64 unchanged lines hidden --- | 311 } 312 } 313 314 //Copy the aux stuff 315 for(int x = 0; x < auxv.size(); x++) 316 { 317 initVirtMem->writeBlob(auxv_array_base + x * 2 * intSize, 318 (uint8_t*)&(auxv[x].a_type), intSize); --- 64 unchanged lines hidden --- |