Deleted Added
sdiff udiff text old ( 13867:9b10bbcf0543 ) new ( 13894:8603648c1679 )
full compact
1/*
2 * Copyright (c) 2014 Advanced Micro Devices, Inc.
3 * Copyright (c) 2007 The Hewlett-Packard Development Company
4 * All rights reserved.
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

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

757
758template<class IntType>
759void
760X86Process::argsInit(int pageSize,
761 std::vector<AuxVector<IntType> > extraAuxvs)
762{
763 int intSize = sizeof(IntType);
764
765 std::vector<AuxVector<IntType>> auxv = extraAuxvs;
766
767 string filename;
768 if (argv.size() < 1)
769 filename = "";
770 else
771 filename = argv[0];
772
773 // We want 16 byte alignment

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

853// X86_CPUSelfSnoop |
854// X86_HyperThreading |
855// X86_AutomaticClockControl |
856// X86_IA64Processor |
857 0;
858
859 // Bits which describe the system hardware capabilities
860 // XXX Figure out what these should be
861 auxv.emplace_back(M5_AT_HWCAP, features);
862 // The system page size
863 auxv.emplace_back(M5_AT_PAGESZ, X86ISA::PageBytes);
864 // Frequency at which times() increments
865 // Defined to be 100 in the kernel source.
866 auxv.emplace_back(M5_AT_CLKTCK, 100);
867 // This is the virtual address of the program header tables if they
868 // appear in the executable image.
869 auxv.emplace_back(M5_AT_PHDR, elfObject->programHeaderTable());
870 // This is the size of a program header entry from the elf file.
871 auxv.emplace_back(M5_AT_PHENT, elfObject->programHeaderSize());
872 // This is the number of program headers from the original elf file.
873 auxv.emplace_back(M5_AT_PHNUM, elfObject->programHeaderCount());
874 // This is the base address of the ELF interpreter; it should be
875 // zero for static executables or contain the base address for
876 // dynamic executables.
877 auxv.emplace_back(M5_AT_BASE, getBias());
878 // XXX Figure out what this should be.
879 auxv.emplace_back(M5_AT_FLAGS, 0);
880 // The entry point to the program
881 auxv.emplace_back(M5_AT_ENTRY, objFile->entryPoint());
882 // Different user and group IDs
883 auxv.emplace_back(M5_AT_UID, uid());
884 auxv.emplace_back(M5_AT_EUID, euid());
885 auxv.emplace_back(M5_AT_GID, gid());
886 auxv.emplace_back(M5_AT_EGID, egid());
887 // Whether to enable "secure mode" in the executable
888 auxv.emplace_back(M5_AT_SECURE, 0);
889 // The address of 16 "random" bytes.
890 auxv.emplace_back(M5_AT_RANDOM, 0);
891 // The name of the program
892 auxv.emplace_back(M5_AT_EXECFN, 0);
893 // The platform string
894 auxv.emplace_back(M5_AT_PLATFORM, 0);
895 }
896
897 // Figure out how big the initial stack needs to be
898
899 // A sentry NULL void pointer at the top of the stack.
900 int sentry_size = intSize;
901
902 // This is the name of the file which is present on the initial stack

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

1000 // Write out the sentry void *
1001 IntType sentry_NULL = 0;
1002 initVirtMem.writeBlob(sentry_base, (uint8_t*)&sentry_NULL, sentry_size);
1003
1004 // Write the file name
1005 initVirtMem.writeString(file_name_base, filename.c_str());
1006
1007 // Fix up the aux vectors which point to data
1008 assert(auxv[auxv.size() - 3].type == M5_AT_RANDOM);
1009 auxv[auxv.size() - 3].val = aux_data_base;
1010 assert(auxv[auxv.size() - 2].type == M5_AT_EXECFN);
1011 auxv[auxv.size() - 2].val = argv_array_base;
1012 assert(auxv[auxv.size() - 1].type == M5_AT_PLATFORM);
1013 auxv[auxv.size() - 1].val = aux_data_base + numRandomBytes;
1014
1015
1016 // Copy the aux stuff
1017 Addr auxv_array_end = auxv_array_base;
1018 for (const auto &aux: auxv) {
1019 initVirtMem.write(auxv_array_end, aux, GuestByteOrder);
1020 auxv_array_end += sizeof(aux);
1021 }
1022 // Write out the terminating zeroed auxiliary vector
1023 const AuxVector<uint64_t> zero(0, 0);
1024 initVirtMem.write(auxv_array_end, zero);
1025 auxv_array_end += sizeof(zero);
1026
1027 initVirtMem.writeString(aux_data_base, platform.c_str());
1028
1029 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
1030 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
1031
1032 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
1033

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

1042 // Align the "stack_min" to a page boundary.
1043 memState->setStackMin(roundDown(stack_min, pageSize));
1044}
1045
1046void
1047X86_64Process::argsInit(int pageSize)
1048{
1049 std::vector<AuxVector<uint64_t> > extraAuxvs;
1050 extraAuxvs.emplace_back(M5_AT_SYSINFO_EHDR, vsyscallPage.base);
1051 X86Process::argsInit<uint64_t>(pageSize, extraAuxvs);
1052}
1053
1054void
1055I386Process::argsInit(int pageSize)
1056{
1057 std::vector<AuxVector<uint32_t> > extraAuxvs;
1058 //Tell the binary where the vsyscall part of the vsyscall page is.
1059 extraAuxvs.emplace_back(M5_AT_SYSINFO,
1060 vsyscallPage.base + vsyscallPage.vsyscallOffset);
1061 extraAuxvs.emplace_back(M5_AT_SYSINFO_EHDR, vsyscallPage.base);
1062 X86Process::argsInit<uint32_t>(pageSize, extraAuxvs);
1063}
1064
1065void
1066X86Process::setSyscallReturn(ThreadContext *tc, SyscallReturn retval)
1067{
1068 tc->setIntReg(INTREG_RAX, retval.encodedValue());
1069}

--- 55 unchanged lines hidden ---