[Mesa-dev] [PATCH shader-db 1/2] intel_stub: Wrap mmap64.

Kenneth Graunke kenneth at whitecape.org
Mon Jun 4 23:26:14 UTC 2018


Otherwise our fake GEM bo mappings don't work.
---
 intel_stub.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/intel_stub.c b/intel_stub.c
index ab046e5..a3316b1 100644
--- a/intel_stub.c
+++ b/intel_stub.c
@@ -39,6 +39,8 @@
 
 static void *(*libc_mmap)(void *addr, size_t len, int prot, int flags,
                           int fildes, off_t off);
+static void *(*libc_mmap64)(void *addr, size_t len, int prot, int flags,
+                            int fildes, off_t off);
 static int (*libc_open)(const char *pathname, int flags, mode_t mode);
 static int (*libc_open64)(const char *pathname, int flags, mode_t mode);
 static int (*libc_close)(int fd);
@@ -208,6 +210,19 @@ mmap(void *addr, size_t len, int prot, int flags,
         }
 }
 
+__attribute__ ((visibility ("default"))) void *
+mmap64(void *addr, size_t len, int prot, int flags,
+       int fildes, off_t off)
+{
+        if (fildes == drm_fd) {
+                return libc_mmap64(NULL, len, prot, flags | MAP_ANONYMOUS,
+                                   -1, 0);
+        } else {
+                return libc_mmap64(addr, len, prot, flags, fildes, off);
+        }
+}
+
+
 __attribute__ ((visibility ("default"))) ssize_t
 readlink(const char *pathname, char *buf, size_t bufsiz)
 {
@@ -305,5 +320,6 @@ init(void)
 	libc__fxstat64 = dlsym(RTLD_NEXT, "__fxstat64");
 	libc_ioctl = dlsym(RTLD_NEXT, "ioctl");
 	libc_mmap = dlsym(RTLD_NEXT, "mmap");
+	libc_mmap64 = dlsym(RTLD_NEXT, "mmap64");
 	libc_readlink = dlsym(RTLD_NEXT, "readlink");
 }
-- 
2.17.0



More information about the mesa-dev mailing list