From patchwork Mon Oct 24 11:29:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp418262wru; Mon, 24 Oct 2022 05:14:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5LxjtejdkXs3Pke/EAJ7jPBS8+n9xgiBwHZafXraTNB1ASDD8xqkF766Vf8yxKuMDg3qW7 X-Received: by 2002:a17:907:9688:b0:7a5:74eb:d12b with SMTP id hd8-20020a170907968800b007a574ebd12bmr5837241ejc.60.1666613660622; Mon, 24 Oct 2022 05:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666613660; cv=none; d=google.com; s=arc-20160816; b=RIoPVR3DNkeq9YiBOJTVIALS2K/iiARd4ipUp2n8cQRtD7JJS7Na4/qQpygMeukdeS TLPbk3InDr0PdSElsdHxi/7IBdkamToPVjtcXEWzCpDemO6HGO2YdDgh+rU8ZqQgAr48 dIANGvjKL0X69lATn5Wnd3JziS5GU/kKpv50L88/YXFR8zSr3mPWzmhd9dH9EZ5/P7FS GqO6zu6Hj8mhQESKfshizTs5SE5uzrk/MEIz/iJEFe5AoD+2x7EYmGeAB4pAAJBnOH5n 9/Ao4H03S0JYKV+NCJsbEDvi6zrk46s/Dx4IaUe96wC9wS0OktEcDPGXGOzYLVFTfEst tMwA== 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=E3LFXV2vyuRDWnSXKx01IaPvG9g3EwNCRRsEgRJ1rQs=; b=AaE9CU4eYHn/VjDkd9IB+mQ4xgt+qoqdw91Zd4N81RSvbK3ZjG1sR5RfOUVnoTB/rn Ut1Zv9jvXrOIRdzfVkojtDWHbjuQigSO9XiY4ja9LW+AskcgCl15N7K4vlqUNbccUq7b HLKNu5b554ps6y+L3JzTEQiTfaQcQAuHurg/8Yju1hD1VJyOZgsn3VOLW9FqLQLo8Hp8 gvgiYLzYzT/C5jLr7XwYAY/RRMCu0bh48Slo8rQoo9ZeKfSQaNLeS/P01EXQQ/ygBQkb WqDRdC2+VV5pWxs/aQASwGh/+EaI3lpy0/QHw/SPdk5zCYc+8DKFj8rqLxFnoqDk6L2U 2QNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0UpgXqRe; 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 o7-20020a056402038700b004592ebc28a9si23363988edv.59.2022.10.24.05.13.56; Mon, 24 Oct 2022 05:14: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=0UpgXqRe; 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 S232617AbiJXMF6 (ORCPT + 99 others); Mon, 24 Oct 2022 08:05:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbiJXMD4 (ORCPT ); Mon, 24 Oct 2022 08:03:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14B504B4B2; Mon, 24 Oct 2022 04:50:06 -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 ams.source.kernel.org (Postfix) with ESMTPS id 1A8C8B811A1; Mon, 24 Oct 2022 11:48:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6537AC433C1; Mon, 24 Oct 2022 11:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612122; bh=0+56YQKLRS3I50WR/rVpZJDlwNIJzh94dKECmtCa8lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0UpgXqReQz47ptCu7Yhozcknkc6IVdokyOlX+rk5XaeOAZ/bdxYaNMwW9+hD15IcV zajoXCcsCOeGOZE9k2ciiKp5jQYY07+uVtjqy6FNvq80sd8nqoN8ePyov7OuUf9meG uJ/542Icvs/Zfq0rzXqFOI01DSryf7MacurfT0ek= 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 4.14 079/210] gcov: support GCC 12.1 and newer compilers Date: Mon, 24 Oct 2022 13:29:56 +0200 Message-Id: <20221024112959.627318144@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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?1747571085720575993?= X-GMAIL-MSGID: =?utf-8?q?1747571085720575993?= 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 @@ -33,6 +33,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; /** @@ -439,12 +446,18 @@ static size_t convert_to_gcda(char *buff 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); @@ -458,7 +471,8 @@ static size_t convert_to_gcda(char *buff /* 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,