aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-01-06 21:36:08 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-01-06 21:36:08 +0000
commit0f584385a76e20455a5f694bb0b1bb57e00c7fd1 (patch)
tree2b89a59288779a6c899f3f852bad0ef4495344c9
parent0d8e7490d6e8a13a8f0977d9b7771803b9f64ea0 (diff)
downloadsrc-0f584385a76e20455a5f694bb0b1bb57e00c7fd1.tar.gz
src-0f584385a76e20455a5f694bb0b1bb57e00c7fd1.zip
Vendor import of compiler-rt release_60 branch r321788:vendor/compiler-rt/compiler-rt-release_60-r321788
Notes
Notes: svn path=/vendor/compiler-rt/dist-release_60/; revision=327643 svn path=/vendor/compiler-rt/compiler-rt-release_60-r321788/; revision=327644; tag=vendor/compiler-rt/compiler-rt-release_60-r321788
-rwxr-xr-xlib/asan/scripts/asan_device_setup7
-rw-r--r--lib/profile/GCDAProfiling.c14
-rw-r--r--test/profile/Inputs/instrprof-dlopen-dlclose-main.c26
-rw-r--r--test/profile/instrprof-dlopen-dlclose-gcov.test6
-rw-r--r--test/scudo/interface.cpp15
5 files changed, 63 insertions, 5 deletions
diff --git a/lib/asan/scripts/asan_device_setup b/lib/asan/scripts/asan_device_setup
index 92a109727267..ca008c03743e 100755
--- a/lib/asan/scripts/asan_device_setup
+++ b/lib/asan/scripts/asan_device_setup
@@ -336,6 +336,13 @@ exec $_to \$@
EOF
}
+# On Android-L not allowing user segv handler breaks some applications.
+# Since ~May 2017 this is the default setting; included for compatibility with
+# older library versions.
+if [[ PRE_L -eq 0 ]]; then
+ ASAN_OPTIONS="$ASAN_OPTIONS,allow_user_segv_handler=1"
+fi
+
if [[ x$extra_options != x ]] ; then
ASAN_OPTIONS="$ASAN_OPTIONS,$extra_options"
fi
diff --git a/lib/profile/GCDAProfiling.c b/lib/profile/GCDAProfiling.c
index ef299f002e20..bb70ff0cf8f1 100644
--- a/lib/profile/GCDAProfiling.c
+++ b/lib/profile/GCDAProfiling.c
@@ -228,6 +228,7 @@ static void unmap_file() {
* profiling enabled will emit to a different file. Only one file may be
* started at a time.
*/
+COMPILER_RT_VISIBILITY
void llvm_gcda_start_file(const char *orig_filename, const char version[4],
uint32_t checksum) {
const char *mode = "r+b";
@@ -295,6 +296,7 @@ void llvm_gcda_start_file(const char *orig_filename, const char version[4],
/* Given an array of pointers to counters (counters), increment the n-th one,
* where we're also given a pointer to n (predecessor).
*/
+COMPILER_RT_VISIBILITY
void llvm_gcda_increment_indirect_counter(uint32_t *predecessor,
uint64_t **counters) {
uint64_t *counter;
@@ -317,6 +319,7 @@ void llvm_gcda_increment_indirect_counter(uint32_t *predecessor,
#endif
}
+COMPILER_RT_VISIBILITY
void llvm_gcda_emit_function(uint32_t ident, const char *function_name,
uint32_t func_checksum, uint8_t use_extra_checksum,
uint32_t cfg_checksum) {
@@ -343,6 +346,7 @@ void llvm_gcda_emit_function(uint32_t ident, const char *function_name,
write_string(function_name);
}
+COMPILER_RT_VISIBILITY
void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {
uint32_t i;
uint64_t *old_ctrs = NULL;
@@ -394,6 +398,7 @@ void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {
#endif
}
+COMPILER_RT_VISIBILITY
void llvm_gcda_summary_info() {
const uint32_t obj_summary_len = 9; /* Length for gcov compatibility. */
uint32_t i;
@@ -447,6 +452,7 @@ void llvm_gcda_summary_info() {
#endif
}
+COMPILER_RT_VISIBILITY
void llvm_gcda_end_file() {
/* Write out EOF record. */
if (output_file) {
@@ -459,6 +465,7 @@ void llvm_gcda_end_file() {
unmap_file();
}
+ fflush(output_file);
lprofUnlockFd(fd);
fclose(output_file);
output_file = NULL;
@@ -471,6 +478,7 @@ void llvm_gcda_end_file() {
#endif
}
+COMPILER_RT_VISIBILITY
void llvm_register_writeout_function(writeout_fn fn) {
struct writeout_fn_node *new_node = malloc(sizeof(struct writeout_fn_node));
new_node->fn = fn;
@@ -484,6 +492,7 @@ void llvm_register_writeout_function(writeout_fn fn) {
}
}
+COMPILER_RT_VISIBILITY
void llvm_writeout_files(void) {
struct writeout_fn_node *curr = writeout_fn_head;
@@ -493,6 +502,7 @@ void llvm_writeout_files(void) {
}
}
+COMPILER_RT_VISIBILITY
void llvm_delete_writeout_function_list(void) {
while (writeout_fn_head) {
struct writeout_fn_node *node = writeout_fn_head;
@@ -503,6 +513,7 @@ void llvm_delete_writeout_function_list(void) {
writeout_fn_head = writeout_fn_tail = NULL;
}
+COMPILER_RT_VISIBILITY
void llvm_register_flush_function(flush_fn fn) {
struct flush_fn_node *new_node = malloc(sizeof(struct flush_fn_node));
new_node->fn = fn;
@@ -516,6 +527,7 @@ void llvm_register_flush_function(flush_fn fn) {
}
}
+COMPILER_RT_VISIBILITY
void __gcov_flush() {
struct flush_fn_node *curr = flush_fn_head;
@@ -525,6 +537,7 @@ void __gcov_flush() {
}
}
+COMPILER_RT_VISIBILITY
void llvm_delete_flush_function_list(void) {
while (flush_fn_head) {
struct flush_fn_node *node = flush_fn_head;
@@ -535,6 +548,7 @@ void llvm_delete_flush_function_list(void) {
flush_fn_head = flush_fn_tail = NULL;
}
+COMPILER_RT_VISIBILITY
void llvm_gcov_init(writeout_fn wfn, flush_fn ffn) {
static int atexit_ran = 0;
diff --git a/test/profile/Inputs/instrprof-dlopen-dlclose-main.c b/test/profile/Inputs/instrprof-dlopen-dlclose-main.c
new file mode 100644
index 000000000000..fe7eaf0b5e4f
--- /dev/null
+++ b/test/profile/Inputs/instrprof-dlopen-dlclose-main.c
@@ -0,0 +1,26 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[]) {
+ dlerror();
+ void *f1_handle = dlopen("func.shared", RTLD_LAZY | RTLD_GLOBAL);
+ if (f1_handle == NULL) {
+ fprintf(stderr, "unable to open 'func.shared': %s\n", dlerror());
+ return EXIT_FAILURE;
+ }
+
+ void *f2_handle = dlopen("func2.shared", RTLD_LAZY | RTLD_GLOBAL);
+ if (f2_handle == NULL) {
+ fprintf(stderr, "unable to open 'func2.shared': %s\n", dlerror());
+ return EXIT_FAILURE;
+ }
+
+ if (dlclose(f2_handle) != 0) {
+ fprintf(stderr, "unable to close 'func2.shared': %s\n", dlerror());
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
diff --git a/test/profile/instrprof-dlopen-dlclose-gcov.test b/test/profile/instrprof-dlopen-dlclose-gcov.test
new file mode 100644
index 000000000000..a785fe32dcb6
--- /dev/null
+++ b/test/profile/instrprof-dlopen-dlclose-gcov.test
@@ -0,0 +1,6 @@
+RUN: mkdir -p %t.d
+RUN: %clang --coverage -o %t.d/func.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func.c
+RUN: %clang --coverage -o %t.d/func2.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func2.c
+RUN: %clang --coverage -o %t -fPIC -rpath %t.d %S/Inputs/instrprof-dlopen-dlclose-main.c
+
+RUN: %run %t
diff --git a/test/scudo/interface.cpp b/test/scudo/interface.cpp
index 73ea0a738e43..ec7375193e12 100644
--- a/test/scudo/interface.cpp
+++ b/test/scudo/interface.cpp
@@ -4,7 +4,6 @@
// RUN: %run %t heap-size 2>&1
// RUN: %env_scudo_opts="allocator_may_return_null=1" %run %t soft-limit 2>&1
// RUN: %env_scudo_opts="allocator_may_return_null=1" not %run %t hard-limit 2>&1
-// UNSUPPORTED: armhf-linux
// Tests that the sanitizer interface functions behave appropriately.
@@ -51,8 +50,11 @@ int main(int argc, char **argv)
// Verifies that setting the soft RSS limit at runtime works as expected.
std::vector<void *> pointers;
size_t size = 1 << 19; // 512Kb
- for (int i = 0; i < 5; i++)
- pointers.push_back(malloc(size));
+ for (int i = 0; i < 5; i++) {
+ void *p = malloc(size);
+ memset(p, 0, size);
+ pointers.push_back(p);
+ }
// Set the soft RSS limit to 1Mb.
__scudo_set_rss_limit(1, 0);
usleep(20000);
@@ -74,8 +76,11 @@ int main(int argc, char **argv)
// Verifies that setting the hard RSS limit at runtime works as expected.
std::vector<void *> pointers;
size_t size = 1 << 19; // 512Kb
- for (int i = 0; i < 5; i++)
- pointers.push_back(malloc(size));
+ for (int i = 0; i < 5; i++) {
+ void *p = malloc(size);
+ memset(p, 0, size);
+ pointers.push_back(p);
+ }
// Set the hard RSS limit to 1Mb
__scudo_set_rss_limit(1, 1);
usleep(20000);