From df0fcdda2632f56997dd54880cbcba9fd4e25e0c Mon Sep 17 00:00:00 2001 From: "Dongkyun, Son" Date: Fri, 7 Apr 2017 10:27:29 +0900 Subject: [PATCH 01/16] packaging: add license files to all sub components The license files are added to only library components because they could be included to target binary. Change-Id: I7fb9885843794ea47c29833ead402386d890d663 Signed-off-by: Chan Lee Signed-off-by: Dongkyun, Son --- packaging/gcc-aarch64.spec | 23 +++++++++++++++++++++-- packaging/gcc-armv7l.spec | 23 +++++++++++++++++++++-- packaging/linaro-gcc.spec | 23 +++++++++++++++++++++-- 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/packaging/gcc-aarch64.spec b/packaging/gcc-aarch64.spec index 9f92181..26dad99 100644 --- a/packaging/gcc-aarch64.spec +++ b/packaging/gcc-aarch64.spec @@ -226,7 +226,7 @@ operations. %package -n libitm Summary: The GNU Compiler Transactional Memory Runtime Library -License: MIT +License: GPL-3.0-with-GCC-exception Group: Development/Languages %description -n libitm The runtime library needed to run programs compiled with the @@ -491,7 +491,7 @@ operations. %package -n libitm-32bit Summary: The GNU Compiler Transactional Memory Runtime Library -License: MIT +License: GPL-3.0-with-GCC-exception Group: Development/Languages %description -n libitm-32bit The runtime library needed to run programs compiled with the @@ -1035,6 +1035,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libstdc++ %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libstdc++.so.* @@ -1048,11 +1049,13 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libgcc %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libgcc_s.so.* %files -n libgomp %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libgomp.so.* @@ -1064,6 +1067,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %asan_arch %files -n libasan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libasan.so* %endif @@ -1071,6 +1075,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %lsan_arch %files -n liblsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/liblsan.so* %endif @@ -1078,6 +1083,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %tsan_arch %files -n libtsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libtsan.so* %endif @@ -1085,6 +1091,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %atomic_arch %files -n libatomic %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libatomic.so.* %endif @@ -1092,6 +1099,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %itm_arch %files -n libitm %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libitm.so.* %endif @@ -1106,6 +1114,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %ubsan_arch %files -n libubsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libubsan.so.* %endif @@ -1113,6 +1122,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %quadmath_arch %files -n libquadmath %manifest gcc.manifest +%license COPYING.LIB %defattr(-,root,root) %{libdir}/libquadmath.so.* %endif @@ -1146,6 +1156,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %asan_arch %files -n libasan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/libasan.so.* %endif @@ -1153,6 +1164,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %lsan_arch %files -n liblsan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/liblsan.so.* %endif @@ -1160,6 +1172,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %atomic_arch %files -n libatomic-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libatomic.so.* %endif @@ -1172,22 +1185,26 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libgcc-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libgcc_s.so.* %files -n libgomp-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libgomp.so.* %ifarch %itm_arch %files -n libitm-32bit +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libitm.so.* %endif %ifarch %quadmath_arch %files -n libquadmath-32bit +%license COPYING.LIB %defattr(-,root,root) %{libsubdir}/32/libquadmath.so.* %endif @@ -1195,12 +1212,14 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %ubsan_arch %files -n libubsan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/libubsan.so.* %endif %files -n libstdc++-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libstdc++.so.* %exclude %{libsubdir}/32/libstdc++.so.*-gdb.py diff --git a/packaging/gcc-armv7l.spec b/packaging/gcc-armv7l.spec index a7ed617..7a1c5a6 100644 --- a/packaging/gcc-armv7l.spec +++ b/packaging/gcc-armv7l.spec @@ -226,7 +226,7 @@ operations. %package -n libitm Summary: The GNU Compiler Transactional Memory Runtime Library -License: MIT +License: GPL-3.0-with-GCC-exception Group: Development/Languages %description -n libitm The runtime library needed to run programs compiled with the @@ -491,7 +491,7 @@ operations. %package -n libitm-32bit Summary: The GNU Compiler Transactional Memory Runtime Library -License: MIT +License: GPL-3.0-with-GCC-exception Group: Development/Languages %description -n libitm-32bit The runtime library needed to run programs compiled with the @@ -1035,6 +1035,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libstdc++ %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libstdc++.so.* @@ -1048,11 +1049,13 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libgcc %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libgcc_s.so.* %files -n libgomp %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libgomp.so.* @@ -1064,6 +1067,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %asan_arch %files -n libasan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libasan.so* %endif @@ -1071,6 +1075,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %lsan_arch %files -n liblsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/liblsan.so* %endif @@ -1078,6 +1083,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %tsan_arch %files -n libtsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libtsan.so* %endif @@ -1085,6 +1091,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %atomic_arch %files -n libatomic %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libatomic.so.* %endif @@ -1092,6 +1099,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %itm_arch %files -n libitm %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libitm.so.* %endif @@ -1106,6 +1114,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %ubsan_arch %files -n libubsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libubsan.so.* %endif @@ -1113,6 +1122,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %quadmath_arch %files -n libquadmath %manifest gcc.manifest +%license COPYING.LIB %defattr(-,root,root) %{libdir}/libquadmath.so.* %endif @@ -1146,6 +1156,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %asan_arch %files -n libasan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/libasan.so.* %endif @@ -1153,6 +1164,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %lsan_arch %files -n liblsan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/liblsan.so.* %endif @@ -1160,6 +1172,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %atomic_arch %files -n libatomic-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libatomic.so.* %endif @@ -1172,22 +1185,26 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libgcc-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libgcc_s.so.* %files -n libgomp-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libgomp.so.* %ifarch %itm_arch %files -n libitm-32bit +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libitm.so.* %endif %ifarch %quadmath_arch %files -n libquadmath-32bit +%license COPYING.LIB %defattr(-,root,root) %{libsubdir}/32/libquadmath.so.* %endif @@ -1195,12 +1212,14 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %ubsan_arch %files -n libubsan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/libubsan.so.* %endif %files -n libstdc++-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libstdc++.so.* %exclude %{libsubdir}/32/libstdc++.so.*-gdb.py diff --git a/packaging/linaro-gcc.spec b/packaging/linaro-gcc.spec index 90f40ad..bd380f1 100644 --- a/packaging/linaro-gcc.spec +++ b/packaging/linaro-gcc.spec @@ -223,7 +223,7 @@ operations. %package -n libitm Summary: The GNU Compiler Transactional Memory Runtime Library -License: MIT +License: GPL-3.0-with-GCC-exception Group: Development/Languages %description -n libitm The runtime library needed to run programs compiled with the @@ -488,7 +488,7 @@ operations. %package -n libitm-32bit Summary: The GNU Compiler Transactional Memory Runtime Library -License: MIT +License: GPL-3.0-with-GCC-exception Group: Development/Languages %description -n libitm-32bit The runtime library needed to run programs compiled with the @@ -1032,6 +1032,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libstdc++ %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libstdc++.so.* @@ -1045,11 +1046,13 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libgcc %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libgcc_s.so.* %files -n libgomp %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libgomp.so.* @@ -1061,6 +1064,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %asan_arch %files -n libasan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libasan.so* %endif @@ -1068,6 +1072,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %lsan_arch %files -n liblsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/liblsan.so* %endif @@ -1075,6 +1080,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %tsan_arch %files -n libtsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libtsan.so* %endif @@ -1082,6 +1088,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %atomic_arch %files -n libatomic %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libatomic.so.* %endif @@ -1089,6 +1096,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %itm_arch %files -n libitm %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libdir}/libitm.so.* %endif @@ -1103,6 +1111,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %ubsan_arch %files -n libubsan %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libdir}/libubsan.so.* %endif @@ -1110,6 +1119,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %quadmath_arch %files -n libquadmath %manifest gcc.manifest +%license COPYING.LIB %defattr(-,root,root) %{libdir}/libquadmath.so.* %endif @@ -1143,6 +1153,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %asan_arch %files -n libasan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/libasan.so.* %endif @@ -1150,6 +1161,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %lsan_arch %files -n liblsan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/liblsan.so.* %endif @@ -1157,6 +1169,7 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %atomic_arch %files -n libatomic-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libatomic.so.* %endif @@ -1169,22 +1182,26 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %files -n libgcc-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libgcc_s.so.* %files -n libgomp-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libgomp.so.* %ifarch %itm_arch %files -n libitm-32bit +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libitm.so.* %endif %ifarch %quadmath_arch %files -n libquadmath-32bit +%license COPYING.LIB %defattr(-,root,root) %{libsubdir}/32/libquadmath.so.* %endif @@ -1192,12 +1209,14 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %ifarch %ubsan_arch %files -n libubsan-32bit %manifest gcc.manifest +%license libsanitizer/LICENSE.TXT %defattr(-,root,root) %{libsubdir}/32/libubsan.so.* %endif %files -n libstdc++-32bit %manifest gcc.manifest +%license COPYING3 COPYING.RUNTIME %defattr(-,root,root) %{libsubdir}/32/libstdc++.so.* %exclude %{libsubdir}/32/libstdc++.so.*-gdb.py -- 2.7.4 From a0c5e7cc3d72cdc5c35236bf812d4fd3ecd3010c Mon Sep 17 00:00:00 2001 From: "Dongkyun, Son" Date: Thu, 6 Apr 2017 19:03:50 +0900 Subject: [PATCH 02/16] Keep to use version 6.2.1 This is for the Tizen version policy (First released to 6.2.1 20161213) Change-Id: I6aa5d673c922401eff605448fe4ab6b3512ccd71 Signed-off-by: Dongkyun, Son --- gcc/BASE-VER | 2 +- gcc/DATESTAMP | 2 +- gcc/LINARO-VERSION | 2 +- packaging/gcc-aarch64.spec | 2 +- packaging/gcc-armv7l.spec | 2 +- packaging/linaro-gcc.spec | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/BASE-VER b/gcc/BASE-VER index dc0208a..024b066 100644 --- a/gcc/BASE-VER +++ b/gcc/BASE-VER @@ -1 +1 @@ -6.3.1 +6.2.1 diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index ee1e9c3..10c7a04 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20170206 +20161213 diff --git a/gcc/LINARO-VERSION b/gcc/LINARO-VERSION index b75db8f..e289be5 100644 --- a/gcc/LINARO-VERSION +++ b/gcc/LINARO-VERSION @@ -1 +1 @@ -Snapshot 6.3-2017.02 +Snapshot 6.2-2016.12 diff --git a/packaging/gcc-aarch64.spec b/packaging/gcc-aarch64.spec index 26dad99..a2607ef 100644 --- a/packaging/gcc-aarch64.spec +++ b/packaging/gcc-aarch64.spec @@ -75,7 +75,7 @@ BuildRequires: expect BuildRequires: gdb %endif URL: http://gcc.gnu.org/ -Version: 6.3.1 +Version: 6.2.1 Release: 0 Source: gcc-%{version}.tar.bz2 Source10: gmp-6.1.1.tar.bz2 diff --git a/packaging/gcc-armv7l.spec b/packaging/gcc-armv7l.spec index 7a1c5a6..ea57dd8 100644 --- a/packaging/gcc-armv7l.spec +++ b/packaging/gcc-armv7l.spec @@ -75,7 +75,7 @@ BuildRequires: expect BuildRequires: gdb %endif URL: http://gcc.gnu.org/ -Version: 6.3.1 +Version: 6.2.1 Release: 0 Source: gcc-%{version}.tar.bz2 Source10: gmp-6.1.1.tar.bz2 diff --git a/packaging/linaro-gcc.spec b/packaging/linaro-gcc.spec index bd380f1..a81bbe4 100644 --- a/packaging/linaro-gcc.spec +++ b/packaging/linaro-gcc.spec @@ -72,7 +72,7 @@ BuildRequires: expect BuildRequires: gdb %endif URL: http://gcc.gnu.org/ -Version: 6.3.1 +Version: 6.2.1 Release: 0 Source: gcc-%{version}.tar.bz2 Source10: gmp-6.1.1.tar.bz2 -- 2.7.4 From aa456f6090612d2b9bed6d79f71ca351937d9d02 Mon Sep 17 00:00:00 2001 From: Slava Barinov Date: Fri, 7 Apr 2017 13:06:58 +0300 Subject: [PATCH 03/16] Remove hard-coded path to extract-ubsan-logs script Change-Id: Id515f89e748fbe9a18f5a615e100eb530a0c5930 Signed-off-by: Slava Barinov --- packaging/macros.ubsan | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/macros.ubsan b/packaging/macros.ubsan index f1f0fec..652a49b 100644 --- a/packaging/macros.ubsan +++ b/packaging/macros.ubsan @@ -2,7 +2,7 @@ %_enable_ubsan_packages 1 -%__ubsan_install_post /usr/lib/rpm/tizen/extract-ubsan-logs +%__ubsan_install_post %{_rpmconfigdir}/tizen/extract-ubsan-logs # See original macro (before expansion) and correct lines after the first one. # Mine is from Fedora RPM macros, YMMV. -- 2.7.4 From 0e367b9938841ef0a7789d6d7ce70de2145e73da Mon Sep 17 00:00:00 2001 From: Denis Khalikov Date: Wed, 26 Apr 2017 18:27:29 +0300 Subject: [PATCH 04/16] commit 6fdba17a20fd7c5f31f39556dc511abe3a537204 Author: Maxim Ostapenko Date: Fri Oct 28 06:49:53 2016 +0000 [asan/lsan] Avoid possible deadlock in dynamic ASan runtime thread initialization. There is possible deadlock in dynamic ASan runtime when we dlopen() shared lib which creates a thread at the global initialization stage. The scenario: 1) dlopen grabs a GI_pthread_mutex_lock in main thread. 2) main thread calls pthread_create, ASan intercepts it, calls real pthread_create and waits for the second thread to be "fully initialized". 3) Newly created thread tries to access a thread local disable_counter in LSan (to complete its "full initialization") and hangs in tls_get_addr_tail, because it also tries to acquire GI_pthread_mutex_lock. The issue is reproducible on relative recent Glibc versions e.g. 2.23. Differential Revision: https://reviews.llvm.org/D26028 Change-Id: I0ed82cb81dd9d37d0be96ece03b667090b72164a --- libsanitizer/lsan/lsan_common.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libsanitizer/lsan/lsan_common.cc b/libsanitizer/lsan/lsan_common.cc index 866e23f..5c92e32 100644 --- a/libsanitizer/lsan/lsan_common.cc +++ b/libsanitizer/lsan/lsan_common.cc @@ -33,6 +33,7 @@ namespace __lsan { // also to protect the global list of root regions. BlockingMutex global_mutex(LINKER_INITIALIZED); +__attribute__((tls_model("initial-exec"))) THREADLOCAL int disable_counter; bool DisabledInThisThread() { return disable_counter > 0; } -- 2.7.4 From b85631a2e7a37e74b9553de1ae01b96aa0f16964 Mon Sep 17 00:00:00 2001 From: Chan Lee Date: Mon, 24 Apr 2017 16:11:01 +0900 Subject: [PATCH 05/16] packaging: add fortran compiler Change-Id: I139d3b29c690a05e29bcfcfa660350f63bbbdadc Signed-off-by: Chan Lee --- packaging/gcc-aarch64.spec | 67 ++++++++++++++++++++++++++++++++++++++++++++-- packaging/gcc-armv7l.spec | 67 ++++++++++++++++++++++++++++++++++++++++++++-- packaging/linaro-gcc.spec | 67 ++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 195 insertions(+), 6 deletions(-) diff --git a/packaging/gcc-aarch64.spec b/packaging/gcc-aarch64.spec index a2607ef..af6e10c 100644 --- a/packaging/gcc-aarch64.spec +++ b/packaging/gcc-aarch64.spec @@ -23,6 +23,7 @@ %define gcc_run_tests 1 %endif +%define quadmath_arch %ix86 x86_64 ia64 %define tsan_arch x86_64 aarch64 %define asan_arch x86_64 %ix86 ppc ppc64 %sparc %arm aarch64 %define itm_arch x86_64 %ix86 %arm ppc ppc64 ppc64le s390 s390x %sparc aarch64 @@ -213,6 +214,23 @@ implementation of Distributed Systems Programming (GLADE) and the Posix %post -n libada -p /sbin/ldconfig %postun -n libada -p /sbin/ldconfig +%package fortran +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0+ +Group: Development/Languages +%description fortran +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package -n libgfortran +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-with-GCC-exception +Group: Development/Languages +%description -n libgfortran +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). +%post -n libgfortran -p /sbin/ldconfig +%postun -n libgfortran -p /sbin/ldconfig + %package -n libquadmath Summary: The GNU Fortran Compiler Quadmath Runtime Library License: LGPL-2.1 @@ -478,6 +496,23 @@ implementation of Distributed Systems Programming (GLADE) and the Posix %post -n libada-32bit -p /sbin/ldconfig %postun -n libada-32bit -p /sbin/ldconfig +%package fortran-32bit +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0+ +Group: Development/Languages +%description fortran-32bit +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package -n libgfortran-32bit +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-with-GCC-exception +Group: Development/Languages +%description -n libgfortran-32bit +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). +%post -n libgfortran-32bit -p /sbin/ldconfig +%postun -n libgfortran-32bit -p /sbin/ldconfig + %package -n libquadmath-32bit Summary: The GNU Fortran Compiler Quadmath Runtime Library License: LGPL-2.1 @@ -826,7 +861,7 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --mandir=%{_mandir} \ --libdir=%{libdir} \ --libexecdir=%{libdir} \ - --enable-languages=c,c++ \ + --enable-languages=c,c++,fortran \ --enable-checking=release \ --disable-libssp \ --disable-bootstrap \ @@ -844,10 +879,10 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --without-system-libunwind \ --enable-threads=posix \ --disable-multilib \ - --disable-libquadmath \ --enable-lto \ %{!?cross: \ --enable-libcc1 \ + --enable-libgfortran \ %ifarch armv7l --with-arch=armv7-a \ --with-tune=cortex-a8 \ @@ -880,6 +915,8 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --disable-sjlj-exceptions \ } \ --disable-libgcc \ + --disable-libgfortran \ + --disable-libquadmath \ --disable-libgomp \ --disable-libatomic \ --disable-libstdc++-v3 \ @@ -1119,6 +1156,26 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %{libdir}/libubsan.so.* %endif +%files fortran +%defattr(-,root,root) +%dir %{libsubdir}/finclude +%{_bindir}/gfortran +%{_bindir}/%{target_arch}-gfortran +%{libsubdir}/f951 +%{libsubdir}/finclude/* +%{libdir}/libgfortran.a +%{libdir}/libgfortran.so +%{libsubdir}/libgfortran.spec +%{libsubdir}/libcaf_single.a +%ifarch %quadmath_arch +%{libdir}/libquadmath.a +%{libdir}/libquadmath.so +%endif + +%files -n libgfortran +%defattr(-,root,root) +%{libdir}/libgfortran.so.* + %ifarch %quadmath_arch %files -n libquadmath %manifest gcc.manifest @@ -1202,6 +1259,12 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %{libsubdir}/32/libitm.so.* %endif +%files -n libgfortran-32bit +%defattr(-,root,root) +%dir %{libsubdir}/32/finclude +%{libsubdir}/32/libgfortran.so.* +%{libsubdir}/32/finclude/* + %ifarch %quadmath_arch %files -n libquadmath-32bit %license COPYING.LIB diff --git a/packaging/gcc-armv7l.spec b/packaging/gcc-armv7l.spec index ea57dd8..9b816c1 100644 --- a/packaging/gcc-armv7l.spec +++ b/packaging/gcc-armv7l.spec @@ -23,6 +23,7 @@ %define gcc_run_tests 1 %endif +%define quadmath_arch %ix86 x86_64 ia64 %define tsan_arch x86_64 aarch64 %define asan_arch x86_64 %ix86 ppc ppc64 %sparc %arm aarch64 %define itm_arch x86_64 %ix86 %arm ppc ppc64 ppc64le s390 s390x %sparc aarch64 @@ -213,6 +214,23 @@ implementation of Distributed Systems Programming (GLADE) and the Posix %post -n libada -p /sbin/ldconfig %postun -n libada -p /sbin/ldconfig +%package fortran +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0+ +Group: Development/Languages +%description fortran +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package -n libgfortran +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-with-GCC-exception +Group: Development/Languages +%description -n libgfortran +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). +%post -n libgfortran -p /sbin/ldconfig +%postun -n libgfortran -p /sbin/ldconfig + %package -n libquadmath Summary: The GNU Fortran Compiler Quadmath Runtime Library License: LGPL-2.1 @@ -478,6 +496,23 @@ implementation of Distributed Systems Programming (GLADE) and the Posix %post -n libada-32bit -p /sbin/ldconfig %postun -n libada-32bit -p /sbin/ldconfig +%package fortran-32bit +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0+ +Group: Development/Languages +%description fortran-32bit +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package -n libgfortran-32bit +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-with-GCC-exception +Group: Development/Languages +%description -n libgfortran-32bit +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). +%post -n libgfortran-32bit -p /sbin/ldconfig +%postun -n libgfortran-32bit -p /sbin/ldconfig + %package -n libquadmath-32bit Summary: The GNU Fortran Compiler Quadmath Runtime Library License: LGPL-2.1 @@ -826,7 +861,7 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --mandir=%{_mandir} \ --libdir=%{libdir} \ --libexecdir=%{libdir} \ - --enable-languages=c,c++ \ + --enable-languages=c,c++,fortran \ --enable-checking=release \ --disable-libssp \ --disable-bootstrap \ @@ -844,10 +879,10 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --without-system-libunwind \ --enable-threads=posix \ --disable-multilib \ - --disable-libquadmath \ --enable-lto \ %{!?cross: \ --enable-libcc1 \ + --enable-libgfortran \ %ifarch armv7l --with-arch=armv7-a \ --with-tune=cortex-a8 \ @@ -880,6 +915,8 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --disable-sjlj-exceptions \ } \ --disable-libgcc \ + --disable-libgfortran \ + --disable-libquadmath \ --disable-libgomp \ --disable-libatomic \ --disable-libstdc++-v3 \ @@ -1119,6 +1156,26 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %{libdir}/libubsan.so.* %endif +%files fortran +%defattr(-,root,root) +%dir %{libsubdir}/finclude +%{_bindir}/gfortran +%{_bindir}/%{target_arch}-gfortran +%{libsubdir}/f951 +%{libsubdir}/finclude/* +%{libdir}/libgfortran.a +%{libdir}/libgfortran.so +%{libsubdir}/libgfortran.spec +%{libsubdir}/libcaf_single.a +%ifarch %quadmath_arch +%{libdir}/libquadmath.a +%{libdir}/libquadmath.so +%endif + +%files -n libgfortran +%defattr(-,root,root) +%{libdir}/libgfortran.so.* + %ifarch %quadmath_arch %files -n libquadmath %manifest gcc.manifest @@ -1202,6 +1259,12 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %{libsubdir}/32/libitm.so.* %endif +%files -n libgfortran-32bit +%defattr(-,root,root) +%dir %{libsubdir}/32/finclude +%{libsubdir}/32/libgfortran.so.* +%{libsubdir}/32/finclude/* + %ifarch %quadmath_arch %files -n libquadmath-32bit %license COPYING.LIB diff --git a/packaging/linaro-gcc.spec b/packaging/linaro-gcc.spec index a81bbe4..d0e2220 100644 --- a/packaging/linaro-gcc.spec +++ b/packaging/linaro-gcc.spec @@ -20,6 +20,7 @@ %define gcc_run_tests 1 %endif +%define quadmath_arch %ix86 x86_64 ia64 %define tsan_arch x86_64 aarch64 %define asan_arch x86_64 %ix86 ppc ppc64 %sparc %arm aarch64 %define itm_arch x86_64 %ix86 %arm ppc ppc64 ppc64le s390 s390x %sparc aarch64 @@ -210,6 +211,23 @@ implementation of Distributed Systems Programming (GLADE) and the Posix %post -n libada -p /sbin/ldconfig %postun -n libada -p /sbin/ldconfig +%package fortran +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0+ +Group: Development/Languages +%description fortran +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package -n libgfortran +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-with-GCC-exception +Group: Development/Languages +%description -n libgfortran +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). +%post -n libgfortran -p /sbin/ldconfig +%postun -n libgfortran -p /sbin/ldconfig + %package -n libquadmath Summary: The GNU Fortran Compiler Quadmath Runtime Library License: LGPL-2.1 @@ -475,6 +493,23 @@ implementation of Distributed Systems Programming (GLADE) and the Posix %post -n libada-32bit -p /sbin/ldconfig %postun -n libada-32bit -p /sbin/ldconfig +%package fortran-32bit +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0+ +Group: Development/Languages +%description fortran-32bit +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package -n libgfortran-32bit +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-with-GCC-exception +Group: Development/Languages +%description -n libgfortran-32bit +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). +%post -n libgfortran-32bit -p /sbin/ldconfig +%postun -n libgfortran-32bit -p /sbin/ldconfig + %package -n libquadmath-32bit Summary: The GNU Fortran Compiler Quadmath Runtime Library License: LGPL-2.1 @@ -823,7 +858,7 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --mandir=%{_mandir} \ --libdir=%{libdir} \ --libexecdir=%{libdir} \ - --enable-languages=c,c++ \ + --enable-languages=c,c++,fortran \ --enable-checking=release \ --disable-libssp \ --disable-bootstrap \ @@ -841,10 +876,10 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --without-system-libunwind \ --enable-threads=posix \ --disable-multilib \ - --disable-libquadmath \ --enable-lto \ %{!?cross: \ --enable-libcc1 \ + --enable-libgfortran \ %ifarch armv7l --with-arch=armv7-a \ --with-tune=cortex-a8 \ @@ -877,6 +912,8 @@ TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \ --disable-sjlj-exceptions \ } \ --disable-libgcc \ + --disable-libgfortran \ + --disable-libquadmath \ --disable-libgomp \ --disable-libatomic \ --disable-libstdc++-v3 \ @@ -1116,6 +1153,26 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %{libdir}/libubsan.so.* %endif +%files fortran +%defattr(-,root,root) +%dir %{libsubdir}/finclude +%{_bindir}/gfortran +%{_bindir}/%{target_arch}-gfortran +%{libsubdir}/f951 +%{libsubdir}/finclude/* +%{libdir}/libgfortran.a +%{libdir}/libgfortran.so +%{libsubdir}/libgfortran.spec +%{libsubdir}/libcaf_single.a +%ifarch %quadmath_arch +%{libdir}/libquadmath.a +%{libdir}/libquadmath.so +%endif + +%files -n libgfortran +%defattr(-,root,root) +%{libdir}/libgfortran.so.* + %ifarch %quadmath_arch %files -n libquadmath %manifest gcc.manifest @@ -1199,6 +1256,12 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/ %{libsubdir}/32/libitm.so.* %endif +%files -n libgfortran-32bit +%defattr(-,root,root) +%dir %{libsubdir}/32/finclude +%{libsubdir}/32/libgfortran.so.* +%{libsubdir}/32/finclude/* + %ifarch %quadmath_arch %files -n libquadmath-32bit %license COPYING.LIB -- 2.7.4 From 58909fae5d4d6bf5048b16cae96a8fe9b9405a55 Mon Sep 17 00:00:00 2001 From: Slava Barinov Date: Thu, 27 Apr 2017 11:20:09 +0300 Subject: [PATCH 06/16] Do not build libgfortran unless requested explicitly * gcc/fortran/config-lang.in : add conditional target_libs setup. This option does not make sense in upstream GCC - Fortran frontend is useless without runtime, but will work with qemu-accel in Tizen OBS environment. Change-Id: Ie42fa3201a0bc022ef46ef53b51be896ad091943 Signed-off-by: Slava Barinov --- gcc/fortran/config-lang.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/config-lang.in b/gcc/fortran/config-lang.in index b81dadd..76b1d06 100644 --- a/gcc/fortran/config-lang.in +++ b/gcc/fortran/config-lang.in @@ -27,7 +27,10 @@ language="fortran" compilers="f951\$(exeext)" -target_libs="target-libgfortran target-libbacktrace" +if test x${enable_libgfortran} == xyes ; then + target_libs="target-libgfortran target-libbacktrace" +else + target_libs= +fi gtfiles="\$(srcdir)/fortran/f95-lang.c \$(srcdir)/fortran/trans-decl.c \$(srcdir)/fortran/trans-intrinsic.c \$(srcdir)/fortran/trans-io.c \$(srcdir)/fortran/trans-stmt.c \$(srcdir)/fortran/trans-types.c \$(srcdir)/fortran/trans-types.h \$(srcdir)/fortran/trans.h \$(srcdir)/fortran/trans-const.h" - -- 2.7.4 From 438ee891ccb52c97f797598c08b92922fc1cce40 Mon Sep 17 00:00:00 2001 From: Mikhail Kashkarov Date: Wed, 10 May 2017 12:58:52 +0300 Subject: [PATCH 07/16] Move static array from header to .c file (fixed increased memory usage bs-45) Please, remove this commit when merging c1cb342. gcc/ * config/arm/arm-opts.h: Move struct arm_arch_core_flag and static array arm_arch_core_flags to... * common/config/arm/arm-common.c: There. Change-Id: Id71ddb5deac5372791b63f9bf03852e661477bf4 --- gcc/common/config/arm/arm-common.c | 20 ++++++++++++++++++++ gcc/config/arm/arm-opts.h | 19 ------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gcc/common/config/arm/arm-common.c b/gcc/common/config/arm/arm-common.c index 29ae0c3..1cb59aa 100644 --- a/gcc/common/config/arm/arm-common.c +++ b/gcc/common/config/arm/arm-common.c @@ -97,6 +97,26 @@ arm_rewrite_mcpu (int argc, const char **argv) return arm_rewrite_selected_cpu (argv[argc - 1]); } +struct arm_arch_core_flag +{ + const char *const name; + const arm_feature_set flags; +}; + +static const struct arm_arch_core_flag arm_arch_core_flags[] = +{ +#undef ARM_CORE +#define ARM_CORE(NAME, X, IDENT, ARCH, FLAGS, COSTS) \ + {NAME, FLAGS}, +#include "config/arm/arm-cores.def" +#undef ARM_CORE +#undef ARM_ARCH +#define ARM_ARCH(NAME, CORE, ARCH, FLAGS) \ + {NAME, FLAGS}, +#include "config/arm/arm-arches.def" +#undef ARM_ARCH +}; + /* Called by the driver to check whether the target denoted by current command line options is a Thumb-only target. ARGV is an array of -march and -mcpu values (ie. it contains the rhs after the equal diff --git a/gcc/config/arm/arm-opts.h b/gcc/config/arm/arm-opts.h index 9ae104a..84669f4 100644 --- a/gcc/config/arm/arm-opts.h +++ b/gcc/config/arm/arm-opts.h @@ -80,23 +80,4 @@ enum arm_tls_type { TLS_GNU2 }; -struct arm_arch_core_flag -{ - const char *const name; - const arm_feature_set flags; -}; - -static const struct arm_arch_core_flag arm_arch_core_flags[] = -{ -#undef ARM_CORE -#define ARM_CORE(NAME, X, IDENT, ARCH, FLAGS, COSTS) \ - {NAME, FLAGS}, -#include "arm-cores.def" -#undef ARM_CORE -#undef ARM_ARCH -#define ARM_ARCH(NAME, CORE, ARCH, FLAGS) \ - {NAME, FLAGS}, -#include "arm-arches.def" -#undef ARM_ARCH -}; #endif -- 2.7.4 From 0d14c8cdb9eab66ab5dd0ceb22010e7ccf5a275a Mon Sep 17 00:00:00 2001 From: Dmitriy Nikiforov Date: Thu, 11 May 2017 17:21:34 +0300 Subject: [PATCH 08/16] [sanitizer-coverage] Add stub for trace-pc instrumentation libsanitizer/ * sanitizer_common/sanitizer_coverage_libcdep.cc (__sanitizer_cov_trace_pc): New function. Change-Id: I1ead302ccb56c8f20d1a6e29a7cdef8963fa4090 Signed-off-by: Dmitriy Nikiforov --- libsanitizer/sanitizer_common/sanitizer_coverage_libcdep.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libsanitizer/sanitizer_common/sanitizer_coverage_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_coverage_libcdep.cc index c678804..1afcc61 100644 --- a/libsanitizer/sanitizer_common/sanitizer_coverage_libcdep.cc +++ b/libsanitizer/sanitizer_common/sanitizer_coverage_libcdep.cc @@ -953,4 +953,6 @@ SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void __sanitizer_cov_trace_cmp() {} SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void __sanitizer_cov_trace_switch() {} +SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE +void __sanitizer_cov_trace_pc() {} } // extern "C" -- 2.7.4 From dfc83a04050deffebd697122580a270393be6a7a Mon Sep 17 00:00:00 2001 From: Dmitriy Nikiforov Date: Thu, 11 May 2017 17:24:59 +0300 Subject: [PATCH 09/16] [sanitizer-coverage] Add interface for coverage symbolization libsanitizer/ * sanitizer_common/sanitizer_stacktrace_libcdep.cc: (__sanitizer_symbolize_pc): New function. (__sanitizer_get_module_and_offset_for_pc): New function. * include/sanitizer/common_interface_defs.h (__sanitizer_symbolize_pc): Likewise. (__sanitizer_get_module_and_offset_for_pc): Likewise. * sanitizer_common/sanitizer_interface_internal.h (__sanitizer_get_module_and_offset_for_pc): Likewise. Partially backported from LLVM mainline r281886, r279780, r288711, r281668, r281015, r289498. Also, fixed argument names in declarations of __sanitizer_get_module_and_offset_for_pc(). Change-Id: I3722eb8d3e1cd07b6b862f1a4421517b32b22c5a Signed-off-by: Dmitriy Nikiforov --- .../include/sanitizer/common_interface_defs.h | 13 ++++++ .../sanitizer_interface_internal.h | 6 +++ .../sanitizer_stacktrace_libcdep.cc | 47 ++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/libsanitizer/include/sanitizer/common_interface_defs.h b/libsanitizer/include/sanitizer/common_interface_defs.h index 35463e0..a6b16a6 100644 --- a/libsanitizer/include/sanitizer/common_interface_defs.h +++ b/libsanitizer/include/sanitizer/common_interface_defs.h @@ -112,6 +112,13 @@ extern "C" { // Print the stack trace leading to this call. Useful for debugging user code. void __sanitizer_print_stack_trace(); + // Symbolizes the supplied 'pc' using the format string 'fmt'. + // Outputs at most 'out_buf_size' bytes into 'out_buf'. + // The format syntax is described in + // lib/sanitizer_common/sanitizer_stacktrace_printer.h. + void __sanitizer_symbolize_pc(void *pc, const char *fmt, char *out_buf, + size_t out_buf_size); + // Sets the callback to be called right before death on error. // Passing 0 will unset the callback. void __sanitizer_set_death_callback(void (*callback)(void)); @@ -126,6 +133,12 @@ extern "C" { const void *s2, size_t n); void __sanitizer_weak_hook_strncmp(void *called_pc, const char *s1, const char *s2, size_t n); + + // Get full module name and calculate pc offset within it. + // Returns 1 if pc belongs to some module, 0 if module was not found. + int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_name, + size_t module_name_len, + void **pc_offset); #ifdef __cplusplus } // extern "C" #endif diff --git a/libsanitizer/sanitizer_common/sanitizer_interface_internal.h b/libsanitizer/sanitizer_common/sanitizer_interface_internal.h index 0547f99..9d2d3d0 100644 --- a/libsanitizer/sanitizer_common/sanitizer_interface_internal.h +++ b/libsanitizer/sanitizer_common/sanitizer_interface_internal.h @@ -54,6 +54,12 @@ extern "C" { SANITIZER_INTERFACE_ATTRIBUTE const void *__sanitizer_contiguous_container_find_bad_address( const void *beg, const void *mid, const void *end); + + SANITIZER_INTERFACE_ATTRIBUTE + int __sanitizer_get_module_and_offset_for_pc(__sanitizer::uptr pc, + char *module_name, + __sanitizer::uptr module_name_len, + __sanitizer::uptr *pc_offset); } // extern "C" #endif // SANITIZER_INTERFACE_INTERNAL_H diff --git a/libsanitizer/sanitizer_common/sanitizer_stacktrace_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_stacktrace_libcdep.cc index addf44f..0bdf65f 100644 --- a/libsanitizer/sanitizer_common/sanitizer_stacktrace_libcdep.cc +++ b/libsanitizer/sanitizer_common/sanitizer_stacktrace_libcdep.cc @@ -71,4 +71,51 @@ void BufferedStackTrace::Unwind(u32 max_depth, uptr pc, uptr bp, void *context, } } +static int GetModuleAndOffsetForPc(uptr pc, char *module_name, + uptr module_name_len, uptr *pc_offset) { + const char *found_module_name = nullptr; + bool ok = Symbolizer::GetOrInit()->GetModuleNameAndOffsetForPC( + pc, &found_module_name, pc_offset); + + if (!ok) + return false; + + if (module_name && module_name_len) { + internal_strncpy(module_name, found_module_name, module_name_len); + module_name[module_name_len - 1] = '\x00'; + } + return true; +} + } // namespace __sanitizer + +using namespace __sanitizer; + +extern "C" { +SANITIZER_INTERFACE_ATTRIBUTE +void __sanitizer_symbolize_pc(uptr pc, const char *fmt, char *out_buf, + uptr out_buf_size) { + if (!out_buf_size) + return; + pc = StackTrace::GetPreviousInstructionPc(pc); + SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc); + if (!frame) { + internal_strncpy(out_buf, "", out_buf_size); + out_buf[out_buf_size - 1] = 0; + return; + } + InternalScopedString frame_desc(GetPageSizeCached()); + RenderFrame(&frame_desc, fmt, 0, frame->info, + common_flags()->symbolize_vs_style, + common_flags()->strip_path_prefix); + internal_strncpy(out_buf, frame_desc.data(), out_buf_size); + out_buf[out_buf_size - 1] = 0; +} + +SANITIZER_INTERFACE_ATTRIBUTE +int __sanitizer_get_module_and_offset_for_pc( // NOLINT + uptr pc, char *module_name, uptr module_name_len, uptr *pc_offset) { + return __sanitizer::GetModuleAndOffsetForPc(pc, module_name, module_name_len, + pc_offset); +} +} // extern "C" -- 2.7.4 From d0fd3198b9b5e12a93160958427bc17ef0d2fa69 Mon Sep 17 00:00:00 2001 From: Dmitriy Nikiforov Date: Thu, 11 May 2017 17:37:27 +0300 Subject: [PATCH 10/16] [sanitizer-coverage] Add new coverage dump interface libsanitizer/ * include/santizer/coverage_interface.h (__sanitizer_dump_coverage): New function. * sanitizer_common/sanitizer_interface_internal.h (__sanitizer_dump_coverage): Likewise. * sanitizer_common/sanitizer_coverage_libcdep_new.cc: New file. * sanitizer/Makefile.am: Updated. * sanitzer/Makefile.in: Updated. Partially backported from LLVM mainline r289498, r291267, r291736, r289851. Change-Id: I6c13ca8e6e7cfb3c98596970c8ba243296464eeb Signed-off-by: Dmitriy Nikiforov --- .../include/sanitizer/coverage_interface.h | 3 + libsanitizer/sanitizer_common/Makefile.am | 1 + libsanitizer/sanitizer_common/Makefile.in | 3 + .../sanitizer_coverage_libcdep_new.cc | 113 +++++++++++++++++++++ .../sanitizer_interface_internal.h | 3 + 5 files changed, 123 insertions(+) create mode 100644 libsanitizer/sanitizer_common/sanitizer_coverage_libcdep_new.cc diff --git a/libsanitizer/include/sanitizer/coverage_interface.h b/libsanitizer/include/sanitizer/coverage_interface.h index 37c133a..d6e83d6 100644 --- a/libsanitizer/include/sanitizer/coverage_interface.h +++ b/libsanitizer/include/sanitizer/coverage_interface.h @@ -21,6 +21,9 @@ extern "C" { void __sanitizer_cov_init(); // Record and dump coverage info. void __sanitizer_cov_dump(); + // Dump collected coverage info. Sorts pcs by module into individual + // .sancov files. + void __sanitizer_dump_coverage(const uintptr_t *pcs, uintptr_t len); // Open .sancov.packed in the coverage directory and return the file // descriptor. Returns -1 on failure, or if coverage dumping is disabled. // This is intended for use by sandboxing code. diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am index ee7a3f1..e66295f 100644 --- a/libsanitizer/sanitizer_common/Makefile.am +++ b/libsanitizer/sanitizer_common/Makefile.am @@ -23,6 +23,7 @@ sanitizer_common_files = \ sanitizer_common.cc \ sanitizer_common_libcdep.cc \ sanitizer_coverage_libcdep.cc \ + sanitizer_coverage_libcdep_new.cc \ sanitizer_coverage_mapping_libcdep.cc \ sanitizer_deadlock_detector1.cc \ sanitizer_deadlock_detector2.cc \ diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in index 765efd1..8924f20 100644 --- a/libsanitizer/sanitizer_common/Makefile.in +++ b/libsanitizer/sanitizer_common/Makefile.in @@ -82,6 +82,7 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) libsanitizer_common_la_LIBADD = am__objects_1 = sanitizer_allocator.lo sanitizer_common.lo \ sanitizer_common_libcdep.lo sanitizer_coverage_libcdep.lo \ + sanitizer_coverage_libcdep_new.lo \ sanitizer_coverage_mapping_libcdep.lo \ sanitizer_deadlock_detector1.lo \ sanitizer_deadlock_detector2.lo sanitizer_flags.lo \ @@ -288,6 +289,7 @@ sanitizer_common_files = \ sanitizer_common.cc \ sanitizer_common_libcdep.cc \ sanitizer_coverage_libcdep.cc \ + sanitizer_coverage_libcdep_new.cc \ sanitizer_coverage_mapping_libcdep.cc \ sanitizer_deadlock_detector1.cc \ sanitizer_deadlock_detector2.cc \ @@ -422,6 +424,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_common.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_common_libcdep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_coverage_libcdep.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_coverage_libcdep_new.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_coverage_mapping_libcdep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_deadlock_detector1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_deadlock_detector2.Plo@am__quote@ diff --git a/libsanitizer/sanitizer_common/sanitizer_coverage_libcdep_new.cc b/libsanitizer/sanitizer_common/sanitizer_coverage_libcdep_new.cc new file mode 100644 index 0000000..dcb305c --- /dev/null +++ b/libsanitizer/sanitizer_common/sanitizer_coverage_libcdep_new.cc @@ -0,0 +1,113 @@ +//===-- sanitizer_coverage_libcdep_new.cc ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// Sanitizer Coverage Controller for Trace PC Guard. + +#include "sanitizer_allocator_internal.h" +#include "sanitizer_atomic.h" +#include "sanitizer_common.h" +#include "sanitizer_flags.h" +#include "sanitizer_symbolizer.h" + +using namespace __sanitizer; + +using AddressRange = LoadedModule::AddressRange; + +namespace __sancov { +namespace { + +static const u64 Magic64 = 0xC0BFFFFFFFFFFF64ULL; +static const u64 Magic32 = 0xC0BFFFFFFFFFFF32ULL; +static const u64 Magic = SANITIZER_WORDSIZE == 64 ? Magic64 : Magic32; + +static fd_t OpenFile(const char *path) { + error_t err; + fd_t fd = OpenFile(path, WrOnly, &err); + if (fd == kInvalidFd) + Report("SanitizerCoverage: failed to open %s for writing (reason: %d)\n", + path, err); + return fd; +} + +static void GetCoverageFilename(char *path, const char *name, + const char *extension) { + CHECK(name); + internal_snprintf(path, kMaxPathLength, "%s/%s.%zd.%s", + common_flags()->coverage_dir, name, internal_getpid(), + extension); +} + +static void WriteModuleCoverage(char *file_path, const char *module_name, + const uptr *pcs, uptr len) { + GetCoverageFilename(file_path, StripModuleName(module_name), "sancov"); + fd_t fd = OpenFile(file_path); + WriteToFile(fd, &Magic, sizeof(Magic)); + WriteToFile(fd, pcs, len * sizeof(*pcs)); + CloseFile(fd); + Printf("SanitizerCoverage: %s %zd PCs written\n", file_path, len); +} + +static void SanitizerDumpCoverage(const uptr *unsorted_pcs, uptr len) { + if (!len) + return; + + char *file_path = static_cast(InternalAlloc(kMaxPathLength)); + char *module_name = static_cast(InternalAlloc(kMaxPathLength)); + uptr *pcs = static_cast(InternalAlloc(len * sizeof(uptr))); + + internal_memcpy(pcs, unsorted_pcs, len * sizeof(uptr)); + SortArray(pcs, len); + + bool module_found = false; + uptr last_base = 0; + uptr module_start_idx = 0; + + for (uptr i = 0; i < len; ++i) { + const uptr pc = pcs[i]; + if (!pc) + continue; + + if (!__sanitizer_get_module_and_offset_for_pc(pc, nullptr, 0, &pcs[i])) { + Printf("ERROR: bad pc %x\n", pc); + continue; + } + uptr module_base = pc - pcs[i]; + + if (module_base != last_base || !module_found) { + if (module_found) { + WriteModuleCoverage(file_path, module_name, &pcs[module_start_idx], + i - module_start_idx); + } + + last_base = module_base; + module_start_idx = i; + module_found = true; + __sanitizer_get_module_and_offset_for_pc(pc, module_name, kMaxPathLength, + &pcs[i]); + } + } + + if (module_found) { + WriteModuleCoverage(file_path, module_name, &pcs[module_start_idx], + len - module_start_idx); + } + + InternalFree(file_path); + InternalFree(module_name); + InternalFree(pcs); +} + +} // namespace +} // namespace __sancov + +extern "C" { +SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage( // NOLINT + const uptr *pcs, uptr len) { + return __sancov::SanitizerDumpCoverage(pcs, len); +} +} // extern "C" diff --git a/libsanitizer/sanitizer_common/sanitizer_interface_internal.h b/libsanitizer/sanitizer_common/sanitizer_interface_internal.h index 9d2d3d0..fe740c9 100644 --- a/libsanitizer/sanitizer_common/sanitizer_interface_internal.h +++ b/libsanitizer/sanitizer_common/sanitizer_interface_internal.h @@ -41,6 +41,9 @@ extern "C" { void __sanitizer_report_error_summary(const char *error_summary); SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump(); + SANITIZER_INTERFACE_ATTRIBUTE + void __sanitizer_dump_coverage(const __sanitizer::uptr *pcs, + const __sanitizer::uptr len); SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_init(); SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov(__sanitizer::u32 *guard); SANITIZER_INTERFACE_ATTRIBUTE -- 2.7.4 From 14e9820ddef8026797810979ba66e32696c058cc Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 27 Apr 2017 13:56:35 +0300 Subject: [PATCH 11/16] PR c++/79296 - ICE mangling localized template instantiation * decl2.c (determine_visibility): Use template fn context for local class instantiations. PR c++/79296 * g++.dg/cpp0x/pr79296.C: New. Change-Id: I51b9ba39a48a97a8836976baf5f598ede9ba695a git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245398 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/decl2.c | 41 ++++++++++++++++++------------------ gcc/testsuite/g++.dg/cpp0x/pr79296.C | 18 ++++++++++++++++ 2 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr79296.C diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index c4a0e85..a9511de 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2280,11 +2280,6 @@ constrain_visibility_for_template (tree decl, tree targs) void determine_visibility (tree decl) { - tree class_type = NULL_TREE; - bool use_template; - bool orig_visibility_specified; - enum symbol_visibility orig_visibility; - /* Remember that all decls get VISIBILITY_DEFAULT when built. */ /* Only relevant for names with external linkage. */ @@ -2296,25 +2291,28 @@ determine_visibility (tree decl) maybe_clone_body. */ gcc_assert (!DECL_CLONED_FUNCTION_P (decl)); - orig_visibility_specified = DECL_VISIBILITY_SPECIFIED (decl); - orig_visibility = DECL_VISIBILITY (decl); + bool orig_visibility_specified = DECL_VISIBILITY_SPECIFIED (decl); + enum symbol_visibility orig_visibility = DECL_VISIBILITY (decl); + /* The decl may be a template instantiation, which could influence + visibilty. */ + tree template_decl = NULL_TREE; if (TREE_CODE (decl) == TYPE_DECL) { if (CLASS_TYPE_P (TREE_TYPE (decl))) - use_template = CLASSTYPE_USE_TEMPLATE (TREE_TYPE (decl)); + { + if (CLASSTYPE_USE_TEMPLATE (TREE_TYPE (decl))) + template_decl = decl; + } else if (TYPE_TEMPLATE_INFO (TREE_TYPE (decl))) - use_template = 1; - else - use_template = 0; + template_decl = decl; } - else if (DECL_LANG_SPECIFIC (decl)) - use_template = DECL_USE_TEMPLATE (decl); - else - use_template = 0; + else if (DECL_LANG_SPECIFIC (decl) && DECL_USE_TEMPLATE (decl)) + template_decl = decl; /* If DECL is a member of a class, visibility specifiers on the class can influence the visibility of the DECL. */ + tree class_type = NULL_TREE; if (DECL_CLASS_SCOPE_P (decl)) class_type = DECL_CONTEXT (decl); else @@ -2357,8 +2355,11 @@ determine_visibility (tree decl) } /* Local classes in templates have CLASSTYPE_USE_TEMPLATE set, - but have no TEMPLATE_INFO, so don't try to check it. */ - use_template = 0; + but have no TEMPLATE_INFO. Their containing template + function does, and the local class could be constrained + by that. */ + if (template_decl) + template_decl = fn; } else if (VAR_P (decl) && DECL_TINFO_P (decl) && flag_visibility_ms_compat) @@ -2388,7 +2389,7 @@ determine_visibility (tree decl) && !CLASSTYPE_VISIBILITY_SPECIFIED (TREE_TYPE (DECL_NAME (decl)))) targetm.cxx.determine_class_data_visibility (decl); } - else if (use_template) + else if (template_decl) /* Template instantiations and specializations get visibility based on their template unless they override it with an attribute. */; else if (! DECL_VISIBILITY_SPECIFIED (decl)) @@ -2405,11 +2406,11 @@ determine_visibility (tree decl) } } - if (use_template) + if (template_decl) { /* If the specialization doesn't specify visibility, use the visibility from the template. */ - tree tinfo = get_template_info (decl); + tree tinfo = get_template_info (template_decl); tree args = TI_ARGS (tinfo); tree attribs = (TREE_CODE (decl) == TYPE_DECL ? TYPE_ATTRIBUTES (TREE_TYPE (decl)) diff --git a/gcc/testsuite/g++.dg/cpp0x/pr79296.C b/gcc/testsuite/g++.dg/cpp0x/pr79296.C new file mode 100644 index 0000000..1ee982c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr79296.C @@ -0,0 +1,18 @@ +// { dg-do compile { target c++11 } } +// { dg-require-effective-target lto } +// { dg-additional-options "-flto" } + +// PR 79296 ICE mangling local class of localized instantiation + +struct X { + template X (T const *) { + struct Z {}; + } +}; + +void Baz () +{ + struct Y { } y; + + 0, X (&y); +} -- 2.7.4 From aa45a75f425e69935bde7dbbfdb2e629e9d43ed5 Mon Sep 17 00:00:00 2001 From: Denis Khalikov Date: Mon, 17 Apr 2017 19:31:13 +0300 Subject: [PATCH 12/16] [ubsan] Ported fix for PR sanitizer/79897 2017-03-07 Jakub Jelinek PR sanitizer/79897 * ubsan.c (ubsan_encode_value): Call mark_addressable on the temporary. Change-Id: I075edb26f51d4ec2eccc2e59dbbe489b43b3b5db Signed-off-by: Denis Khalikov --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/ubsan/pr79897.c | 15 +++++++++++++++ gcc/ubsan.c | 1 + 4 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/ubsan/pr79897.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b765c86..d83072b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-03-07 Jakub Jelinek + + PR sanitizer/79897 + * ubsan.c (ubsan_encode_value): Call mark_addressable on the + temporary. + 2017-02-03 Carl Love Backport of two commits from mainline, r244943 and r244904, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e9cf664..e564593 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-07 Jakub Jelinek + + PR sanitizer/79897 + * c-c++-common/ubsan/pr79897.c: New test. + 2017-02-03 Carl Love * gcc.target/powerpc/builtins-3-p8.c: Add new testfile for missing diff --git a/gcc/testsuite/c-c++-common/ubsan/pr79897.c b/gcc/testsuite/c-c++-common/ubsan/pr79897.c new file mode 100644 index 0000000..0dadcff --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr79897.c @@ -0,0 +1,15 @@ +/* PR sanitizer/79897 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=enum -O2" } */ + +enum E +{ + A = 0, + B = ~0U + 1LL +} x = A; + +int +main () +{ + return x != A; +} diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 1093824..127f21d 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -144,6 +144,7 @@ ubsan_encode_value (tree t, bool in_expand_p) code by making vars unnecessarily addressable. */ tree var = create_tmp_var (type); tree tem = build2 (MODIFY_EXPR, void_type_node, var, t); + mark_addressable (var); if (in_expand_p) { rtx mem -- 2.7.4 From ac5b0b65260c7b4659fc503b96401f7011601c69 Mon Sep 17 00:00:00 2001 From: Denis Khalikov Date: Fri, 2 Jun 2017 12:17:06 +0300 Subject: [PATCH 13/16] PR sanitizer/80414 * ubsan.c (ubsan_expand_bounds_ifn): Pass original index to ubsan_encode_value. Change-Id: Id8e339c51aac586cd7d61e02a6711e875354948a Signed-off-by: Denis Khalikov --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/ubsan/bounds-15.c | 13 +++++++++++++ gcc/ubsan.c | 10 +++++----- 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/ubsan/bounds-15.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d83072b..77528a5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-04-13 Denis Khalikov + + PR sanitizer/80414 + * ubsan.c (ubsan_expand_bounds_ifn): Pass original index + to ubsan_encode_value. + 2017-03-07 Jakub Jelinek PR sanitizer/79897 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e564593..3ae4c95 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-13 Denis Khalikov + + PR sanitizer/80414 + * c-c++-common/ubsan/bounds-15.c: New test. + 2017-03-07 Jakub Jelinek PR sanitizer/79897 diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-15.c b/gcc/testsuite/c-c++-common/ubsan/bounds-15.c new file mode 100644 index 0000000..5fa8eee --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/bounds-15.c @@ -0,0 +1,13 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=bounds" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +int main() +{ + long long offset = 10; + char array[10]; + char c = array[offset]; + return 0; +} + +/* { dg-output "index 10 out of bounds for type 'char \\\[10\\\]'" } */ diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 127f21d..cbb46ec 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -666,7 +666,7 @@ ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi) /* Pick up the arguments of the UBSAN_BOUNDS call. */ tree type = TREE_TYPE (TREE_TYPE (gimple_call_arg (stmt, 0))); tree index = gimple_call_arg (stmt, 1); - tree orig_index_type = TREE_TYPE (index); + tree orig_index = index; tree bound = gimple_call_arg (stmt, 2); gimple_stmt_iterator gsi_orig = *gsi; @@ -693,7 +693,7 @@ ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi) tree data = ubsan_create_data ("__ubsan_out_of_bounds_data", 1, &loc, ubsan_type_descriptor (type, UBSAN_PRINT_ARRAY), - ubsan_type_descriptor (orig_index_type), + ubsan_type_descriptor (TREE_TYPE (orig_index)), NULL_TREE, NULL_TREE); data = build_fold_addr_expr_loc (loc, data); enum built_in_function bcode @@ -701,9 +701,9 @@ ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi) ? BUILT_IN_UBSAN_HANDLE_OUT_OF_BOUNDS : BUILT_IN_UBSAN_HANDLE_OUT_OF_BOUNDS_ABORT; tree fn = builtin_decl_explicit (bcode); - tree val = force_gimple_operand_gsi (gsi, ubsan_encode_value (index), - true, NULL_TREE, true, - GSI_SAME_STMT); + tree val + = force_gimple_operand_gsi (gsi, ubsan_encode_value (orig_index), true, + NULL_TREE, true, GSI_SAME_STMT); g = gimple_build_call (fn, 2, data, val); } gimple_set_location (g, loc); -- 2.7.4 From 01e95341203049e57915f5ad9d8102c909364473 Mon Sep 17 00:00:00 2001 From: Chan Lee Date: Thu, 1 Jun 2017 12:28:22 +0900 Subject: [PATCH 14/16] packaging: enable log_exe_name sanitizer option for ASan This option shoule be 'log_exe_name' not 'log_exe_path' According to SanitizerCommonFlags, (https://github.com/google/sanitizers/wiki/SanitizerCommonFlags) Enabling this option makes ASan mention name of executable when reporting error and append executable name to logs (as in "log_path.exe_name.pid"). Change-Id: I0a49a2032355b6527ea7522faa1414ec8d567125 Signed-off-by: Chan Lee --- packaging/gcc-aarch64.spec | 2 +- packaging/gcc-armv7l.spec | 2 +- packaging/linaro-gcc.spec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/gcc-aarch64.spec b/packaging/gcc-aarch64.spec index af6e10c..40d1ae6 100644 --- a/packaging/gcc-aarch64.spec +++ b/packaging/gcc-aarch64.spec @@ -785,7 +785,7 @@ Asan runtime environment echo "%{libdir}/libasan.so" > /etc/ld.so.preload [ -f /etc/ld.so.preload.orig ] && cat /etc/ld.so.preload.orig >> /etc/ld.so.preload [ -f /etc/ld.so.preload.orig ] && rm -f /etc/ld.so.preload.orig -echo "halt_on_error=false:start_deactivated=true:print_cmdline=true:quarantine_size_mb=1:detect_leaks=0:log_path=/tmp/asan.log:log_exe_path=1" > /ASAN_OPTIONS +echo "halt_on_error=false:start_deactivated=true:print_cmdline=true:quarantine_size_mb=1:detect_leaks=0:log_path=/tmp/asan.log:log_exe_name=1" > /ASAN_OPTIONS chsmack -a "_" /etc/ld.so.preload /ASAN_OPTIONS %preun -n asan-runtime-env diff --git a/packaging/gcc-armv7l.spec b/packaging/gcc-armv7l.spec index 9b816c1..f3ad3bd 100644 --- a/packaging/gcc-armv7l.spec +++ b/packaging/gcc-armv7l.spec @@ -785,7 +785,7 @@ Asan runtime environment echo "%{libdir}/libasan.so" > /etc/ld.so.preload [ -f /etc/ld.so.preload.orig ] && cat /etc/ld.so.preload.orig >> /etc/ld.so.preload [ -f /etc/ld.so.preload.orig ] && rm -f /etc/ld.so.preload.orig -echo "halt_on_error=false:start_deactivated=true:print_cmdline=true:quarantine_size_mb=1:detect_leaks=0:log_path=/tmp/asan.log:log_exe_path=1" > /ASAN_OPTIONS +echo "halt_on_error=false:start_deactivated=true:print_cmdline=true:quarantine_size_mb=1:detect_leaks=0:log_path=/tmp/asan.log:log_exe_name=1" > /ASAN_OPTIONS chsmack -a "_" /etc/ld.so.preload /ASAN_OPTIONS %preun -n asan-runtime-env diff --git a/packaging/linaro-gcc.spec b/packaging/linaro-gcc.spec index d0e2220..c6460cf 100644 --- a/packaging/linaro-gcc.spec +++ b/packaging/linaro-gcc.spec @@ -782,7 +782,7 @@ Asan runtime environment echo "%{libdir}/libasan.so" > /etc/ld.so.preload [ -f /etc/ld.so.preload.orig ] && cat /etc/ld.so.preload.orig >> /etc/ld.so.preload [ -f /etc/ld.so.preload.orig ] && rm -f /etc/ld.so.preload.orig -echo "halt_on_error=false:start_deactivated=true:print_cmdline=true:quarantine_size_mb=1:detect_leaks=0:log_path=/tmp/asan.log:log_exe_path=1" > /ASAN_OPTIONS +echo "halt_on_error=false:start_deactivated=true:print_cmdline=true:quarantine_size_mb=1:detect_leaks=0:log_path=/tmp/asan.log:log_exe_name=1" > /ASAN_OPTIONS chsmack -a "_" /etc/ld.so.preload /ASAN_OPTIONS %preun -n asan-runtime-env -- 2.7.4 From 10747d7c26bb7c0c4e2e8761256e44b82e63f47a Mon Sep 17 00:00:00 2001 From: Denis Khalikov Date: Thu, 8 Jun 2017 11:32:02 +0300 Subject: [PATCH 15/16] [asan] Fix ASan preload issue. There might be a situation when ASan initializing later than shared library which has malloc in static constructor. (rtld doesn't provide the order of initiazation) In this case ASan doesn't initialize interceptors but already intercepting malloc. If malloc is too big to be handled by static local pool ASan will die with error: Sanitizer CHECK failed: libsanitizer/asan/asan_malloc_linux.cc:40 ((allocated_for_dlsym)) < ((kDlsymAllocPoolSize)) (1036, 1024) Backported from LLVM mainline rL305058 Change-Id: I93c9662953629b373506fcacacee43edd791c68f Signed-off-by: Denis Khalikov --- libsanitizer/asan/asan_malloc_linux.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/libsanitizer/asan/asan_malloc_linux.cc b/libsanitizer/asan/asan_malloc_linux.cc index bfe72af..24829ef 100644 --- a/libsanitizer/asan/asan_malloc_linux.cc +++ b/libsanitizer/asan/asan_malloc_linux.cc @@ -56,30 +56,42 @@ INTERCEPTOR(void, cfree, void *ptr) { } INTERCEPTOR(void*, malloc, uptr size) { - if (UNLIKELY(!asan_inited)) + if (UNLIKELY(asan_init_is_running)) // Hack: dlsym calls malloc before REAL(malloc) is retrieved from dlsym. return AllocateFromLocalPool(size); + ENSURE_ASAN_INITED(); GET_STACK_TRACE_MALLOC; return asan_malloc(size, &stack); } INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) { - if (UNLIKELY(!asan_inited)) + if (UNLIKELY(asan_init_is_running)) // Hack: dlsym calls calloc before REAL(calloc) is retrieved from dlsym. return AllocateFromLocalPool(nmemb * size); + ENSURE_ASAN_INITED(); GET_STACK_TRACE_MALLOC; return asan_calloc(nmemb, size, &stack); } INTERCEPTOR(void*, realloc, void *ptr, uptr size) { - GET_STACK_TRACE_MALLOC; if (UNLIKELY(IsInDlsymAllocPool(ptr))) { - uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym; - uptr copy_size = Min(size, kDlsymAllocPoolSize - offset); - void *new_ptr = asan_malloc(size, &stack); + const uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym; + const uptr copy_size = Min(size, kDlsymAllocPoolSize - offset); + void *new_ptr; + if (UNLIKELY(asan_init_is_running)) { + new_ptr = AllocateFromLocalPool(size); + } else { + ENSURE_ASAN_INITED(); + GET_STACK_TRACE_MALLOC; + new_ptr = asan_malloc(size, &stack); + } internal_memcpy(new_ptr, ptr, copy_size); return new_ptr; } + if (UNLIKELY(asan_init_is_running)) + return AllocateFromLocalPool(size); + ENSURE_ASAN_INITED(); + GET_STACK_TRACE_MALLOC; return asan_realloc(ptr, size, &stack); } -- 2.7.4 From 0b7063a7415d107715e262ed8b9a03ff14af223e Mon Sep 17 00:00:00 2001 From: Denis Khalikov Date: Mon, 29 May 2017 20:35:03 +0300 Subject: [PATCH 16/16] [ubsan] Fix for vptr check MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Summary: There can be a situation when vptr not initializing by constructor of the object, and has a junk data which should be properly checked, because c++ standard says: "If the new-initializer is omitted, the object is default-initialized (8.5). [ Note: If no initialization is performed, the object has an indeterminate value. — end note ] Change-Id: I6fd297dc10b2ddb54eaed9e6eb3a46310dafead4 Signed-off-by: Denis Khalikov --- gcc/testsuite/g++.dg/ubsan/pr332211-llvm.C | 21 +++++++++++++++++++++ libsanitizer/ubsan/ubsan_type_hash_itanium.cc | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ubsan/pr332211-llvm.C diff --git a/gcc/testsuite/g++.dg/ubsan/pr332211-llvm.C b/gcc/testsuite/g++.dg/ubsan/pr332211-llvm.C new file mode 100644 index 0000000..c747754 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr332211-llvm.C @@ -0,0 +1,21 @@ +/* PR 332211 port from llvm */ +/* { dg-do run } */ +/* { dg-options "-fsanitize=vptr -frtti -fno-sanitize-recover=undefined"} */ + +class Base { +public: + int i; + virtual void print() {} +}; + +class Derived : public Base { +public: + void print() {} +}; + +int main() { + char *c = new char[sizeof(Derived)]; + Derived *list = (Derived *)c; + int foo = list->i; + return 0; +} diff --git a/libsanitizer/ubsan/ubsan_type_hash_itanium.cc b/libsanitizer/ubsan/ubsan_type_hash_itanium.cc index e4f1334..4716935 100644 --- a/libsanitizer/ubsan/ubsan_type_hash_itanium.cc +++ b/libsanitizer/ubsan/ubsan_type_hash_itanium.cc @@ -191,7 +191,7 @@ struct VtablePrefix { }; VtablePrefix *getVtablePrefix(void *Vtable) { VtablePrefix *Vptr = reinterpret_cast(Vtable); - if (!Vptr) + if (!IsAccessibleMemoryRange((uptr)Vptr, sizeof(VtablePrefix))) return 0; VtablePrefix *Prefix = Vptr - 1; if (!Prefix->TypeInfo) -- 2.7.4