52 #include "debug/Stack.hh"
61 using namespace ArmISA;
65 :
Process(params, objFile), arch(_arch)
75 Addr stack_base = 0xbf000000
L;
76 Addr max_stack_size = 8 * 1024 * 1024;
77 Addr next_thread_stack_base = stack_base - max_stack_size;
78 Addr mmap_end = 0x40000000
L;
80 memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
81 next_thread_stack_base, mmap_end);
90 Addr stack_base = 0x7fffff0000
L;
91 Addr max_stack_size = 8 * 1024 * 1024;
92 Addr next_thread_stack_base = stack_base - max_stack_size;
93 Addr mmap_end = 0x4000000000
L;
95 memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
96 next_thread_stack_base, mmap_end);
140 template <
class IntType>
144 int intSize =
sizeof(IntType);
169 Arm_FastMult = 1 << 4,
175 Arm_Crunch = 1 << 10,
176 Arm_ThumbEE = 1 << 11,
179 Arm_Vfpv3d16 = 1 << 14
248 int sentry_size = intSize;
250 string platform =
"v71";
251 int platform_size = platform.size() + 1;
254 int aux_random_size = 16;
260 int aux_data_size = filename.size() + 1;
262 int env_data_size = 0;
263 for (
int i = 0;
i <
envp.size(); ++
i) {
264 env_data_size +=
envp[
i].size() + 1;
266 int arg_data_size = 0;
267 for (
int i = 0;
i <
argv.size(); ++
i) {
268 arg_data_size +=
argv[
i].size() + 1;
271 int info_block_size =
272 sentry_size + env_data_size + arg_data_size +
273 aux_data_size + platform_size + aux_random_size;
276 int aux_array_size = intSize * 2 * (auxv.size() + 1);
278 int envp_array_size = intSize * (
envp.size() + 1);
279 int argv_array_size = intSize * (
argv.size() + 1);
281 int argc_size = intSize;
293 int partial_size = frame_size;
294 int aligned_partial_size =
roundUp(partial_size, align);
295 int aux_padding = aligned_partial_size - partial_size;
297 int space_needed = frame_size + aux_padding;
308 IntType sentry_base =
memState->getStackBase() - sentry_size;
309 IntType aux_data_base = sentry_base - aux_data_size;
310 IntType env_data_base = aux_data_base - env_data_size;
311 IntType arg_data_base = env_data_base - arg_data_size;
312 IntType platform_base = arg_data_base - platform_size;
313 IntType aux_random_base = platform_base - aux_random_size;
314 IntType auxv_array_base = aux_random_base - aux_array_size - aux_padding;
315 IntType envp_array_base = auxv_array_base - envp_array_size;
316 IntType argv_array_base = envp_array_base - argv_array_size;
317 IntType argc_base = argv_array_base - argc_size;
319 DPRINTF(Stack,
"The addresses of items on the initial stack:\n");
320 DPRINTF(Stack,
"0x%x - aux data\n", aux_data_base);
321 DPRINTF(Stack,
"0x%x - env data\n", env_data_base);
322 DPRINTF(Stack,
"0x%x - arg data\n", arg_data_base);
323 DPRINTF(Stack,
"0x%x - random data\n", aux_random_base);
324 DPRINTF(Stack,
"0x%x - platform base\n", platform_base);
325 DPRINTF(Stack,
"0x%x - auxv array\n", auxv_array_base);
326 DPRINTF(Stack,
"0x%x - envp array\n", envp_array_base);
327 DPRINTF(Stack,
"0x%x - argv array\n", argv_array_base);
328 DPRINTF(Stack,
"0x%x - argc \n", argc_base);
334 IntType argc =
argv.size();
338 IntType sentry_NULL = 0;
340 (uint8_t*)&sentry_NULL, sentry_size);
343 for (
int i = auxv.size() - 1;
i >= 0;
i--) {
345 auxv[
i].a_val = platform_base;
348 auxv[
i].a_val = aux_data_base;
351 auxv[
i].a_val = aux_random_base;
357 for (
int x = 0;
x < auxv.size();
x++) {
359 (uint8_t*)&(auxv[
x].a_type), intSize);
361 (uint8_t*)&(auxv[
x].a_val), intSize);
364 const uint64_t zero = 0;
366 (uint8_t*)&zero, 2 * intSize);
380 if (
argv.size() > 0) {
386 if (
envp.size() > 0) {
395 pc.nextThumb(pc.thumb());
397 pc.nextAArch64(pc.aarch64());
422 assert(width == 32 || width == 64);
Addr programHeaderTable()
std::vector< ContextID > contextIds
ArmISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width)
void allocateMem(Addr vaddr, int64_t size, bool clobber=false)
SETranslatingPortProxy initVirtMem
virtual void setMiscReg(int misc_reg, const MiscReg &val)=0
virtual void setIntReg(int reg_idx, uint64_t val)=0
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
virtual TheISA::PCState pcState()=0
T roundUp(const T &val, const U &align)
std::shared_ptr< MemState > memState
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value)
virtual void setCCReg(int reg_idx, CCReg val)=0
void setSyscallArg(ThreadContext *tc, int i, ArmISA::IntReg val)
virtual uint64_t readIntReg(int reg_idx)=0
ArmProcess(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch)
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value)
void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
T roundDown(const T &val, const U &align)
std::vector< std::string > envp
ThreadContext * getThreadContext(ContextID tid)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void setSyscallArg(ThreadContext *tc, int i, ArmISA::IntReg val)
virtual bool loadSections(PortProxy &mem_proxy, Addr mask=maxAddr, Addr offset=0)
uint16_t programHeaderSize()
void copyStringArray(std::vector< std::string > &strings, AddrType array_ptr, AddrType data_ptr, SETranslatingPortProxy &memProxy)
virtual MiscReg readMiscReg(int misc_reg)=0
void writeString(Addr addr, const char *str) const
Declarations of a non-full system Page Table.
uint16_t programHeaderCount()
ArmProcess64(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch)
GenericISA::SimplePCState< MachInst > PCState
ArmISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width)
int64_t encodedValue() const
The encoded value (as described above)
void argsInit(int pageSize, ArmISA::IntRegIndex spIndex)
ArmProcess32(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch)
const RegIndex ReturnValueReg
std::vector< std::string > argv
This class represents the return value from an emulated system call, including any errno setting...
virtual void writeBlob(Addr addr, const uint8_t *p, int size) const
Write size bytes from p to address.
void initState()
initState() is called on each SimObject when not restoring from a checkpoint.