[PATCH] Add FreeBSD support to Asan test cases that use mmap() with MAP_ANON
Viktor Kutuzov
vkutuzov at accesssoftek.com
Thu Jul 17 06:35:50 PDT 2014
Hi kcc, samsonov,
http://reviews.llvm.org/D4561
Files:
test/asan/TestCases/Posix/large_allocator_unpoisons_on_free.cc
test/asan/TestCases/dlclose-test.cc
Index: test/asan/TestCases/Posix/large_allocator_unpoisons_on_free.cc
===================================================================
--- test/asan/TestCases/Posix/large_allocator_unpoisons_on_free.cc
+++ test/asan/TestCases/Posix/large_allocator_unpoisons_on_free.cc
@@ -27,7 +27,14 @@
void *p = my_memalign(kPageSize, 1024 * 1024);
free(p);
- char *q = (char *)mmap(p, kPageSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, 0, 0);
+ // FreeBSD requires fd to be (-1) when MAP_ANON is specified.
+#if defined(__FreeBSD__)
+ const int fd = (-1);
+#else
+ const int fd = 0;
+#endif
+ char *q = (char *)mmap(p, kPageSize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON | MAP_FIXED, fd, 0);
assert(q == p);
memset(q, 42, kPageSize);
Index: test/asan/TestCases/dlclose-test.cc
===================================================================
--- test/asan/TestCases/dlclose-test.cc
+++ test/asan/TestCases/dlclose-test.cc
@@ -62,11 +62,17 @@
printf("failed to dlclose\n");
return 1;
}
+ // FreeBSD requires fd to be (-1) when MAP_ANON is specified.
+#if defined(__FreeBSD__)
+ const int fd = (-1);
+#else
+ const int fd = 0;
+#endif
// Now, the page where 'addr' is unmapped. Map it.
size_t page_beg = ((size_t)addr) & ~(PageSize - 1);
void *res = mmap((void*)(page_beg), PageSize,
PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE, 0, 0);
+ MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE, fd, 0);
if (res == (char*)-1L) {
printf("failed to mmap\n");
return 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4561.11578.patch
Type: text/x-patch
Size: 1652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140717/d8a6a722/attachment.bin>
More information about the llvm-commits
mailing list