From patchwork Mon Oct 24 11:33:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp481908wru; Mon, 24 Oct 2022 07:23:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pARVUuCr58/ZH9TIRFN+kjvLxL6AC9NLSjfKV5AApiwS3MjzHU4rf4xDuIupXNBLyDBTg X-Received: by 2002:a05:6402:501a:b0:457:f093:cadb with SMTP id p26-20020a056402501a00b00457f093cadbmr30429052eda.143.1666621439602; Mon, 24 Oct 2022 07:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621439; cv=none; d=google.com; s=arc-20160816; b=YHL9JNXUOMaF1+DVD5sSKH1BVTy407Ha6Z+IzMzzsKKWOGcQbFUghv8uIn/W3IK8LJ eyxLnOp9OhuQyQs9/9Ypid9JMM7raa7t2d0YqFLDUPvQl3jSPsYzXRsELpuIbirddPEE AFsGyadUppkhwNaJl5g+w/CZVplDLlj4S1WGm3fgxiDMe5HuecQhHkS1oWpA70vo60n7 plmN4xagcrWfTxvLReER1fAxn+o79yJ6SmFV2ClrJmepSO1bgQGISVrbm4ooCDXYF022 w6q6ATMaPjd9zRAkLEA1maBfgR1a+uRgjjCzpOfu2NX3npQo8vk4fID+QzghcrTzhPyO sR1A== 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=/83USHCMB2hdYmRPH12/clGeKyqK4sNW52edn+MhCbo=; b=rlRWaHmSR4BQOx/mziSkxKTXKFQpdjGCAbJHKhM3Z7GgMprZ0iCz3fR4gGV67Q0rLK nSdZNxNbqpOd6fvEtQ/vwB78f9ryRBHQjLbkUFTZu/DUIBSjDdCQDszScTPsCGJtLx1a l3FVJQ39bInXCd7QK7q5H9YAOFx5I8YT9pL71q18gTYJQLhm16raNUPCE99VLa8pEwGm oOouUucoSQQKavXaeZJjauJ0ps33z+kUX+xBstbCueebZ65cCF09LJv3RDDEf3imA75m u/F9bTN7Hlf/+6/+JmSQk3CsSriDEEzl1N4csMy8smwnnn1jHMmuBw4J9pGlti802ha1 8FRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nq5gbjgP; 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 v15-20020a170906180f00b0078d20d71475si24243088eje.413.2022.10.24.07.23.35; Mon, 24 Oct 2022 07:23:59 -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=nq5gbjgP; 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 S235843AbiJXOWP (ORCPT + 99 others); Mon, 24 Oct 2022 10:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233583AbiJXOQf (ORCPT ); Mon, 24 Oct 2022 10:16:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89D2BCC836; Mon, 24 Oct 2022 05:56:02 -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 7B380B8171A; Mon, 24 Oct 2022 12:33:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D056BC433C1; Mon, 24 Oct 2022 12:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614796; bh=QHolA/OG9b0aq0+4xFDwS22hchZVMgKudTulwkkkeH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nq5gbjgP6pv0emZCv5n7lcXV0/W/4JB+iliVPSs6G0IcNDaeWFC9aWeutAd4pCYyO RQg3ZVADg+XiByk3oZ/qejCBBZLp3/b7sNuOuuuwqPT0l+4B/HOd5FVVKl8aZ+GLvV SRgirzZuWjWkKzmVhA7Beuc+HMVM5kv2yvTmsKnY= 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 5.10 390/390] gcov: support GCC 12.1 and newer compilers Date: Mon, 24 Oct 2022 13:33:07 +0200 Message-Id: <20221024113039.579086999@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747579242888088837?= X-GMAIL-MSGID: =?utf-8?q?1747579242888088837?= 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; /** @@ -451,12 +458,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); @@ -470,7 +483,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,