From patchwork Fri Feb 24 08:20:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 65574 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EFA873857BA4 for ; Fri, 24 Feb 2023 08:20:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id D8C45385840F for ; Fri, 24 Feb 2023 08:20:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D8C45385840F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1B34D386D7; Fri, 24 Feb 2023 08:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1677226827; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4if4fqgNo/FJA3UQufIruMGhskQuayembQ4CsF1ooe8=; b=ZoFNDjMkejDxroHSph21dhuB5qcQPO59QGSFdXU7ezuVtkEE2JB00RlbQdkZZRaiQ7jJBf byumCwcIr3ycvjobJYxYs9bEcl0KKVZaxxxkVAEs6eZHlhmgVBPEUbW9QG32uPH9pDf9FX U14kBADME3rICr09hcg2sGSIbghpWDI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1677226827; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4if4fqgNo/FJA3UQufIruMGhskQuayembQ4CsF1ooe8=; b=4MxfDKmwfq1ABVsTW+9AtpN5uTjMLlyfrquWTUzmeFWLLX4YrprLDY/Vi5NfDP+ny6cjWs 4al7TFbSZmN2dZCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F093113A3A; Fri, 24 Feb 2023 08:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KCPyOEpz+GOUFQAAMHmgww (envelope-from ); Fri, 24 Feb 2023 08:20:26 +0000 Message-ID: Date: Fri, 24 Feb 2023 09:20:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH (pushed)] libsanitizer: cherry-pick commit 8f5962b1ccb5fcd4d4544121d43efb860ac3cc6d from upstream To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: Jakub Jelinek X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" ASAN: keep support for Global::location We as GCC still emit __asan_global_source_location for global variables and we would like to use it in the future. On other hand, we don't support llvm-symbolizer and the default libbacktraace symbolizer does not support location info. --- libsanitizer/asan/asan_globals.cpp | 9 +++++++++ libsanitizer/asan/asan_interface_internal.h | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libsanitizer/asan/asan_globals.cpp b/libsanitizer/asan/asan_globals.cpp index 8f3491f0199..01a243927ca 100644 --- a/libsanitizer/asan/asan_globals.cpp +++ b/libsanitizer/asan/asan_globals.cpp @@ -92,6 +92,10 @@ static void ReportGlobal(const Global &g, const char *prefix) { if (info.line != 0) { Report(" location: name=%s, %d\n", info.file, static_cast(info.line)); } + else if (g.gcc_location != 0) { + // Fallback to Global::gcc_location + Report(" location: name=%s, %d\n", g.gcc_location->filename, g.gcc_location->line_no); + } } static u32 FindRegistrationSite(const Global *g) { @@ -283,6 +287,11 @@ void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g) { if (info.line != 0) { str->append("%s:%d", info.file, static_cast(info.line)); + } else if (g.gcc_location != 0) { + // Fallback to Global::gcc_location + str->append("%s", g.gcc_location->filename ? g.gcc_location->filename : g.module_name); + if (g.gcc_location->line_no) str->append(":%d", g.gcc_location->line_no); + if (g.gcc_location->column_no) str->append(":%d", g.gcc_location->column_no); } else { str->append("%s", g.module_name); } diff --git a/libsanitizer/asan/asan_interface_internal.h b/libsanitizer/asan/asan_interface_internal.h index 987f855c0f9..a9982637802 100644 --- a/libsanitizer/asan/asan_interface_internal.h +++ b/libsanitizer/asan/asan_interface_internal.h @@ -53,9 +53,10 @@ extern "C" { const char *module_name; // Module name as a C string. This pointer is a // unique identifier of a module. uptr has_dynamic_init; // Non-zero if the global has dynamic initializer. - uptr windows_padding; // TODO: Figure out how to remove this padding - // that's simply here to make the MSVC incremental - // linker happy... + __asan_global_source_location *gcc_location; // Source location of a global, + // used by GCC compiler. LLVM uses + // llvm-symbolizer that relies + // on DWARF debugging info. uptr odr_indicator; // The address of the ODR indicator symbol. };