summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-02-20 13:54:32 +0000
committerAlexey Samsonov <samsonov@google.com>2013-02-20 13:54:32 +0000
commitaadd1f2ad65712a974a1c49997c47adb23e3809d (patch)
tree2c7513cacceed399aee8866050cd8cdd533b6081
parent5c3e21ba5534184e95cb20af055b64f4ca1b06e9 (diff)
downloadbcm5719-llvm-aadd1f2ad65712a974a1c49997c47adb23e3809d.tar.gz
bcm5719-llvm-aadd1f2ad65712a974a1c49997c47adb23e3809d.zip
[Sanitizer] use raw syscall instead of _exit() function on Linux
llvm-svn: 175622
-rw-r--r--compiler-rt/lib/asan/asan_report.cc4
-rw-r--r--compiler-rt/lib/asan/asan_rtl.cc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.cc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_libc.h6
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux.cc5
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_mac.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_posix.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_win.cc8
10 files changed, 22 insertions, 16 deletions
diff --git a/compiler-rt/lib/asan/asan_report.cc b/compiler-rt/lib/asan/asan_report.cc
index 32252cbf2e7..8fa42f71400 100644
--- a/compiler-rt/lib/asan/asan_report.cc
+++ b/compiler-rt/lib/asan/asan_report.cc
@@ -435,9 +435,9 @@ class ScopedInErrorReport {
// an error report will finish doing it.
SleepForSeconds(Max(100, flags()->sleep_before_dying + 1));
}
- // If we're still not dead for some reason, use raw Exit() instead of
+ // If we're still not dead for some reason, use raw _exit() instead of
// Die() to bypass any additional checks.
- Exit(flags()->exitcode);
+ internal__exit(flags()->exitcode);
}
ASAN_ON_ERROR();
reporting_thread_tid = asanThreadRegistry().GetCurrentTidOrInvalid();
diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc
index 39b722a9701..ad97c77af99 100644
--- a/compiler-rt/lib/asan/asan_rtl.cc
+++ b/compiler-rt/lib/asan/asan_rtl.cc
@@ -51,7 +51,7 @@ static void AsanDie() {
death_callback();
if (flags()->abort_on_error)
Abort();
- Exit(flags()->exitcode);
+ internal__exit(flags()->exitcode);
}
static void AsanCheckFailed(const char *file, int line, const char *cond,
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
index 8f95d2b64a2..0518f415f27 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
@@ -45,7 +45,7 @@ void NORETURN Die() {
if (DieCallback) {
DieCallback();
}
- Exit(1);
+ internal__exit(1);
}
static CheckFailedCallbackType CheckFailedCallback;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 7816306aff1..fafef40cdfc 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -140,7 +140,6 @@ void SortArray(uptr *array, uptr size);
// Exit
void NORETURN Abort();
-void NORETURN Exit(int exitcode);
void NORETURN Die();
void NORETURN SANITIZER_INTERFACE_ATTRIBUTE
CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
index 6bdca3c9b16..d4e954c263c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
@@ -45,6 +45,7 @@ char *internal_strrchr(const char *s, int c);
char *internal_strstr(const char *haystack, const char *needle);
// Works only for base=10 and doesn't set errno.
s64 internal_simple_strtoll(const char *nptr, char **endptr, int base);
+int internal_snprintf(char *buffer, uptr length, const char *format, ...);
// Return true if all bytes in [mem, mem+size) are zero.
// Optimized for the case when the result is true.
@@ -70,14 +71,15 @@ fd_t internal_open(const char *filename, int flags, u32 mode);
uptr internal_read(fd_t fd, void *buf, uptr count);
uptr internal_write(fd_t fd, const void *buf, uptr count);
+
+// OS
uptr internal_filesize(fd_t fd); // -1 on error.
int internal_stat(const char *path, void *buf);
int internal_lstat(const char *path, void *buf);
int internal_fstat(fd_t fd, void *buf);
-
int internal_dup2(int oldfd, int newfd);
uptr internal_readlink(const char *path, char *buf, uptr bufsize);
-int internal_snprintf(char *buffer, uptr length, const char *format, ...);
+void NORETURN internal__exit(int exitcode);
// Threading
int internal_sched_yield();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
index 1f3d68e9ab0..11cec22f998 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
@@ -140,6 +140,11 @@ int internal_sched_yield() {
return syscall(__NR_sched_yield);
}
+void internal__exit(int exitcode) {
+ syscall(__NR_exit_group, exitcode);
+ Die(); // Unreachable.
+}
+
// ----------------- sanitizer_common.h
bool FileExists(const char *filename) {
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
index 2c5bd52b231..7851721f055 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
@@ -106,6 +106,10 @@ int internal_sched_yield() {
return sched_yield();
}
+void internal__exit(int exitcode) {
+ _exit(exitcode);
+}
+
// ----------------- sanitizer_common.h
bool FileExists(const char *filename) {
struct stat st;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
index d07202569d8..001ca75fe0d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
@@ -209,10 +209,6 @@ void SleepForMillis(int millis) {
usleep(millis * 1000);
}
-void Exit(int exitcode) {
- _exit(exitcode);
-}
-
void Abort() {
abort();
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc
index 4bd3dc8826e..c0688398e93 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc
@@ -99,7 +99,7 @@ bool StartSymbolizerSubprocess(const char *path_to_symbolizer,
for (int fd = getdtablesize(); fd > 2; fd--)
internal_close(fd);
execl(path_to_symbolizer, path_to_symbolizer, (char*)0);
- Exit(1);
+ internal__exit(1);
}
// Continue execution in parent process.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
index 4fe3ece6c4d..40af4e3708f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
@@ -167,10 +167,6 @@ void SleepForMillis(int millis) {
Sleep(millis);
}
-void Exit(int exitcode) {
- _exit(exitcode);
-}
-
void Abort() {
abort();
_exit(-1); // abort is not NORETURN on Windows.
@@ -257,6 +253,10 @@ int internal_sched_yield() {
return 0;
}
+void internal__exit(int exitcode) {
+ _exit(exitcode);
+}
+
// ---------------------- BlockingMutex ---------------- {{{1
const uptr LOCK_UNINITIALIZED = 0;
const uptr LOCK_READY = (uptr)-1;
OpenPOWER on IntegriCloud