sim, arm: implement more of the at variety syscalls
authorAli Saidi <Ali.Saidi@ARM.com>
Thu, 17 Apr 2014 21:55:05 +0000 (16:55 -0500)
committerAli Saidi <Ali.Saidi@ARM.com>
Thu, 17 Apr 2014 21:55:05 +0000 (16:55 -0500)
Needed for new AArch64 binaries

src/arch/arm/linux/process.cc
src/sim/syscall_emul.cc
src/sim/syscall_emul.hh

index 7f8f9ccd6ba8df8b963e60b5c17f4c06ac85583f..faa39fd3419650eab94b768801fef9f0dacbfd3e 100644 (file)
@@ -536,7 +536,7 @@ static SyscallDesc syscallDescs64[] = {
     /*   45 */ SyscallDesc("truncate64", unimplementedFunc),
     /*   46 */ SyscallDesc("ftruncate64", ftruncate64Func),
     /*   47 */ SyscallDesc("fallocate", unimplementedFunc),
-    /*   48 */ SyscallDesc("faccessat", unimplementedFunc),
+    /*   48 */ SyscallDesc("faccessat", faccessatFunc<ArmLinux64>),
     /*   49 */ SyscallDesc("chdir", unimplementedFunc),
     /*   50 */ SyscallDesc("fchdir", unimplementedFunc),
     /*   51 */ SyscallDesc("chroot", unimplementedFunc),
@@ -566,7 +566,7 @@ static SyscallDesc syscallDescs64[] = {
     /*   75 */ SyscallDesc("vmsplice", unimplementedFunc),
     /*   76 */ SyscallDesc("splice", unimplementedFunc),
     /*   77 */ SyscallDesc("tee", unimplementedFunc),
-    /*   78 */ SyscallDesc("readlinkat", unimplementedFunc),
+    /*   78 */ SyscallDesc("readlinkat", readlinkatFunc<ArmLinux64>),
     /*   79 */ SyscallDesc("fstatat64", fstatat64Func<ArmLinux64>),
     /*   80 */ SyscallDesc("fstat64", fstat64Func<ArmLinux64>),
     /*   81 */ SyscallDesc("sync", unimplementedFunc),
index a860653178fa6f5749b46f27bc8d5a24dfc282e2..935193e7f9a0a1b8337892bf3496492eaf353090 100644 (file)
@@ -351,13 +351,20 @@ getcwdFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
     return (result == -1) ? -errno : result;
 }
 
+/// Target open() handler.
+SyscallReturn
+readlinkFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+         ThreadContext *tc)
+{
+    return readlinkFunc(desc, callnum, process, tc, 0);
+}
 
 SyscallReturn
-readlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
+readlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc,
+        int index)
 {
     string path;
 
-    int index = 0;
     if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
         return (TheISA::IntReg)-EFAULT;
 
@@ -852,10 +859,9 @@ cloneFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 }
 
 SyscallReturn
-accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc)
+accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc,
+        int index)
 {
-    int index = 0;
-
     string path;
     if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
         return (TheISA::IntReg)-EFAULT;
@@ -868,3 +874,10 @@ accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc)
     int result = access(path.c_str(), mode);
     return (result == -1) ? -errno : result;
 }
+
+SyscallReturn
+accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc)
+{
+    return accessFunc(desc, callnum, p, tc, 0);
+}
+
index ac01ba1e874c5d424f369616abeb27d068f11523..e971902cba8954b06bf0e66c76f0636ce0bc9f31 100644 (file)
@@ -253,7 +253,10 @@ SyscallReturn gethostnameFunc(SyscallDesc *desc, int num,
 SyscallReturn getcwdFunc(SyscallDesc *desc, int num,
                          LiveProcess *p, ThreadContext *tc);
 
-/// Target unlink() handler.
+/// Target readlink() handler.
+SyscallReturn readlinkFunc(SyscallDesc *desc, int num,
+                           LiveProcess *p, ThreadContext *tc,
+                           int index = 0);
 SyscallReturn readlinkFunc(SyscallDesc *desc, int num,
                            LiveProcess *p, ThreadContext *tc);
 
@@ -350,6 +353,9 @@ SyscallReturn cloneFunc(SyscallDesc *desc, int num,
 /// Target access() handler
 SyscallReturn accessFunc(SyscallDesc *desc, int num,
                                LiveProcess *p, ThreadContext *tc);
+SyscallReturn accessFunc(SyscallDesc *desc, int num,
+                               LiveProcess *p, ThreadContext *tc,
+                               int index);
 
 /// Futex system call
 ///  Implemented by Daniel Sanchez
@@ -696,6 +702,32 @@ openatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     return openFunc<OS>(desc, callnum, process, tc, 1);
 }
 
+/// Target facessat() handler
+template <class OS>
+SyscallReturn
+faccessatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+        ThreadContext *tc)
+{
+    int index = 0;
+    int dirfd = process->getSyscallArg(tc, index);
+    if (dirfd != OS::TGT_AT_FDCWD)
+        warn("faccessat: first argument not AT_FDCWD; unlikely to work");
+    return accessFunc(desc, callnum, process, tc, 1);
+}
+
+/// Target readlinkat() handler
+template <class OS>
+SyscallReturn
+readlinkatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+        ThreadContext *tc)
+{
+    int index = 0;
+    int dirfd = process->getSyscallArg(tc, index);
+    if (dirfd != OS::TGT_AT_FDCWD)
+        warn("openat: first argument not AT_FDCWD; unlikely to work");
+    return readlinkFunc(desc, callnum, process, tc, 1);
+}
+
 /// Target sysinfo() handler.
 template <class OS>
 SyscallReturn