diff options
author | Jaehun Jeong <jh4u.jeong@samsung.com> | 2018-01-24 09:31:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.ap-northeast-2.compute.internal> | 2018-01-24 09:31:10 +0000 |
commit | 74e971b7cb20e7a9b5e2cb0a47bb10e090926319 (patch) | |
tree | e1f03ce2313381fbf45dcfc622806dbe0d121803 | |
parent | 5ccca94af27d300dbb5c116000044926bae26161 (diff) | |
parent | c3641771bad91e80355e300d11ad879b7b5aebf7 (diff) | |
download | linaro-gcc-74e971b7cb20e7a9b5e2cb0a47bb10e090926319.tar.gz linaro-gcc-74e971b7cb20e7a9b5e2cb0a47bb10e090926319.tar.bz2 linaro-gcc-74e971b7cb20e7a9b5e2cb0a47bb10e090926319.zip |
Merge "[asan_build] Enable asaned glibc work." into tizen_basesubmit/tizen_base/20180124.094033accepted/tizen/base/20180126.040727
-rw-r--r-- | libsanitizer/asan/Makefile.am | 3 | ||||
-rw-r--r-- | libsanitizer/asan/Makefile.in | 3 | ||||
-rw-r--r-- | libsanitizer/asan/asan_linux.cc | 8 | ||||
-rw-r--r-- | libsanitizer/sanitizer_common/sanitizer_linux.cc | 3 | ||||
-rw-r--r-- | packaging/gcc-aarch64.spec | 2 | ||||
-rw-r--r-- | packaging/gcc-armv7l.spec | 2 | ||||
-rw-r--r-- | packaging/linaro-gcc.spec | 2 |
7 files changed, 17 insertions, 6 deletions
diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am index 8b758edeaf8..c04bf4b0400 100644 --- a/libsanitizer/asan/Makefile.am +++ b/libsanitizer/asan/Makefile.am @@ -54,7 +54,8 @@ libasan_la_LIBADD += $(top_builddir)/libbacktrace/libsanitizer_libbacktrace.la endif libasan_la_LIBADD += $(LIBSTDCXX_RAW_CXX_LDFLAGS) -libasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(link_libasan) +libasan_la_LDFLAGS = -Wl,-z,initfirst +libasan_la_LDFLAGS += -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(link_libasan) libasan_preinit.o: asan_preinit.o cp $< $@ diff --git a/libsanitizer/asan/Makefile.in b/libsanitizer/asan/Makefile.in index ed81727992e..5af30c4f971 100644 --- a/libsanitizer/asan/Makefile.in +++ b/libsanitizer/asan/Makefile.in @@ -343,7 +343,8 @@ libasan_la_LIBADD = \ $(top_builddir)/lsan/libsanitizer_lsan.la \ $(top_builddir)/ubsan/libsanitizer_ubsan.la $(am__append_2) \ $(am__append_3) $(LIBSTDCXX_RAW_CXX_LDFLAGS) -libasan_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(link_libasan) +libasan_la_LDFLAGS = -Wl,-z,initfirst -version-info `grep -v '^\#' \ + $(srcdir)/libtool-version` $(link_libasan) # Work around what appears to be a GNU make bug handling MAKEFLAGS # values defined in terms of make variables, as is the case for CC and diff --git a/libsanitizer/asan/asan_linux.cc b/libsanitizer/asan/asan_linux.cc index 9f058df71a5..7533f4566b0 100644 --- a/libsanitizer/asan/asan_linux.cc +++ b/libsanitizer/asan/asan_linux.cc @@ -83,6 +83,8 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { void AsanCheckDynamicRTPrereqs() {} void AsanCheckIncompatibleRT() {} #else + +#ifndef ASAN_INIT_FIRST static int FindFirstDSOCallback(struct dl_phdr_info *info, size_t size, void *data) { // Continue until the first dynamic library is found @@ -96,6 +98,7 @@ static int FindFirstDSOCallback(struct dl_phdr_info *info, size_t size, *(const char **)data = info->dlpi_name; return 1; } +#endif static bool IsDynamicRTName(const char *libname) { return internal_strstr(libname, "libclang_rt.asan") || @@ -111,6 +114,10 @@ void AsanCheckDynamicRTPrereqs() { if (!ASAN_DYNAMIC) return; +// Can not use dl_iterate_phdr before libc is inited. +// Anyway if we have patched rtld we will get libasan.so +// inited early than other libraries. +#ifndef ASAN_INIT_FIRST // Ensure that dynamic RT is the first DSO in the list const char *first_dso_name = nullptr; dl_iterate_phdr(FindFirstDSOCallback, &first_dso_name); @@ -120,6 +127,7 @@ void AsanCheckDynamicRTPrereqs() { "manually preload it with LD_PRELOAD.\n"); Die(); } +#endif } void AsanCheckIncompatibleRT() { diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc index 5d17bf7bd49..769cba7fc66 100644 --- a/libsanitizer/sanitizer_common/sanitizer_linux.cc +++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc @@ -799,7 +799,8 @@ bool ThreadLister::GetDirectoryEntries() { uptr GetPageSize() { // Android post-M sysconf(_SC_PAGESIZE) crashes if called from .preinit_array. -#if SANITIZER_ANDROID +#if SANITIZER_ANDROID || \ + (SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__))) return 4096; #elif SANITIZER_LINUX && (defined(__x86_64__) || defined(__i386__)) return EXEC_PAGESIZE; diff --git a/packaging/gcc-aarch64.spec b/packaging/gcc-aarch64.spec index 4cd7eeea003..ed47e43d6ab 100644 --- a/packaging/gcc-aarch64.spec +++ b/packaging/gcc-aarch64.spec @@ -679,7 +679,7 @@ RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(sse\|fpmath\)[^ ]*//g'` } RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ */ /g'` - +%{?asan: RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS -DASAN_INIT_FIRST) } CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ diff --git a/packaging/gcc-armv7l.spec b/packaging/gcc-armv7l.spec index 81846a50f88..356244850d6 100644 --- a/packaging/gcc-armv7l.spec +++ b/packaging/gcc-armv7l.spec @@ -679,7 +679,7 @@ RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(sse\|fpmath\)[^ ]*//g'` } RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ */ /g'` - +%{?asan: RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS -DASAN_INIT_FIRST) } CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ diff --git a/packaging/linaro-gcc.spec b/packaging/linaro-gcc.spec index 72c9b170de6..31ffa153f0e 100644 --- a/packaging/linaro-gcc.spec +++ b/packaging/linaro-gcc.spec @@ -676,7 +676,7 @@ RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(sse\|fpmath\)[^ ]*//g'` } RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ */ /g'` - +%{?asan: RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS -DASAN_INIT_FIRST) } CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ |