From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1147) id 05B473858D28; Mon, 7 Aug 2023 09:32:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05B473858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691400744; bh=/2+JEhnw+Df1OcTIvi9L3ujRfl3CQ/e9E41OASvB2Bw=; h=From:To:Subject:Date:From; b=jVZk2rcCULGhgP6y3TMueunT3FMQ4ZW3TG9BImM1dfo24MeiMI67aKRaeou5eLUyf U19/8cX4zl9FfOfEJ08JggniIsZJIRTI5ufsGv7/TrMEdu6fvNWSiU3G27NCTy0BZh 5QFPeEmb07GnDohhcbUTshbHH8/JRaqavehkep9k= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Rainer Orth To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7690] libsanitizer: Fix SPARC stacktraces X-Act-Checkin: gcc X-Git-Author: Rainer Orth X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: a8792b8429aa562e82cb83ff4661ca9d3f26500f X-Git-Newrev: 10bde732dbc972b0f0dd1f4318f54b399dbc0ffa Message-Id: <20230807093224.05B473858D28@sourceware.org> Date: Mon, 7 Aug 2023 09:32:24 +0000 (GMT) List-Id: https://gcc.gnu.org/g:10bde732dbc972b0f0dd1f4318f54b399dbc0ffa commit r13-7690-g10bde732dbc972b0f0dd1f4318f54b399dbc0ffa Author: Rainer Orth Date: Mon Aug 7 11:31:56 2023 +0200 libsanitizer: Fix SPARC stacktraces As detailed in LLVM Issue #57624 (https://github.com/llvm/llvm-project/issues/57624), a patch to sanitizer_internal_defs.h broke SPARC stacktraces in the sanitizers. The issue has now been fixed upstream (https://reviews.llvm.org/D156504) and I'd like to cherry-pick that patch. Bootstrapped without regressions on sparc-sun-solaris2.11. 2023-07-27 Rainer Orth libsanitizer: * sanitizer_common/sanitizer_stacktrace_sparc.cpp, sanitizer_common/sanitizer_unwind_linux_libcdep.cpp: Cherry-pick llvm-project revision 679c076ae446af81eba81ce9b94203a273d4b88a. Diff: --- libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp | 6 ------ libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp b/libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp index 1e635a66978..a2000798a39 100644 --- a/libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp @@ -30,13 +30,7 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top, // TODO(yln): add arg sanity check for stack_top/stack_bottom CHECK_GE(max_depth, 2); const uptr kPageSize = GetPageSizeCached(); -#if defined(__GNUC__) - // __builtin_return_address returns the address of the call instruction - // on the SPARC and not the return address, so we need to compensate. - trace_buffer[0] = GetNextInstructionPc(pc); -#else trace_buffer[0] = pc; -#endif size = 1; if (stack_top < 4096) return; // Sanity check for stack top. // Flush register windows to memory diff --git a/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp index 72f025a7d30..6a8e82e2e21 100644 --- a/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp @@ -139,13 +139,7 @@ void BufferedStackTrace::UnwindSlow(uptr pc, u32 max_depth) { if (to_pop == 0 && size > 1) to_pop = 1; PopStackFrames(to_pop); -#if defined(__GNUC__) && defined(__sparc__) - // __builtin_return_address returns the address of the call instruction - // on the SPARC and not the return address, so we need to compensate. - trace_buffer[0] = GetNextInstructionPc(pc); -#else trace_buffer[0] = pc; -#endif } void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {