[llvm-commits] [compiler-rt] r158452 - in /compiler-rt/trunk/lib: asan/asan_internal.h asan/asan_linux.cc asan/asan_mac.cc asan/asan_rtl.cc asan/asan_win.cc sanitizer_common/sanitizer_common.h sanitizer_common/sanitizer_posix.cc sanitizer_common/sanitizer_win.cc
Alexey Samsonov
samsonov at google.com
Thu Jun 14 07:42:59 PDT 2012
Author: samsonov
Date: Thu Jun 14 09:42:58 2012
New Revision: 158452
URL: http://llvm.org/viewvc/llvm-project?rev=158452&view=rev
Log:
[Sanitizer] move rest of mmap routines to common sanitizer runtime
Modified:
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_linux.cc
compiler-rt/trunk/lib/asan/asan_mac.cc
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/asan_win.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=158452&r1=158451&r2=158452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Thu Jun 14 09:42:58 2012
@@ -124,10 +124,6 @@
bool AsanShadowRangeIsAvailable();
void AsanDumpProcessMap();
-void *AsanMmapFixedNoReserve(uptr fixed_addr, uptr size);
-void *AsanMmapFixedReserve(uptr fixed_addr, uptr size);
-void *AsanMprotect(uptr fixed_addr, uptr size);
-
void AsanDisableCoreDumper();
void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp);
Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=158452&r1=158451&r2=158452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_linux.cc Thu Jun 14 09:42:58 2012
@@ -72,20 +72,6 @@
return signum == SIGSEGV && FLAG_handle_segv;
}
-void *AsanMmapFixedNoReserve(uptr fixed_addr, uptr size) {
- return internal_mmap((void*)fixed_addr, size,
- PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
- 0, 0);
-}
-
-void *AsanMprotect(uptr fixed_addr, uptr size) {
- return internal_mmap((void*)fixed_addr, size,
- PROT_NONE,
- MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
- 0, 0);
-}
-
AsanLock::AsanLock(LinkerInitialized) {
// We assume that pthread_mutex_t initialized to all zeroes is a valid
// unlocked mutex. We can not use PTHREAD_MUTEX_INITIALIZER as it triggers
Modified: compiler-rt/trunk/lib/asan/asan_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=158452&r1=158451&r2=158452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Thu Jun 14 09:42:58 2012
@@ -97,20 +97,6 @@
return (signum == SIGSEGV || signum == SIGBUS) && FLAG_handle_segv;
}
-void *AsanMmapFixedNoReserve(uptr fixed_addr, uptr size) {
- return internal_mmap((void*)fixed_addr, size,
- PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
- 0, 0);
-}
-
-void *AsanMprotect(uptr fixed_addr, uptr size) {
- return internal_mmap((void*)fixed_addr, size,
- PROT_NONE,
- MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
- 0, 0);
-}
-
AsanLock::AsanLock(LinkerInitialized) {
// We assume that OS_SPINLOCK_INIT is zero
}
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=158452&r1=158451&r2=158452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu Jun 14 09:42:58 2012
@@ -127,7 +127,7 @@
CHECK((beg % kPageSize) == 0);
CHECK(((end + 1) % kPageSize) == 0);
uptr size = end - beg + 1;
- void *res = AsanMmapFixedNoReserve(beg, size);
+ void *res = MmapFixedNoReserve(beg, size);
CHECK(res == (void*)beg && "ReserveShadowMemoryRange failed");
}
@@ -547,7 +547,7 @@
// mmap the high shadow.
ReserveShadowMemoryRange(kHighShadowBeg, kHighShadowEnd);
// protect the gap
- void *prot = AsanMprotect(kShadowGapBeg, kShadowGapEnd - kShadowGapBeg + 1);
+ void *prot = Mprotect(kShadowGapBeg, kShadowGapEnd - kShadowGapBeg + 1);
CHECK(prot == (void*)kShadowGapBeg);
} else {
Report("Shadow memory range interleaves with an existing memory mapping. "
Modified: compiler-rt/trunk/lib/asan/asan_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=158452&r1=158451&r2=158452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Thu Jun 14 09:42:58 2012
@@ -30,17 +30,6 @@
namespace __asan {
-// ---------------------- Memory management ---------------- {{{1
-void *AsanMmapFixedNoReserve(uptr fixed_addr, uptr size) {
- return VirtualAlloc((LPVOID)fixed_addr, size,
- MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
-}
-
-void *AsanMprotect(uptr fixed_addr, uptr size) {
- return VirtualAlloc((LPVOID)fixed_addr, size,
- MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS);
-}
-
// ---------------------- Stacktraces, symbols, etc. ---------------- {{{1
static AsanLock dbghelp_lock(LINKER_INITIALIZED);
static bool dbghelp_initialized = false;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=158452&r1=158451&r2=158452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Thu Jun 14 09:42:58 2012
@@ -34,9 +34,14 @@
// Memory management
void *MmapOrDie(uptr size, const char *mem_type);
void UnmapOrDie(void *addr, uptr size);
+void *MmapFixedNoReserve(uptr fixed_addr, uptr size);
+void *Mprotect(uptr fixed_addr, uptr size);
+
+// Internal allocator
void *InternalAlloc(uptr size);
void InternalFree(void *addr);
+// IO
void RawWrite(const char *buffer);
void Printf(const char *format, ...);
int SNPrintf(char *buffer, uptr length, const char *format, ...);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc?rev=158452&r1=158451&r2=158452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Thu Jun 14 09:42:58 2012
@@ -51,6 +51,20 @@
}
}
+void *MmapFixedNoReserve(uptr fixed_addr, uptr size) {
+ return internal_mmap((void*)fixed_addr, size,
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
+ 0, 0);
+}
+
+void *Mprotect(uptr fixed_addr, uptr size) {
+ return internal_mmap((void*)fixed_addr, size,
+ PROT_NONE,
+ MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
+ 0, 0);
+}
+
int internal_sscanf(const char *str, const char *format, ...) {
va_list args;
va_start(args, format);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=158452&r1=158451&r2=158452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Thu Jun 14 09:42:58 2012
@@ -56,6 +56,16 @@
}
}
+void *MmapFixedNoReserve(uptr fixed_addr, uptr size) {
+ return VirtualAlloc((LPVOID)fixed_addr, size,
+ MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+}
+
+void *Mprotect(uptr fixed_addr, uptr size) {
+ return VirtualAlloc((LPVOID)fixed_addr, size,
+ MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS);
+}
+
const char *GetEnv(const char *name) {
static char env_buffer[32767] = {};
More information about the llvm-commits
mailing list