1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2012 ARM Limited 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 9 * to a hardware implementation of the functionality of the software 10 * licensed hereunder. You may use the software subject to the license 11 * terms below provided that you ensure that this notice is replicated 12 * unmodified and in its entirety in all distributions of the software, 13 * modified or unmodified, in source code or in binary form. 14 * 15 * Copyright (c) 2001-2005 The Regents of The University of Michigan 16 * All rights reserved. 17 * 18 * Redistribution and use in source and binary forms, with or without 19 * modification, are permitted provided that the following conditions are 20 * met: redistributions of source code must retain the above copyright 21 * notice, this list of conditions and the following disclaimer; 22 * redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution; 25 * neither the name of the copyright holders nor the names of its 26 * contributors may be used to endorse or promote products derived from 27 * this software without specific prior written permission. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 * 41 * Authors: Nathan Binkert 42 * Steve Reinhardt 43 * Ali Saidi 44 */ 45 46#include <fcntl.h> 47#include <unistd.h> 48 49#include <cstdio> 50#include <string> 51 52#include "base/loader/object_file.hh" 53#include "base/loader/symtab.hh" 54#include "base/intmath.hh" 55#include "base/statistics.hh" 56#include "config/the_isa.hh" 57#include "cpu/thread_context.hh" 58#include "mem/page_table.hh" 59#include "mem/multi_level_page_table.hh" 60#include "mem/se_translating_port_proxy.hh" 61#include "params/LiveProcess.hh" 62#include "params/Process.hh" 63#include "sim/debug.hh" 64#include "sim/process.hh" 65#include "sim/process_impl.hh" 66#include "sim/stats.hh" 67#include "sim/syscall_emul.hh" 68#include "sim/system.hh" 69 70#if THE_ISA == ALPHA_ISA 71#include "arch/alpha/linux/process.hh" 72#include "arch/alpha/tru64/process.hh" 73#elif THE_ISA == SPARC_ISA 74#include "arch/sparc/linux/process.hh" 75#include "arch/sparc/solaris/process.hh" 76#elif THE_ISA == MIPS_ISA 77#include "arch/mips/linux/process.hh" 78#elif THE_ISA == ARM_ISA 79#include "arch/arm/linux/process.hh" 80#elif THE_ISA == X86_ISA 81#include "arch/x86/linux/process.hh" 82#elif THE_ISA == POWER_ISA 83#include "arch/power/linux/process.hh" 84#else 85#error "THE_ISA not set" 86#endif 87 88 89using namespace std; 90using namespace TheISA; 91 92// current number of allocated processes 93int num_processes = 0; 94 95template<class IntType> 96AuxVector<IntType>::AuxVector(IntType type, IntType val) 97{ 98 a_type = TheISA::htog(type); 99 a_val = TheISA::htog(val); 100} 101 102template struct AuxVector<uint32_t>; 103template struct AuxVector<uint64_t>; 104 105Process::Process(ProcessParams * params) 106 : SimObject(params), system(params->system), 107 max_stack_size(params->max_stack_size), 108 M5_pid(system->allocatePID()), 109 useArchPT(params->useArchPT), 110 pTable(useArchPT ? 111 static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) : 112 static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ), 113 initVirtMem(system->getSystemPort(), this, 114 SETranslatingPortProxy::Always) 115{ 116 string in = params->input; 117 string out = params->output; 118 string err = params->errout; 119 120 // initialize file descriptors to default: same as simulator 121 int stdin_fd, stdout_fd, stderr_fd; 122 123 if (in == "stdin" || in == "cin") 124 stdin_fd = STDIN_FILENO; 125 else if (in == "None") 126 stdin_fd = -1; 127 else 128 stdin_fd = Process::openInputFile(in); 129 130 if (out == "stdout" || out == "cout") 131 stdout_fd = STDOUT_FILENO; 132 else if (out == "stderr" || out == "cerr") 133 stdout_fd = STDERR_FILENO; 134 else if (out == "None") 135 stdout_fd = -1; 136 else 137 stdout_fd = Process::openOutputFile(out); 138 139 if (err == "stdout" || err == "cout") 140 stderr_fd = STDOUT_FILENO; 141 else if (err == "stderr" || err == "cerr") 142 stderr_fd = STDERR_FILENO; 143 else if (err == "None") 144 stderr_fd = -1; 145 else if (err == out) 146 stderr_fd = stdout_fd; 147 else 148 stderr_fd = Process::openOutputFile(err); 149 150 // initialize first 3 fds (stdin, stdout, stderr) 151 Process::FdMap *fdo = &fd_map[STDIN_FILENO]; 152 fdo->fd = stdin_fd; 153 fdo->filename = in; 154 fdo->flags = O_RDONLY; 155 fdo->mode = -1; 156 fdo->fileOffset = 0; 157 158 fdo = &fd_map[STDOUT_FILENO]; 159 fdo->fd = stdout_fd; 160 fdo->filename = out; 161 fdo->flags = O_WRONLY | O_CREAT | O_TRUNC; 162 fdo->mode = 0774; 163 fdo->fileOffset = 0; 164 165 fdo = &fd_map[STDERR_FILENO]; 166 fdo->fd = stderr_fd; 167 fdo->filename = err; 168 fdo->flags = O_WRONLY; 169 fdo->mode = -1; 170 fdo->fileOffset = 0; 171 172 173 // mark remaining fds as free 174 for (int i = 3; i <= MAX_FD; ++i) { 175 fdo = &fd_map[i]; 176 fdo->fd = -1; 177 } 178 179 mmap_start = mmap_end = 0; 180 nxm_start = nxm_end = 0; 181 // other parameters will be initialized when the program is loaded 182} 183 184 185void 186Process::regStats() 187{ 188 using namespace Stats; 189 190 num_syscalls 191 .name(name() + ".num_syscalls") 192 .desc("Number of system calls") 193 ; 194} 195 196// 197// static helper functions 198// 199int 200Process::openInputFile(const string &filename) 201{ 202 int fd = open(filename.c_str(), O_RDONLY); 203 204 if (fd == -1) { 205 perror(NULL); 206 cerr << "unable to open \"" << filename << "\" for reading\n"; 207 fatal("can't open input file"); 208 } 209 210 return fd; 211} 212 213 214int 215Process::openOutputFile(const string &filename) 216{ 217 int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664); 218 219 if (fd == -1) { 220 perror(NULL); 221 cerr << "unable to open \"" << filename << "\" for writing\n"; 222 fatal("can't open output file"); 223 } 224 225 return fd; 226} 227 228ThreadContext * 229Process::findFreeContext() 230{ 231 int size = contextIds.size(); 232 ThreadContext *tc; 233 for (int i = 0; i < size; ++i) { 234 tc = system->getThreadContext(contextIds[i]); 235 if (tc->status() == ThreadContext::Halted) { 236 // inactive context, free to use 237 return tc; 238 } 239 } 240 return NULL; 241} 242 243void 244Process::initState() 245{ 246 if (contextIds.empty()) 247 fatal("Process %s is not associated with any HW contexts!\n", name()); 248 249 // first thread context for this process... initialize & enable 250 ThreadContext *tc = system->getThreadContext(contextIds[0]); 251 252 // mark this context as active so it will start ticking.
|
254 255 pTable->initState(tc); 256} 257 258// map simulator fd sim_fd to target fd tgt_fd 259void 260Process::dup_fd(int sim_fd, int tgt_fd) 261{ 262 if (tgt_fd < 0 || tgt_fd > MAX_FD) 263 panic("Process::dup_fd tried to dup past MAX_FD (%d)", tgt_fd); 264 265 Process::FdMap *fdo = &fd_map[tgt_fd]; 266 fdo->fd = sim_fd; 267} 268 269 270// generate new target fd for sim_fd 271int 272Process::alloc_fd(int sim_fd, string filename, int flags, int mode, bool pipe) 273{ 274 // in case open() returns an error, don't allocate a new fd 275 if (sim_fd == -1) 276 return -1; 277 278 // find first free target fd 279 for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) { 280 Process::FdMap *fdo = &fd_map[free_fd]; 281 if (fdo->fd == -1) { 282 fdo->fd = sim_fd; 283 fdo->filename = filename; 284 fdo->mode = mode; 285 fdo->fileOffset = 0; 286 fdo->flags = flags; 287 fdo->isPipe = pipe; 288 fdo->readPipeSource = 0; 289 return free_fd; 290 } 291 } 292 293 panic("Process::alloc_fd: out of file descriptors!"); 294} 295 296 297// free target fd (e.g., after close) 298void 299Process::free_fd(int tgt_fd) 300{ 301 Process::FdMap *fdo = &fd_map[tgt_fd]; 302 if (fdo->fd == -1) 303 warn("Process::free_fd: request to free unused fd %d", tgt_fd); 304 305 fdo->fd = -1; 306 fdo->filename = "NULL"; 307 fdo->mode = 0; 308 fdo->fileOffset = 0; 309 fdo->flags = 0; 310 fdo->isPipe = false; 311 fdo->readPipeSource = 0; 312} 313 314 315// look up simulator fd for given target fd 316int 317Process::sim_fd(int tgt_fd) 318{ 319 if (tgt_fd < 0 || tgt_fd > MAX_FD) 320 return -1; 321 322 return fd_map[tgt_fd].fd; 323} 324 325Process::FdMap * 326Process::sim_fd_obj(int tgt_fd) 327{ 328 if (tgt_fd < 0 || tgt_fd > MAX_FD) 329 return NULL; 330 331 return &fd_map[tgt_fd]; 332} 333 334void 335Process::allocateMem(Addr vaddr, int64_t size, bool clobber) 336{ 337 int npages = divCeil(size, (int64_t)PageBytes); 338 Addr paddr = system->allocPhysPages(npages); 339 pTable->map(vaddr, paddr, size, clobber); 340} 341 342bool 343Process::fixupStackFault(Addr vaddr) 344{ 345 // Check if this is already on the stack and there's just no page there 346 // yet. 347 if (vaddr >= stack_min && vaddr < stack_base) { 348 allocateMem(roundDown(vaddr, PageBytes), PageBytes); 349 return true; 350 } 351 352 // We've accessed the next page of the stack, so extend it to include 353 // this address. 354 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) { 355 while (vaddr < stack_min) { 356 stack_min -= TheISA::PageBytes; 357 if (stack_base - stack_min > max_stack_size) 358 fatal("Maximum stack size exceeded\n"); 359 allocateMem(stack_min, TheISA::PageBytes); 360 inform("Increasing stack size by one page."); 361 }; 362 return true; 363 } 364 return false; 365} 366 367// find all offsets for currently open files and save them 368void 369Process::fix_file_offsets() 370{ 371 Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO]; 372 Process::FdMap *fdo_stdout = &fd_map[STDOUT_FILENO]; 373 Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO]; 374 string in = fdo_stdin->filename; 375 string out = fdo_stdout->filename; 376 string err = fdo_stderr->filename; 377 378 // initialize file descriptors to default: same as simulator 379 int stdin_fd, stdout_fd, stderr_fd; 380 381 if (in == "stdin" || in == "cin") 382 stdin_fd = STDIN_FILENO; 383 else if (in == "None") 384 stdin_fd = -1; 385 else { 386 // open standard in and seek to the right location 387 stdin_fd = Process::openInputFile(in); 388 if (lseek(stdin_fd, fdo_stdin->fileOffset, SEEK_SET) < 0) 389 panic("Unable to seek to correct location in file: %s", in); 390 } 391 392 if (out == "stdout" || out == "cout") 393 stdout_fd = STDOUT_FILENO; 394 else if (out == "stderr" || out == "cerr") 395 stdout_fd = STDERR_FILENO; 396 else if (out == "None") 397 stdout_fd = -1; 398 else { 399 stdout_fd = Process::openOutputFile(out); 400 if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0) 401 panic("Unable to seek to correct location in file: %s", out); 402 } 403 404 if (err == "stdout" || err == "cout") 405 stderr_fd = STDOUT_FILENO; 406 else if (err == "stderr" || err == "cerr") 407 stderr_fd = STDERR_FILENO; 408 else if (err == "None") 409 stderr_fd = -1; 410 else if (err == out) 411 stderr_fd = stdout_fd; 412 else { 413 stderr_fd = Process::openOutputFile(err); 414 if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0) 415 panic("Unable to seek to correct location in file: %s", err); 416 } 417 418 fdo_stdin->fd = stdin_fd; 419 fdo_stdout->fd = stdout_fd; 420 fdo_stderr->fd = stderr_fd; 421 422 423 for (int free_fd = 3; free_fd <= MAX_FD; ++free_fd) { 424 Process::FdMap *fdo = &fd_map[free_fd]; 425 if (fdo->fd != -1) { 426 if (fdo->isPipe){ 427 if (fdo->filename == "PIPE-WRITE") 428 continue; 429 else { 430 assert (fdo->filename == "PIPE-READ"); 431 //create a new pipe 432 int fds[2]; 433 int pipe_retval = pipe(fds); 434 435 if (pipe_retval < 0) { 436 // error 437 panic("Unable to create new pipe."); 438 } 439 fdo->fd = fds[0]; //set read pipe 440 Process::FdMap *fdo_write = &fd_map[fdo->readPipeSource]; 441 if (fdo_write->filename != "PIPE-WRITE") 442 panic ("Couldn't find write end of the pipe"); 443 444 fdo_write->fd = fds[1];//set write pipe 445 } 446 } else { 447 //Open file 448 int fd = open(fdo->filename.c_str(), fdo->flags, fdo->mode); 449 450 if (fd == -1) 451 panic("Unable to open file: %s", fdo->filename); 452 fdo->fd = fd; 453 454 //Seek to correct location before checkpoint 455 if (lseek(fd,fdo->fileOffset, SEEK_SET) < 0) 456 panic("Unable to seek to correct location in file: %s", 457 fdo->filename); 458 } 459 } 460 } 461} 462 463void 464Process::find_file_offsets() 465{ 466 for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) { 467 Process::FdMap *fdo = &fd_map[free_fd]; 468 if (fdo->fd != -1) { 469 fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR); 470 } else { 471 fdo->filename = "NULL"; 472 fdo->fileOffset = 0; 473 } 474 } 475} 476 477void 478Process::setReadPipeSource(int read_pipe_fd, int source_fd) 479{ 480 Process::FdMap *fdo = &fd_map[read_pipe_fd]; 481 fdo->readPipeSource = source_fd; 482} 483 484void 485Process::FdMap::serialize(std::ostream &os) 486{ 487 SERIALIZE_SCALAR(fd); 488 SERIALIZE_SCALAR(isPipe); 489 SERIALIZE_SCALAR(filename); 490 SERIALIZE_SCALAR(flags); 491 SERIALIZE_SCALAR(readPipeSource); 492 SERIALIZE_SCALAR(fileOffset); 493} 494 495void 496Process::FdMap::unserialize(Checkpoint *cp, const std::string §ion) 497{ 498 UNSERIALIZE_SCALAR(fd); 499 UNSERIALIZE_SCALAR(isPipe); 500 UNSERIALIZE_SCALAR(filename); 501 UNSERIALIZE_SCALAR(flags); 502 UNSERIALIZE_SCALAR(readPipeSource); 503 UNSERIALIZE_SCALAR(fileOffset); 504} 505 506void 507Process::serialize(std::ostream &os) 508{ 509 SERIALIZE_SCALAR(brk_point); 510 SERIALIZE_SCALAR(stack_base); 511 SERIALIZE_SCALAR(stack_size); 512 SERIALIZE_SCALAR(stack_min); 513 SERIALIZE_SCALAR(next_thread_stack_base); 514 SERIALIZE_SCALAR(mmap_start); 515 SERIALIZE_SCALAR(mmap_end); 516 SERIALIZE_SCALAR(nxm_start); 517 SERIALIZE_SCALAR(nxm_end); 518 find_file_offsets(); 519 pTable->serialize(os); 520 for (int x = 0; x <= MAX_FD; x++) { 521 nameOut(os, csprintf("%s.FdMap%d", name(), x)); 522 fd_map[x].serialize(os); 523 } 524 SERIALIZE_SCALAR(M5_pid); 525 526} 527 528void 529Process::unserialize(Checkpoint *cp, const std::string §ion) 530{ 531 UNSERIALIZE_SCALAR(brk_point); 532 UNSERIALIZE_SCALAR(stack_base); 533 UNSERIALIZE_SCALAR(stack_size); 534 UNSERIALIZE_SCALAR(stack_min); 535 UNSERIALIZE_SCALAR(next_thread_stack_base); 536 UNSERIALIZE_SCALAR(mmap_start); 537 UNSERIALIZE_SCALAR(mmap_end); 538 UNSERIALIZE_SCALAR(nxm_start); 539 UNSERIALIZE_SCALAR(nxm_end); 540 pTable->unserialize(cp, section); 541 for (int x = 0; x <= MAX_FD; x++) { 542 fd_map[x].unserialize(cp, csprintf("%s.FdMap%d", section, x)); 543 } 544 fix_file_offsets(); 545 UNSERIALIZE_OPT_SCALAR(M5_pid); 546 // The above returns a bool so that you could do something if you don't 547 // find the param in the checkpoint if you wanted to, like set a default 548 // but in this case we'll just stick with the instantianted value if not 549 // found. 550} 551 552 553bool 554Process::map(Addr vaddr, Addr paddr, int size) 555{ 556 pTable->map(vaddr, paddr, size); 557 return true; 558} 559 560 561//////////////////////////////////////////////////////////////////////// 562// 563// LiveProcess member definitions 564// 565//////////////////////////////////////////////////////////////////////// 566 567 568LiveProcess::LiveProcess(LiveProcessParams * params, ObjectFile *_objFile) 569 : Process(params), objFile(_objFile), 570 argv(params->cmd), envp(params->env), cwd(params->cwd) 571{ 572 __uid = params->uid; 573 __euid = params->euid; 574 __gid = params->gid; 575 __egid = params->egid; 576 __pid = params->pid; 577 __ppid = params->ppid; 578 579 // load up symbols, if any... these may be used for debugging or 580 // profiling. 581 if (!debugSymbolTable) { 582 debugSymbolTable = new SymbolTable(); 583 if (!objFile->loadGlobalSymbols(debugSymbolTable) || 584 !objFile->loadLocalSymbols(debugSymbolTable) || 585 !objFile->loadWeakSymbols(debugSymbolTable)) { 586 // didn't load any symbols 587 delete debugSymbolTable; 588 debugSymbolTable = NULL; 589 } 590 } 591} 592 593void 594LiveProcess::syscall(int64_t callnum, ThreadContext *tc) 595{ 596 num_syscalls++; 597 598 SyscallDesc *desc = getDesc(callnum); 599 if (desc == NULL) 600 fatal("Syscall %d out of range", callnum); 601 602 desc->doSyscall(callnum, this, tc); 603} 604 605IntReg 606LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width) 607{ 608 return getSyscallArg(tc, i); 609} 610 611LiveProcess * 612LiveProcess::create(LiveProcessParams * params) 613{ 614 LiveProcess *process = NULL; 615 616 string executable = 617 params->executable == "" ? params->cmd[0] : params->executable; 618 ObjectFile *objFile = createObjectFile(executable); 619 if (objFile == NULL) { 620 fatal("Can't load object file %s", executable); 621 } 622 623 if (objFile->isDynamic()) 624 fatal("Object file is a dynamic executable however only static " 625 "executables are supported!\n Please recompile your " 626 "executable as a static binary and try again.\n"); 627 628#if THE_ISA == ALPHA_ISA 629 if (objFile->getArch() != ObjectFile::Alpha) 630 fatal("Object file architecture does not match compiled ISA (Alpha)."); 631 632 switch (objFile->getOpSys()) { 633 case ObjectFile::Tru64: 634 process = new AlphaTru64Process(params, objFile); 635 break; 636 637 case ObjectFile::UnknownOpSys: 638 warn("Unknown operating system; assuming Linux."); 639 // fall through 640 case ObjectFile::Linux: 641 process = new AlphaLinuxProcess(params, objFile); 642 break; 643 644 default: 645 fatal("Unknown/unsupported operating system."); 646 } 647#elif THE_ISA == SPARC_ISA 648 if (objFile->getArch() != ObjectFile::SPARC64 && 649 objFile->getArch() != ObjectFile::SPARC32) 650 fatal("Object file architecture does not match compiled ISA (SPARC)."); 651 switch (objFile->getOpSys()) { 652 case ObjectFile::UnknownOpSys: 653 warn("Unknown operating system; assuming Linux."); 654 // fall through 655 case ObjectFile::Linux: 656 if (objFile->getArch() == ObjectFile::SPARC64) { 657 process = new Sparc64LinuxProcess(params, objFile); 658 } else { 659 process = new Sparc32LinuxProcess(params, objFile); 660 } 661 break; 662 663 664 case ObjectFile::Solaris: 665 process = new SparcSolarisProcess(params, objFile); 666 break; 667 668 default: 669 fatal("Unknown/unsupported operating system."); 670 } 671#elif THE_ISA == X86_ISA 672 if (objFile->getArch() != ObjectFile::X86_64 && 673 objFile->getArch() != ObjectFile::I386) 674 fatal("Object file architecture does not match compiled ISA (x86)."); 675 switch (objFile->getOpSys()) { 676 case ObjectFile::UnknownOpSys: 677 warn("Unknown operating system; assuming Linux."); 678 // fall through 679 case ObjectFile::Linux: 680 if (objFile->getArch() == ObjectFile::X86_64) { 681 process = new X86_64LinuxProcess(params, objFile); 682 } else { 683 process = new I386LinuxProcess(params, objFile); 684 } 685 break; 686 687 default: 688 fatal("Unknown/unsupported operating system."); 689 } 690#elif THE_ISA == MIPS_ISA 691 if (objFile->getArch() != ObjectFile::Mips) 692 fatal("Object file architecture does not match compiled ISA (MIPS)."); 693 switch (objFile->getOpSys()) { 694 case ObjectFile::UnknownOpSys: 695 warn("Unknown operating system; assuming Linux."); 696 // fall through 697 case ObjectFile::Linux: 698 process = new MipsLinuxProcess(params, objFile); 699 break; 700 701 default: 702 fatal("Unknown/unsupported operating system."); 703 } 704#elif THE_ISA == ARM_ISA 705 ObjectFile::Arch arch = objFile->getArch(); 706 if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 707 arch != ObjectFile::Arm64) 708 fatal("Object file architecture does not match compiled ISA (ARM)."); 709 switch (objFile->getOpSys()) { 710 case ObjectFile::UnknownOpSys: 711 warn("Unknown operating system; assuming Linux."); 712 // fall through 713 case ObjectFile::Linux: 714 if (arch == ObjectFile::Arm64) { 715 process = new ArmLinuxProcess64(params, objFile, 716 objFile->getArch()); 717 } else { 718 process = new ArmLinuxProcess32(params, objFile, 719 objFile->getArch()); 720 } 721 break; 722 case ObjectFile::LinuxArmOABI: 723 fatal("M5 does not support ARM OABI binaries. Please recompile with an" 724 " EABI compiler."); 725 default: 726 fatal("Unknown/unsupported operating system."); 727 } 728#elif THE_ISA == POWER_ISA 729 if (objFile->getArch() != ObjectFile::Power) 730 fatal("Object file architecture does not match compiled ISA (Power)."); 731 switch (objFile->getOpSys()) { 732 case ObjectFile::UnknownOpSys: 733 warn("Unknown operating system; assuming Linux."); 734 // fall through 735 case ObjectFile::Linux: 736 process = new PowerLinuxProcess(params, objFile); 737 break; 738 739 default: 740 fatal("Unknown/unsupported operating system."); 741 } 742#else 743#error "THE_ISA not set" 744#endif 745 746 if (process == NULL) 747 fatal("Unknown error creating process object."); 748 return process; 749} 750 751LiveProcess * 752LiveProcessParams::create() 753{ 754 return LiveProcess::create(this); 755}
|