!174 [Sync] Sync patch from openeuler/gcc
From: @li-yancheng Reviewed-by: @benniaobufeijiushiji, @eastb233 Signed-off-by: @eastb233
This commit is contained in:
commit
fa2aa9efd6
@ -0,0 +1,72 @@
|
|||||||
|
From 2969f5190561e26a8ce42d5dcda43ef59e0b6d32 Mon Sep 17 00:00:00 2001
|
||||||
|
From: liyancheng <412998149@qq.com>
|
||||||
|
Date: Tue, 26 Apr 2022 19:59:09 +0800
|
||||||
|
Subject: [PATCH] [Backport] sanitizer: Fix asan against glibc 2.34 [PR100114]
|
||||||
|
|
||||||
|
Reference: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=d9f462fb372fb02da032cefd6b091d7582c425ae
|
||||||
|
|
||||||
|
sanitizer: Fix asan against glibc 2.34 [PR100114]
|
||||||
|
|
||||||
|
As mentioned in the PR, SIGSTKSZ is no longer a compile time constant in
|
||||||
|
glibc 2.34 and later, so
|
||||||
|
static const uptr kAltStackSize = SIGSTKSZ * 4;
|
||||||
|
needs dynamic initialization, but is used by a function called indirectly
|
||||||
|
from .preinit_array and therefore before the variable is constructed.
|
||||||
|
This results in using 0 size instead and all asan instrumented programs
|
||||||
|
die with:
|
||||||
|
==91==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22)
|
||||||
|
|
||||||
|
Here is a cherry-pick from upstream to fix this.
|
||||||
|
|
||||||
|
2021-04-17 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR sanitizer/100114
|
||||||
|
* sanitizer_common/sanitizer_posix_libcdep.cpp: Cherry-pick
|
||||||
|
llvm-project revisions 82150606fb11d28813ae6da1101f5bda638165fe
|
||||||
|
and b93629dd335ffee2fc4b9b619bf86c3f9e6b0023.
|
||||||
|
---
|
||||||
|
.../sanitizer_common/sanitizer_posix_libcdep.cpp | 13 ++++++++-----
|
||||||
|
1 file changed, 8 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
|
||||||
|
index 304b3a01a..ac88fbe07 100644
|
||||||
|
--- a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
|
||||||
|
+++ b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
|
||||||
|
@@ -169,7 +169,11 @@ bool SupportsColoredOutput(fd_t fd) {
|
||||||
|
|
||||||
|
#if !SANITIZER_GO
|
||||||
|
// TODO(glider): different tools may require different altstack size.
|
||||||
|
-static const uptr kAltStackSize = SIGSTKSZ * 4; // SIGSTKSZ is not enough.
|
||||||
|
+static uptr GetAltStackSize() {
|
||||||
|
+ // SIGSTKSZ is not enough.
|
||||||
|
+ static const uptr kAltStackSize = SIGSTKSZ * 4;
|
||||||
|
+ return kAltStackSize;
|
||||||
|
+}
|
||||||
|
|
||||||
|
void SetAlternateSignalStack() {
|
||||||
|
stack_t altstack, oldstack;
|
||||||
|
@@ -180,10 +184,9 @@ void SetAlternateSignalStack() {
|
||||||
|
// TODO(glider): the mapped stack should have the MAP_STACK flag in the
|
||||||
|
// future. It is not required by man 2 sigaltstack now (they're using
|
||||||
|
// malloc()).
|
||||||
|
- void* base = MmapOrDie(kAltStackSize, __func__);
|
||||||
|
- altstack.ss_sp = (char*) base;
|
||||||
|
+ altstack.ss_size = GetAltStackSize();
|
||||||
|
+ altstack.ss_sp = (char *)MmapOrDie(altstack.ss_size, __func__);
|
||||||
|
altstack.ss_flags = 0;
|
||||||
|
- altstack.ss_size = kAltStackSize;
|
||||||
|
CHECK_EQ(0, sigaltstack(&altstack, nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -191,7 +194,7 @@ void UnsetAlternateSignalStack() {
|
||||||
|
stack_t altstack, oldstack;
|
||||||
|
altstack.ss_sp = nullptr;
|
||||||
|
altstack.ss_flags = SS_DISABLE;
|
||||||
|
- altstack.ss_size = kAltStackSize; // Some sane value required on Darwin.
|
||||||
|
+ altstack.ss_size = GetAltStackSize(); // Some sane value required on Darwin.
|
||||||
|
CHECK_EQ(0, sigaltstack(&altstack, &oldstack));
|
||||||
|
UnmapOrDie(oldstack.ss_sp, oldstack.ss_size);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
10
gcc.spec
10
gcc.spec
@ -61,7 +61,7 @@
|
|||||||
Summary: Various compilers (C, C++, Objective-C, ...)
|
Summary: Various compilers (C, C++, Objective-C, ...)
|
||||||
Name: gcc
|
Name: gcc
|
||||||
Version: %{gcc_version}
|
Version: %{gcc_version}
|
||||||
Release: 10
|
Release: 11
|
||||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
||||||
URL: https://gcc.gnu.org
|
URL: https://gcc.gnu.org
|
||||||
|
|
||||||
@ -149,6 +149,7 @@ Patch30: 0030-AutoBOLT-Add-bolt-linker-plugin-2-3.patch
|
|||||||
Patch31: 0031-AutoBOLT-Enable-BOLT-linker-plugin-on-aarch64-3-3.patch
|
Patch31: 0031-AutoBOLT-Enable-BOLT-linker-plugin-on-aarch64-3-3.patch
|
||||||
Patch32: 0032-Autoprefetch-Prune-invaild-loops-containing-edges-wh.patch
|
Patch32: 0032-Autoprefetch-Prune-invaild-loops-containing-edges-wh.patch
|
||||||
Patch33: 0033-AutoFdo-Fix-memory-leaks-in-autofdo-and-autoprefetch.patch
|
Patch33: 0033-AutoFdo-Fix-memory-leaks-in-autofdo-and-autoprefetch.patch
|
||||||
|
Patch34: 0034-Backport-sanitizer-Fix-asan-against-glibc-2.34-PR100.patch
|
||||||
|
|
||||||
%global gcc_target_platform %{_arch}-linux-gnu
|
%global gcc_target_platform %{_arch}-linux-gnu
|
||||||
|
|
||||||
@ -623,6 +624,7 @@ not stable, so plugins must be rebuilt any time GCC is updated.
|
|||||||
%patch31 -p1
|
%patch31 -p1
|
||||||
%patch32 -p1
|
%patch32 -p1
|
||||||
%patch33 -p1
|
%patch33 -p1
|
||||||
|
%patch34 -p1
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
@ -2589,6 +2591,12 @@ end
|
|||||||
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri May 6 2022 liyancheng <412998149@qq.com> - 10.3.1-11
|
||||||
|
- Type:Sync
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:Sync patch from openeuler/gcc
|
||||||
|
|
||||||
* Tue Mar 22 2022 benniaobufeijiushiji <linda7@huawei.com> - 10.3.1-10
|
* Tue Mar 22 2022 benniaobufeijiushiji <linda7@huawei.com> - 10.3.1-10
|
||||||
- Type:Sync
|
- Type:Sync
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user