[Sanitizer] implement readlink as syscall on Linux

llvm-svn: 163213
This commit is contained in:
Alexey Samsonov 2012-09-05 14:48:24 +00:00
parent eb958ded72
commit f6d2125829
5 changed files with 16 additions and 2 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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';

View File

@ -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;