From patchwork Mon Oct 24 11:31:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8367 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp392462wru; Mon, 24 Oct 2022 04:35:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM545cvTaKfUKt+F8l/HQG26By4VPLgQeWORm64A84ISqIslEm9EROUCGN6e8l4fq/xfEsmY X-Received: by 2002:a05:6402:5409:b0:44f:1e05:1e8 with SMTP id ev9-20020a056402540900b0044f1e0501e8mr30104745edb.373.1666611320957; Mon, 24 Oct 2022 04:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666611320; cv=none; d=google.com; s=arc-20160816; b=xx9oVFIJgti7EL3r8ptfSlgoo/CQogObD2tSq02olEGjtQgr3Pb3WPeOn500kfolWa 6L1DFPSZZOLs/fWKZcja72YHXT5SA7tiPn0Ms+wmRt4UrYl5JoAhGbbihkccFb/rWb82 UjubkZeZEerSHrXipDC5BSzdHPwqmMulhQ9DHc0vqxNLXMXiNAT9LjlxeYoERWc7fO5x 3WEXWdOKe2O0A1Lb1LL6r0xjFdEeYsu6JzYfh3GYLv7B+jvAvN4PruMtP5/2gs7m3y1b uzdpFrneLlBnfZC0EzYfJkhDCwiseeqtfr7NaXQRzzT7085A95lt5CAiQRXHz/EaEZUc 7HVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ozCVv1Z7Nxh914ZQ32W+kEmGACgzjl8+va6hqN3WM1o=; b=M+d16urPjNLwPmiSaMPlFW5OgxJ5ala8jqeCdmgd12CX1Y/6IXbkXNU0qOzsBJ//MH ///yj/b9K73x/D0ZuSHOvVWSKWlmXoYooNXG/unJTz/gzm0nmBwmfleB9ZNafthY1oCr zBE1kDehX1UmwfRd6JBC56KmD83Oj554PA3h6Z8oVy3kN6jMr3URZjv/Au9ETdQfxhka rvrrfueosEDJ2w3zQeJlqVJqR8O0ynBMDyZ8zEobZIVnQtFehxMTkhceh25tl/9uCupo EtuEypAk9oJPVYD1gdUWgVilXIuYtL0S5ERW3fLdmEsg/+RV5xt1/Z3hR3eH77PVQbr/ iVvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XUhX/Qiy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du3-20020a17090772c300b007417040d1c5si26321318ejc.823.2022.10.24.04.34.56; Mon, 24 Oct 2022 04:35:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XUhX/Qiy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbiJXLc2 (ORCPT + 99 others); Mon, 24 Oct 2022 07:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbiJXLcO (ORCPT ); Mon, 24 Oct 2022 07:32:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C6246113C; Mon, 24 Oct 2022 04:32:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0B80361269; Mon, 24 Oct 2022 11:32:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17560C433D7; Mon, 24 Oct 2022 11:32:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611121; bh=GaP2zY4gDt9q7SPS4N2nf0KNAmezYbQqo06Tm3bRLT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XUhX/QiyGIGs+heuCG/5umB6mRfS8s4Ngl5HRjhgqYMH0k3R40Q8aX7KNP1qzcggM KAPUva+wXkNToX1a9swPCUG4piDKkaItLddK/TttyFaHFKaXAzBBQQRfy7azfSD9O0 uBbogihLl+ByfsG5O7RXj1ehhISY7QBNpdT2jp8Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Liska , Peter Oberparleiter , Andrew Morton Subject: [PATCH 6.0 17/20] gcov: support GCC 12.1 and newer compilers Date: Mon, 24 Oct 2022 13:31:19 +0200 Message-Id: <20221024112935.104167318@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112934.415391158@linuxfoundation.org> References: <20221024112934.415391158@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747568632781835100?= X-GMAIL-MSGID: =?utf-8?q?1747568632781835100?= From: Martin Liska commit 977ef30a7d888eeb52fb6908f99080f33e5309a8 upstream. Starting with GCC 12.1, the created .gcda format can't be read by gcov tool. There are 2 significant changes to the .gcda file format that need to be supported: a) [gcov: Use system IO buffering] (23eb66d1d46a34cb28c4acbdf8a1deb80a7c5a05) changed that all sizes in the format are in bytes and not in words (4B) b) [gcov: make profile merging smarter] (72e0c742bd01f8e7e6dcca64042b9ad7e75979de) add a new checksum to the file header. Tested with GCC 7.5, 10.4, 12.2 and the current master. Link: https://lkml.kernel.org/r/624bda92-f307-30e9-9aaa-8cc678b2dfb2@suse.cz Signed-off-by: Martin Liska Tested-by: Peter Oberparleiter Reviewed-by: Peter Oberparleiter Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- kernel/gcov/gcc_4_7.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/kernel/gcov/gcc_4_7.c +++ b/kernel/gcov/gcc_4_7.c @@ -30,6 +30,13 @@ #define GCOV_TAG_FUNCTION_LENGTH 3 +/* Since GCC 12.1 sizes are in BYTES and not in WORDS (4B). */ +#if (__GNUC__ >= 12) +#define GCOV_UNIT_SIZE 4 +#else +#define GCOV_UNIT_SIZE 1 +#endif + static struct gcov_info *gcov_info_head; /** @@ -383,12 +390,18 @@ size_t convert_to_gcda(char *buffer, str pos += store_gcov_u32(buffer, pos, info->version); pos += store_gcov_u32(buffer, pos, info->stamp); +#if (__GNUC__ >= 12) + /* Use zero as checksum of the compilation unit. */ + pos += store_gcov_u32(buffer, pos, 0); +#endif + for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) { fi_ptr = info->functions[fi_idx]; /* Function record. */ pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION); - pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH); + pos += store_gcov_u32(buffer, pos, + GCOV_TAG_FUNCTION_LENGTH * GCOV_UNIT_SIZE); pos += store_gcov_u32(buffer, pos, fi_ptr->ident); pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum); pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); @@ -402,7 +415,8 @@ size_t convert_to_gcda(char *buffer, str /* Counter record. */ pos += store_gcov_u32(buffer, pos, GCOV_TAG_FOR_COUNTER(ct_idx)); - pos += store_gcov_u32(buffer, pos, ci_ptr->num * 2); + pos += store_gcov_u32(buffer, pos, + ci_ptr->num * 2 * GCOV_UNIT_SIZE); for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) { pos += store_gcov_u64(buffer, pos,