process.cc (13614:52c5311db96b) | process.cc (13894:8603648c1679) |
---|---|
1/* 2 * Copyright (c) 2003-2004 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; --- 68 unchanged lines hidden (view full) --- 77void 78AlphaProcess::argsInit(int intSize, int pageSize) 79{ 80 // Patch the ld_bias for dynamic executables. 81 updateBias(); 82 83 objFile->loadSections(initVirtMem); 84 | 1/* 2 * Copyright (c) 2003-2004 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; --- 68 unchanged lines hidden (view full) --- 77void 78AlphaProcess::argsInit(int intSize, int pageSize) 79{ 80 // Patch the ld_bias for dynamic executables. 81 updateBias(); 82 83 objFile->loadSections(initVirtMem); 84 |
85 typedef AuxVector<uint64_t> auxv_t; 86 std::vector<auxv_t> auxv; | 85 std::vector<AuxVector<uint64_t>> auxv; |
87 88 ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile); 89 if (elfObject) 90 { 91 // modern glibc uses a bunch of auxiliary vectors to set up 92 // TLS as well as do a bunch of other stuff 93 // these vectors go on the bottom of the stack, below argc/argv/envp 94 // pointers but above actual arg strings 95 // I don't have all the ones glibc looks at here, but so far it doesn't 96 // seem to be a problem. 97 // check out _dl_aux_init() in glibc/elf/dl-support.c for details 98 // --Lisa | 86 87 ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile); 88 if (elfObject) 89 { 90 // modern glibc uses a bunch of auxiliary vectors to set up 91 // TLS as well as do a bunch of other stuff 92 // these vectors go on the bottom of the stack, below argc/argv/envp 93 // pointers but above actual arg strings 94 // I don't have all the ones glibc looks at here, but so far it doesn't 95 // seem to be a problem. 96 // check out _dl_aux_init() in glibc/elf/dl-support.c for details 97 // --Lisa |
99 auxv.push_back(auxv_t(M5_AT_PAGESZ, AlphaISA::PageBytes)); 100 auxv.push_back(auxv_t(M5_AT_CLKTCK, 100)); 101 auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable())); 102 DPRINTF(Loader, "auxv at PHDR %08p\n", elfObject->programHeaderTable()); 103 auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount())); | 98 auxv.emplace_back(M5_AT_PAGESZ, AlphaISA::PageBytes); 99 auxv.emplace_back(M5_AT_CLKTCK, 100); 100 auxv.emplace_back(M5_AT_PHDR, elfObject->programHeaderTable()); 101 DPRINTF(Loader, "auxv at PHDR %08p\n", 102 elfObject->programHeaderTable()); 103 auxv.emplace_back(M5_AT_PHNUM, elfObject->programHeaderCount()); |
104 // This is the base address of the ELF interpreter; it should be 105 // zero for static executables or contain the base address for 106 // dynamic executables. | 104 // This is the base address of the ELF interpreter; it should be 105 // zero for static executables or contain the base address for 106 // dynamic executables. |
107 auxv.push_back(auxv_t(M5_AT_BASE, getBias())); 108 auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint())); 109 auxv.push_back(auxv_t(M5_AT_UID, uid())); 110 auxv.push_back(auxv_t(M5_AT_EUID, euid())); 111 auxv.push_back(auxv_t(M5_AT_GID, gid())); 112 auxv.push_back(auxv_t(M5_AT_EGID, egid())); | 107 auxv.emplace_back(M5_AT_BASE, getBias()); 108 auxv.emplace_back(M5_AT_ENTRY, objFile->entryPoint()); 109 auxv.emplace_back(M5_AT_UID, uid()); 110 auxv.emplace_back(M5_AT_EUID, euid()); 111 auxv.emplace_back(M5_AT_GID, gid()); 112 auxv.emplace_back(M5_AT_EGID, egid()); |
113 114 } 115 116 // Calculate how much space we need for arg & env & auxv arrays. 117 int argv_array_size = intSize * (argv.size() + 1); 118 int envp_array_size = intSize * (envp.size() + 1); 119 int auxv_array_size = intSize * 2 * (auxv.size() + 1); 120 --- 42 unchanged lines hidden (view full) --- 163 panic("Unknown int size"); 164 165 initVirtMem.writeBlob(memState->getStackMin(), (uint8_t*)&argc, intSize); 166 167 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 168 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 169 170 //Copy the aux stuff | 113 114 } 115 116 // Calculate how much space we need for arg & env & auxv arrays. 117 int argv_array_size = intSize * (argv.size() + 1); 118 int envp_array_size = intSize * (envp.size() + 1); 119 int auxv_array_size = intSize * 2 * (auxv.size() + 1); 120 --- 42 unchanged lines hidden (view full) --- 163 panic("Unknown int size"); 164 165 initVirtMem.writeBlob(memState->getStackMin(), (uint8_t*)&argc, intSize); 166 167 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 168 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 169 170 //Copy the aux stuff |
171 for (vector<auxv_t>::size_type x = 0; x < auxv.size(); x++) { 172 initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize, 173 (uint8_t*)&(auxv[x].getAuxType()), intSize); 174 initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize, 175 (uint8_t*)&(auxv[x].getAuxVal()), intSize); | 171 Addr auxv_array_end = auxv_array_base; 172 for (const auto &aux: auxv) { 173 initVirtMem.write(auxv_array_end, aux, GuestByteOrder); 174 auxv_array_end += sizeof(aux); |
176 } 177 178 ThreadContext *tc = system->getThreadContext(contextIds[0]); 179 180 setSyscallArg(tc, 0, argc); 181 setSyscallArg(tc, 1, argv_array_base); 182 tc->setIntReg(StackPointerReg, memState->getStackMin()); 183 --- 71 unchanged lines hidden --- | 175 } 176 177 ThreadContext *tc = system->getThreadContext(contextIds[0]); 178 179 setSyscallArg(tc, 0, argc); 180 setSyscallArg(tc, 1, argv_array_base); 181 tc->setIntReg(StackPointerReg, memState->getStackMin()); 182 --- 71 unchanged lines hidden --- |