Deleted Added
sdiff udiff text old ( 13615:5cc9363f5ab7 ) new ( 13894:8603648c1679 )
full compact
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
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;

--- 82 unchanged lines hidden (view full) ---

91 int intSize = sizeof(IntType);
92
93 // Patch the ld_bias for dynamic executables.
94 updateBias();
95
96 // load object file into target memory
97 objFile->loadSections(initVirtMem);
98
99 std::vector<AuxVector<IntType>> auxv;
100
101 ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
102 if (elfObject)
103 {
104 // Set the system page size
105 auxv.emplace_back(M5_AT_PAGESZ, MipsISA::PageBytes);
106 // Set the frequency at which time() increments
107 auxv.emplace_back(M5_AT_CLKTCK, 100);
108 // For statically linked executables, this is the virtual
109 // address of the program header tables if they appear in the
110 // executable image.
111 auxv.emplace_back(M5_AT_PHDR, elfObject->programHeaderTable());
112 DPRINTF(Loader, "auxv at PHDR %08p\n",
113 elfObject->programHeaderTable());
114 // This is the size of a program header entry from the elf file.
115 auxv.emplace_back(M5_AT_PHENT, elfObject->programHeaderSize());
116 // This is the number of program headers from the original elf file.
117 auxv.emplace_back(M5_AT_PHNUM, elfObject->programHeaderCount());
118 // This is the base address of the ELF interpreter; it should be
119 // zero for static executables or contain the base address for
120 // dynamic executables.
121 auxv.emplace_back(M5_AT_BASE, getBias());
122 //The entry point to the program
123 auxv.emplace_back(M5_AT_ENTRY, objFile->entryPoint());
124 //Different user and group IDs
125 auxv.emplace_back(M5_AT_UID, uid());
126 auxv.emplace_back(M5_AT_EUID, euid());
127 auxv.emplace_back(M5_AT_GID, gid());
128 auxv.emplace_back(M5_AT_EGID, egid());
129 }
130
131 // Calculate how much space we need for arg & env & auxv arrays.
132 int argv_array_size = intSize * (argv.size() + 1);
133 int envp_array_size = intSize * (envp.size() + 1);
134 int auxv_array_size = intSize * 2 * (auxv.size() + 1);
135
136 int arg_data_size = 0;

--- 35 unchanged lines hidden (view full) ---

172
173 initVirtMem.writeBlob(memState->getStackMin(), (uint8_t*)&argc, intSize);
174
175 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
176
177 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
178
179 // Copy the aux vector
180 Addr auxv_array_end = auxv_array_base;
181 for (const auto &aux: auxv) {
182 initVirtMem.write(auxv_array_end, aux, GuestByteOrder);
183 auxv_array_end += sizeof(aux);
184 }
185
186 // Write out the terminating zeroed auxilliary vector
187 const AuxVector<IntType> zero(0, 0);
188 initVirtMem.write(auxv_array_end, zero);
189 auxv_array_end += sizeof(zero);
190
191 ThreadContext *tc = system->getThreadContext(contextIds[0]);
192
193 setSyscallArg(tc, 0, argc);
194 setSyscallArg(tc, 1, argv_array_base);
195 tc->setIntReg(StackPointerReg, memState->getStackMin());
196
197 tc->pcState(getStartPC());

--- 30 unchanged lines hidden ---