[llvm-commits] [compiler-rt] r157991 - in /compiler-rt/trunk/lib/asan: asan_internal.h asan_linux.cc asan_mac.cc asan_posix.cc asan_printf.cc asan_rtl.cc asan_win.cc
Alexey Samsonov
samsonov at google.com
Tue Jun 5 01:48:10 PDT 2012
Author: samsonov
Date: Tue Jun 5 03:48:10 2012
New Revision: 157991
URL: http://llvm.org/viewvc/llvm-project?rev=157991&view=rev
Log:
[ASan] use internal_{close,read,write} in ASan 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_posix.cc
compiler-rt/trunk/lib/asan/asan_printf.cc
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/asan_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=157991&r1=157990&r2=157991&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Tue Jun 5 03:48:10 2012
@@ -169,10 +169,6 @@
void AsanDisableCoreDumper();
void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp);
-uptr AsanRead(int fd, void *buf, uptr count);
-uptr AsanWrite(int fd, const void *buf, uptr count);
-int AsanClose(int fd);
-
bool AsanInterceptsSignal(int signum);
void SetAlternateSignalStack();
void UnsetAlternateSignalStack();
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=157991&r1=157990&r2=157991&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_linux.cc Tue Jun 5 03:48:10 2012
@@ -110,10 +110,6 @@
}
}
-uptr AsanWrite(int fd, const void *buf, uptr count) {
- return (uptr)syscall(__NR_write, fd, buf, count);
-}
-
// Like getenv, but reads env directly from /proc and does not use libc.
// This function should be called first inside __asan_init.
const char* AsanGetEnv(const char* name) {
@@ -142,20 +138,12 @@
return 0; // Not found.
}
-uptr AsanRead(int fd, void *buf, uptr count) {
- return (uptr)syscall(__NR_read, fd, buf, count);
-}
-
-int AsanClose(int fd) {
- return syscall(__NR_close, fd);
-}
-
AsanProcMaps::AsanProcMaps() {
proc_self_maps_buff_len_ =
ReadFileToBuffer("/proc/self/maps", &proc_self_maps_buff_,
&proc_self_maps_buff_mmaped_size_, 1 << 26);
CHECK(proc_self_maps_buff_len_ > 0);
- // AsanWrite(2, proc_self_maps_buff_, proc_self_maps_buff_len_);
+ // internal_write(2, proc_self_maps_buff_, proc_self_maps_buff_len_);
Reset();
}
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=157991&r1=157990&r2=157991&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Tue Jun 5 03:48:10 2012
@@ -100,10 +100,6 @@
return (signum == SIGSEGV || signum == SIGBUS) && FLAG_handle_segv;
}
-size_t AsanWrite(int fd, const void *buf, size_t count) {
- return write(fd, buf, count);
-}
-
void *AsanMmapSomewhereOrDie(size_t size, const char *mem_type) {
size = RoundUpTo(size, kPageSize);
void *res = internal_mmap(0, size,
@@ -158,14 +154,6 @@
return 0;
}
-size_t AsanRead(int fd, void *buf, size_t count) {
- return read(fd, buf, count);
-}
-
-int AsanClose(int fd) {
- return close(fd);
-}
-
AsanProcMaps::AsanProcMaps() {
Reset();
}
Modified: compiler-rt/trunk/lib/asan/asan_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=157991&r1=157990&r2=157991&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Tue Jun 5 03:48:10 2012
@@ -19,6 +19,7 @@
#include "asan_procmaps.h"
#include "asan_stack.h"
#include "asan_thread_registry.h"
+#include "sanitizer_common/sanitizer_libc.h"
#include <pthread.h>
#include <signal.h>
@@ -35,6 +36,8 @@
// since most of the stuff here is inlinable.
#include <algorithm>
+using namespace __sanitizer;
+
static const uptr kAltStackSize = SIGSTKSZ * 4; // SIGSTKSZ is not enough.
namespace __asan {
@@ -82,7 +85,7 @@
static void ASAN_OnSIGSEGV(int, siginfo_t *siginfo, void *context) {
uptr addr = (uptr)siginfo->si_addr;
// Write the first message using the bullet-proof write.
- if (13 != AsanWrite(2, "ASAN:SIGSEGV\n", 13)) AsanDie();
+ if (13 != internal_write(2, "ASAN:SIGSEGV\n", 13)) AsanDie();
uptr pc, sp, bp;
GetPcSpBp(context, &pc, &sp, &bp);
Report("ERROR: AddressSanitizer crashed on unknown address %p"
Modified: compiler-rt/trunk/lib/asan/asan_printf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_printf.cc?rev=157991&r1=157990&r2=157991&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_printf.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_printf.cc Tue Jun 5 03:48:10 2012
@@ -31,8 +31,8 @@
void RawWrite(const char *buffer) {
static const char *kRawWriteError = "RawWrite can't output requested buffer!";
uptr length = (uptr)internal_strlen(buffer);
- if (length != AsanWrite(2, buffer, length)) {
- AsanWrite(2, kRawWriteError, internal_strlen(kRawWriteError));
+ if (length != internal_write(2, buffer, length)) {
+ internal_write(2, kRawWriteError, internal_strlen(kRawWriteError));
AsanDie();
}
if (error_message_buffer) {
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=157991&r1=157990&r2=157991&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Jun 5 03:48:10 2012
@@ -96,14 +96,14 @@
read_len = 0;
bool reached_eof = false;
while (read_len + kPageSize <= size) {
- uptr just_read = AsanRead(fd, *buff + read_len, kPageSize);
+ uptr just_read = internal_read(fd, *buff + read_len, kPageSize);
if (just_read == 0) {
reached_eof = true;
break;
}
read_len += just_read;
}
- AsanClose(fd);
+ internal_close(fd);
if (reached_eof) // We've read the whole file.
break;
}
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=157991&r1=157990&r2=157991&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Tue Jun 5 03:48:10 2012
@@ -53,30 +53,6 @@
CHECK(VirtualFree(addr, size, MEM_DECOMMIT));
}
-// ---------------------- IO ---------------- {{{1
-uptr AsanWrite(int fd, const void *buf, uptr count) {
- if (fd != 2)
- UNIMPLEMENTED();
-
- HANDLE err = GetStdHandle(STD_ERROR_HANDLE);
- if (err == 0)
- return 0; // FIXME: this might not work on some apps.
- DWORD ret;
- if (!WriteFile(err, buf, count, &ret, 0))
- return 0;
- return ret;
-}
-
-// FIXME: Looks like these functions are not needed and are linked in by the
-// code unreachable on Windows. We should clean this up.
-uptr AsanRead(int fd, void *buf, uptr count) {
- UNIMPLEMENTED();
-}
-
-int AsanClose(int fd) {
- UNIMPLEMENTED();
-}
-
// ---------------------- Stacktraces, symbols, etc. ---------------- {{{1
static AsanLock dbghelp_lock(LINKER_INITIALIZED);
static bool dbghelp_initialized = false;
More information about the llvm-commits
mailing list