summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-09-05 14:48:24 +0000
committerAlexey Samsonov <samsonov@google.com>2012-09-05 14:48:24 +0000
commitf6d2125829760276ac8c686c113d700a3d0a0121 (patch)
treec1ebcb35d80971bb7d87c2c72009b2fbb9c440ea
parenteb958ded72847a6f24d172a7c68b000b1a4a7a25 (diff)
downloadbcm5719-llvm-f6d2125829760276ac8c686c113d700a3d0a0121.tar.gz
bcm5719-llvm-f6d2125829760276ac8c686c113d700a3d0a0121.zip
[Sanitizer] implement readlink as syscall on Linux
llvm-svn: 163213
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_libc.h1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_mac.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_win.cc5
5 files changed, 16 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
index 8c3a78cd519..b1bac7be514 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h
@@ -60,6 +60,7 @@ uptr internal_read(fd_t fd, void *buf, uptr count);
uptr internal_write(fd_t fd, const void *buf, uptr count);
uptr internal_filesize(fd_t fd); // -1 on error.
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, ...);
// Threading
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
index c2f8810eae4..853be7a7303 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
@@ -80,6 +80,10 @@ int internal_dup2(int oldfd, int newfd) {
return syscall(__NR_dup2, oldfd, newfd);
}
+uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
+ return (uptr)syscall(__NR_readlink, path, buf, bufsize);
+}
+
int internal_sched_yield() {
return syscall(__NR_sched_yield);
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
index 986f31ff680..ca55c8ce764 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
@@ -71,6 +71,10 @@ int internal_dup2(int oldfd, int newfd) {
return dup2(oldfd, newfd);
}
+uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
+ return readlink(path, buf, bufsize);
+}
+
int internal_sched_yield() {
return sched_yield();
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc
index e4d3f024cd3..6125cda96aa 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_linux.cc
@@ -125,8 +125,8 @@ static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
module_name.data()[0] = '\0';
if (data->current_n == 0) {
// First module is the binary itself.
- uptr module_name_len = readlink("/proc/self/exe",
- module_name.data(), module_name.size());
+ uptr module_name_len = internal_readlink(
+ "/proc/self/exe", module_name.data(), module_name.size());
CHECK_NE(module_name_len, (uptr)-1);
CHECK_LT(module_name_len, module_name.size());
module_name[module_name_len] = '\0';
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
index f5d3fca1cc8..b2ddd61c615 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
@@ -179,6 +179,11 @@ int internal_dup2(int oldfd, int newfd) {
return 0;
}
+uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
+ UNIMPLEMENTED();
+ return 0;
+}
+
int internal_sched_yield() {
UNIMPLEMENTED();
return 0;
OpenPOWER on IntegriCloud