33 #include <sys/syscall.h>
47 class LinuxLoader :
public Process::Loader
51 load(
const ProcessParams ¶ms, loader::ObjectFile *obj)
override
53 auto arch = obj->getArch();
54 auto opsys = obj->getOpSys();
60 warn(
"Unknown operating system; assuming Linux.");
68 return new RiscvProcess64(params, obj);
70 return new RiscvProcess32(params, obj);
74 LinuxLoader linuxLoader;
87 process->Process::syscall(tc);
102 strcpy(
name->sysname,
"Linux");
103 strcpy(
name->nodename,
"sim.gem5.org");
104 strcpy(
name->release, process->release.c_str());
105 strcpy(
name->version,
"#1 Mon Aug 18 11:32:15 EDT 2003");
106 strcpy(
name->machine,
"riscv64");
117 strcpy(
name->sysname,
"Linux");
118 strcpy(
name->nodename,
"sim.gem5.org");
119 strcpy(
name->release, process->release.c_str());
120 strcpy(
name->version,
"#1 Mon Aug 18 11:32:15 EDT 2003");
121 strcpy(
name->machine,
"riscv32");
131 { 4,
"io_getevents" },
139 { 12,
"llistxattr" },
140 { 13,
"flistxattr" },
141 { 14,
"removexattr" },
142 { 15,
"lremovexattr" },
143 { 16,
"fremovexattr" },
145 { 18,
"lookup_dcookie" },
147 { 20,
"epoll_create1" },
149 { 22,
"epoll_pwait" },
153 { 26,
"inotify_init1" },
154 { 27,
"inotify_add_watch" },
155 { 28,
"inotify_rm_watch" },
156 { 29,
"ioctl", ioctlFunc<RiscvLinux64> },
157 { 30,
"ioprio_get" },
158 { 31,
"ioprio_set" },
160 { 33,
"mknodat", mknodatFunc<RiscvLinux64> },
161 { 34,
"mkdirat", mkdiratFunc<RiscvLinux64> },
162 { 35,
"unlinkat", unlinkatFunc<RiscvLinux64> },
165 { 38,
"renameat", renameatFunc<RiscvLinux64> },
168 { 41,
"pivot_root" },
169 { 42,
"nfsservctl" },
170 { 43,
"statfs", statfsFunc<RiscvLinux64> },
171 { 44,
"fstatfs", fstatfsFunc<RiscvLinux64> },
172 { 45,
"truncate", truncateFunc<RiscvLinux64> },
174 { 47,
"fallocate", fallocateFunc<RiscvLinux64> },
175 { 48,
"faccessat", faccessatFunc<RiscvLinux64> },
179 { 52,
"fchmod", fchmodFunc<RiscvLinux64> },
183 { 56,
"openat", openatFunc<RiscvLinux64> },
188 #if defined(SYS_getdents64)
189 { 61,
"getdents64", getdents64Func },
191 { 61,
"getdents64" },
194 { 63,
"read", readFunc<RiscvLinux64> },
195 { 64,
"write", writeFunc<RiscvLinux64> },
196 { 66,
"writev", writevFunc<RiscvLinux64> },
197 { 67,
"pread64", pread64Func<RiscvLinux64> },
198 { 68,
"pwrite64", pwrite64Func<RiscvLinux64> },
204 { 74,
"signalfd64" },
208 { 78,
"readlinkat", readlinkatFunc<RiscvLinux64> },
209 { 79,
"fstatat", fstatat64Func<RiscvLinux64> },
210 { 80,
"fstat", fstat64Func<RiscvLinux64> },
214 { 84,
"sync_file_range2" },
215 { 85,
"timerfd_create" },
216 { 86,
"timerfd_settime" },
217 { 87,
"timerfd_gettime" },
222 { 92,
"personality" },
228 { 98,
"futex", futexFunc<RiscvLinux64> },
232 { 102,
"getitimer" },
233 { 103,
"setitimer" },
234 { 104,
"kexec_load" },
235 { 105,
"init_module" },
236 { 106,
"delete_module" },
237 { 107,
"timer_create" },
238 { 108,
"timer_gettime" },
239 { 109,
"timer_getoverrun" },
240 { 110,
"timer_settime" },
241 { 111,
"timer_delete" },
242 { 112,
"clock_settime" },
243 { 113,
"clock_gettime", clock_gettimeFunc<RiscvLinux64> },
244 { 114,
"clock_getres", clock_getresFunc<RiscvLinux64> },
245 { 115,
"clock_nanosleep" },
248 { 118,
"sched_setparam" },
249 { 119,
"sched_setscheduler" },
250 { 120,
"sched_getscheduler" },
251 { 121,
"sched_getparam" },
252 { 122,
"sched_setaffinity" },
253 { 123,
"sched_getaffinity", schedGetaffinityFunc<RiscvLinux64> },
255 { 125,
"sched_get_priority_max" },
256 { 126,
"sched_get_priority_min" },
257 { 127,
"scheD_rr_get_interval" },
258 { 128,
"restart_syscall" },
261 { 131,
"tgkill", tgkillFunc<RiscvLinux64> },
262 { 132,
"sigaltstack" },
270 { 140,
"setpriority" },
271 { 141,
"getpriority" },
277 { 147,
"setresuid" },
278 { 148,
"getresuid" },
279 { 149,
"getresgid" },
280 { 150,
"getresgid" },
283 { 153,
"times", timesFunc<RiscvLinux64> },
288 { 158,
"getgroups" },
289 { 159,
"setgroups" },
291 { 161,
"sethostname" },
292 { 162,
"setdomainname" },
293 { 163,
"getrlimit", getrlimitFunc<RiscvLinux64> },
295 { 165,
"getrusage", getrusageFunc<RiscvLinux64> },
299 { 169,
"gettimeofday", gettimeofdayFunc<RiscvLinux64> },
300 { 170,
"settimeofday" },
309 { 179,
"sysinfo", sysinfoFunc<RiscvLinux64> },
311 { 181,
"mq_unlink" },
312 { 182,
"mq_timedsend" },
313 { 183,
"mq_timedrecieve" },
314 { 184,
"mq_notify" },
315 { 185,
"mq_getsetattr" },
322 { 192,
"semtimedop" },
328 { 198,
"socket", socketFunc<RiscvLinux64> },
329 { 199,
"socketpair", socketpairFunc<RiscvLinux64> },
332 { 202,
"accept", acceptFunc<RiscvLinux64> },
336 { 206,
"sendto", sendtoFunc<RiscvLinux64> },
337 { 207,
"recvfrom", recvfromFunc<RiscvLinux64> },
343 { 213,
"readahead" },
345 { 215,
"munmap", munmapFunc<RiscvLinux64> },
346 { 216,
"mremap", mremapFunc<RiscvLinux64> },
348 { 218,
"request_key" },
350 { 220,
"clone", cloneBackwardsFunc<RiscvLinux64> },
351 { 221,
"execve", execveFunc<RiscvLinux64> },
352 { 222,
"mmap", mmapFunc<RiscvLinux64> },
353 { 223,
"fadvise64" },
364 { 234,
"remap_file_pages" },
366 { 236,
"get_mempolicy" },
367 { 237,
"set_mempolicy" },
368 { 238,
"migrate_pages" },
369 { 239,
"move_pages" },
370 { 240,
"tgsigqueueinfo" },
371 { 241,
"perf_event_open" },
374 { 260,
"wait4", wait4Func<RiscvLinux64> },
375 { 261,
"prlimit64", prlimitFunc<RiscvLinux64> },
376 { 262,
"fanotify_init" },
377 { 263,
"fanotify_mark" },
378 { 264,
"name_to_handle_at" },
379 { 265,
"open_by_handle_at" },
380 { 266,
"clock_adjtime" },
384 { 270,
"process_vm_ready" },
385 { 271,
"process_vm_writev" },
387 { 273,
"finit_module" },
388 { 274,
"sched_setattr" },
389 { 275,
"sched_getattr" },
390 { 276,
"renameat2" },
392 { 278,
"getrandom", getrandomFunc<RiscvLinux64> },
393 { 279,
"memfd_create" },
396 { 282,
"userfaultid" },
397 { 283,
"membarrier" },
399 { 285,
"copy_file_range" },
402 { 1024,
"open", openFunc<RiscvLinux64> },
406 { 1028,
"chmod", chmodFunc<RiscvLinux64> },
413 { 1035,
"readlink", readlinkFunc<RiscvLinux64> },
415 { 1037,
"utimes", utimesFunc<RiscvLinux64> },
416 { 1038,
"stat", stat64Func<RiscvLinux64> },
417 { 1039,
"lstat", lstat64Func<RiscvLinux64> },
420 { 1042,
"epoll_create" },
421 { 1043,
"inotifiy_init" },
422 { 1044,
"eventfd", eventfdFunc<RiscvLinux64> },
423 { 1045,
"signalfd" },
424 { 1046,
"sendfile" },
427 { 1049,
"stat", stat64Func<RiscvLinux64> },
428 { 1050,
"lstat", lstat64Func<RiscvLinux64> },
429 { 1051,
"fstat", fstat64Func<RiscvLinux64> },
431 { 1053,
"fadvise64" },
432 { 1054,
"newfstatat", newfstatatFunc<RiscvLinux64> },
433 { 1055,
"fstatfs", fstatfsFunc<RiscvLinux64> },
434 { 1056,
"statfs", statfsFunc<RiscvLinux64> },
436 { 1058,
"mmap", mmapFunc<RiscvLinux64> },
440 { 1062,
"time", timeFunc<RiscvLinux64> },
443 #if defined(SYS_getdents)
444 { 1065,
"getdents", getdentsFunc },
446 { 1065,
"getdents" },
448 { 1066,
"futimesat" },
449 { 1067,
"select", selectFunc<RiscvLinux64> },
450 { 1068,
"poll", pollFunc<RiscvLinux64> },
451 { 1069,
"epoll_wait" },
454 { 1072,
"oldwait4" },
462 { 2011,
"getmainvars" }
470 { 4,
"io_getevents" },
478 { 12,
"llistxattr" },
479 { 13,
"flistxattr" },
480 { 14,
"removexattr" },
481 { 15,
"lremovexattr" },
482 { 16,
"fremovexattr" },
484 { 18,
"lookup_dcookie" },
486 { 20,
"epoll_create1" },
488 { 22,
"epoll_pwait" },
492 { 26,
"inotify_init1" },
493 { 27,
"inotify_add_watch" },
494 { 28,
"inotify_rm_watch" },
495 { 29,
"ioctl", ioctlFunc<RiscvLinux32> },
496 { 30,
"ioprio_get" },
497 { 31,
"ioprio_set" },
499 { 33,
"mknodat", mknodatFunc<RiscvLinux32> },
500 { 34,
"mkdirat", mkdiratFunc<RiscvLinux32> },
501 { 35,
"unlinkat", unlinkatFunc<RiscvLinux32> },
504 { 38,
"renameat", renameatFunc<RiscvLinux32> },
507 { 41,
"pivot_root" },
508 { 42,
"nfsservctl" },
509 { 43,
"statfs", statfsFunc<RiscvLinux32> },
510 { 44,
"fstatfs", fstatfsFunc<RiscvLinux32> },
511 { 45,
"truncate", truncateFunc<RiscvLinux32> },
512 { 46,
"ftruncate", ftruncateFunc<RiscvLinux32> },
513 { 47,
"fallocate", fallocateFunc<RiscvLinux32> },
514 { 48,
"faccessat", faccessatFunc<RiscvLinux32> },
518 { 52,
"fchmod", fchmodFunc<RiscvLinux32> },
522 { 56,
"openat", openatFunc<RiscvLinux32> },
527 #if defined(SYS_getdents64)
528 { 61,
"getdents64", getdents64Func },
530 { 61,
"getdents64" },
533 { 63,
"read", readFunc<RiscvLinux32> },
534 { 64,
"write", writeFunc<RiscvLinux32> },
535 { 66,
"writev", writevFunc<RiscvLinux32> },
536 { 67,
"pread64", pread64Func<RiscvLinux32> },
537 { 68,
"pwrite64", pwrite64Func<RiscvLinux32> },
543 { 74,
"signalfd64" },
547 { 78,
"readlinkat", readlinkatFunc<RiscvLinux32> },
549 { 80,
"fstat", fstatFunc<RiscvLinux32> },
553 { 84,
"sync_file_range2" },
554 { 85,
"timerfd_create" },
555 { 86,
"timerfd_settime" },
556 { 87,
"timerfd_gettime" },
561 { 92,
"personality" },
567 { 98,
"futex", futexFunc<RiscvLinux32> },
570 { 101,
"nanosleep" },
571 { 102,
"getitimer" },
572 { 103,
"setitimer" },
573 { 104,
"kexec_load" },
574 { 105,
"init_module" },
575 { 106,
"delete_module" },
576 { 107,
"timer_create" },
577 { 108,
"timer_gettime" },
578 { 109,
"timer_getoverrun" },
579 { 110,
"timer_settime" },
580 { 111,
"timer_delete" },
581 { 112,
"clock_settime" },
582 { 113,
"clock_gettime", clock_gettimeFunc<RiscvLinux32> },
583 { 114,
"clock_getres", clock_getresFunc<RiscvLinux32> },
584 { 115,
"clock_nanosleep" },
587 { 118,
"sched_setparam" },
588 { 119,
"sched_setscheduler" },
589 { 120,
"sched_getscheduler" },
590 { 121,
"sched_getparam" },
591 { 122,
"sched_setaffinity" },
592 { 123,
"sched_getaffinity", schedGetaffinityFunc<RiscvLinux32> },
594 { 125,
"sched_get_priority_max" },
595 { 126,
"sched_get_priority_min" },
596 { 127,
"scheD_rr_get_interval" },
597 { 128,
"restart_syscall" },
600 { 131,
"tgkill", tgkillFunc<RiscvLinux32> },
601 { 132,
"sigaltstack" },
609 { 140,
"setpriority" },
610 { 141,
"getpriority" },
616 { 147,
"setresuid" },
617 { 148,
"getresuid" },
618 { 149,
"getresgid" },
619 { 150,
"getresgid" },
622 { 153,
"times", timesFunc<RiscvLinux32> },
627 { 158,
"getgroups" },
628 { 159,
"setgroups" },
630 { 161,
"sethostname" },
631 { 162,
"setdomainname" },
632 { 163,
"getrlimit", getrlimitFunc<RiscvLinux32> },
634 { 165,
"getrusage", getrusageFunc<RiscvLinux32> },
638 { 169,
"gettimeofday", gettimeofdayFunc<RiscvLinux32> },
639 { 170,
"settimeofday" },
648 { 179,
"sysinfo", sysinfoFunc<RiscvLinux32> },
650 { 181,
"mq_unlink" },
651 { 182,
"mq_timedsend" },
652 { 183,
"mq_timedrecieve" },
653 { 184,
"mq_notify" },
654 { 185,
"mq_getsetattr" },
661 { 192,
"semtimedop" },
667 { 198,
"socket", socketFunc<RiscvLinux32> },
668 { 199,
"socketpair", socketpairFunc<RiscvLinux32> },
671 { 202,
"accept", acceptFunc<RiscvLinux32> },
675 { 206,
"sendto", sendtoFunc<RiscvLinux32> },
676 { 207,
"recvfrom", recvfromFunc<RiscvLinux32> },
682 { 213,
"readahead" },
684 { 215,
"munmap", munmapFunc<RiscvLinux32> },
685 { 216,
"mremap", mremapFunc<RiscvLinux32> },
687 { 218,
"request_key" },
689 { 220,
"clone", cloneBackwardsFunc<RiscvLinux32> },
690 { 221,
"execve", execveFunc<RiscvLinux32> },
691 { 222,
"mmap", mmapFunc<RiscvLinux32> },
692 { 223,
"fadvise64" },
703 { 234,
"remap_file_pages" },
705 { 236,
"get_mempolicy" },
706 { 237,
"set_mempolicy" },
707 { 238,
"migrate_pages" },
708 { 239,
"move_pages" },
709 { 240,
"tgsigqueueinfo" },
710 { 241,
"perf_event_open" },
713 { 260,
"wait4", wait4Func<RiscvLinux32> },
714 { 261,
"prlimit64", prlimitFunc<RiscvLinux32> },
715 { 262,
"fanotify_init" },
716 { 263,
"fanotify_mark" },
717 { 264,
"name_to_handle_at" },
718 { 265,
"open_by_handle_at" },
719 { 266,
"clock_adjtime" },
723 { 270,
"process_vm_ready" },
724 { 271,
"process_vm_writev" },
726 { 273,
"finit_module" },
727 { 274,
"sched_setattr" },
728 { 275,
"sched_getattr" },
729 { 276,
"renameat2" },
731 { 278,
"getrandom", getrandomFunc<RiscvLinux32> },
732 { 279,
"memfd_create" },
735 { 282,
"userfaultid" },
736 { 283,
"membarrier" },
738 { 285,
"copy_file_range" },
741 { 1024,
"open", openFunc<RiscvLinux32> },
745 { 1028,
"chmod", chmodFunc<RiscvLinux32> },
752 { 1035,
"readlink", readlinkFunc<RiscvLinux32> },
754 { 1037,
"utimes", utimesFunc<RiscvLinux32> },
755 { 1038,
"stat", statFunc<RiscvLinux32> },
756 { 1039,
"lstat", lstatFunc<RiscvLinux32> },
759 { 1042,
"epoll_create" },
760 { 1043,
"inotifiy_init" },
761 { 1044,
"eventfd", eventfdFunc<RiscvLinux32> },
762 { 1045,
"signalfd" },
763 { 1046,
"sendfile" },
764 { 1047,
"ftruncate", ftruncateFunc<RiscvLinux32> },
765 { 1048,
"truncate", truncateFunc<RiscvLinux32> },
766 { 1049,
"stat", statFunc<RiscvLinux32> },
767 { 1050,
"lstat", lstatFunc<RiscvLinux32> },
768 { 1051,
"fstat", fstatFunc<RiscvLinux32> },
770 { 1053,
"fadvise64" },
771 { 1054,
"newfstatat", newfstatatFunc<RiscvLinux32> },
772 { 1055,
"fstatfs", fstatfsFunc<RiscvLinux32> },
773 { 1056,
"statfs", statfsFunc<RiscvLinux32> },
775 { 1058,
"mmap", mmapFunc<RiscvLinux32> },
779 { 1062,
"time", timeFunc<RiscvLinux32> },
782 #if defined(SYS_getdents)
783 { 1065,
"getdents", getdentsFunc },
785 { 1065,
"getdents" },
787 { 1066,
"futimesat" },
788 { 1067,
"select", selectFunc<RiscvLinux32> },
789 { 1068,
"poll", pollFunc<RiscvLinux32> },
790 { 1069,
"epoll_wait" },
793 { 1072,
"oldwait4" },
801 { 2011,
"getmainvars" }