From nobody Wed Sep 3 06:38:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1278C38A2D for ; Mon, 24 Oct 2022 12:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230496AbiJXMmZ (ORCPT ); Mon, 24 Oct 2022 08:42:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234301AbiJXMjd (ORCPT ); Mon, 24 Oct 2022 08:39:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 656998A7FE; Mon, 24 Oct 2022 05:07:08 -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 45B8D61254; Mon, 24 Oct 2022 12:04:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58C2FC433C1; Mon, 24 Oct 2022 12:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613074; bh=0+56YQKLRS3I50WR/rVpZJDlwNIJzh94dKECmtCa8lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i1tTvQKOvkN8DBtVPbJCe9WCB3kZ3Gh2G/+xi//3IVXgFro+JAXcO/fMXqEmr32xZ Hy1h7dKQHHfYM3CCG4Hu8H+1LcXV7IsKteIOTyHaheh0t1p5yX1w+rrzLMdJ9DFXYn umXQHXD/ou/q8pi1GaafZlhN7kBz8kVEKkKzjwUk= 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.19 229/229] gcov: support GCC 12.1 and newer compilers Date: Mon, 24 Oct 2022 13:32:28 +0200 Message-Id: <20221024113006.684314336@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 @@ =20 #define GCOV_TAG_FUNCTION_LENGTH 3 =20 +/* Since GCC 12.1 sizes are in BYTES and not in WORDS (4B). */ +#if (__GNUC__ >=3D 12) +#define GCOV_UNIT_SIZE 4 +#else +#define GCOV_UNIT_SIZE 1 +#endif + static struct gcov_info *gcov_info_head; =20 /** @@ -439,12 +446,18 @@ static size_t convert_to_gcda(char *buff pos +=3D store_gcov_u32(buffer, pos, info->version); pos +=3D store_gcov_u32(buffer, pos, info->stamp); =20 +#if (__GNUC__ >=3D 12) + /* Use zero as checksum of the compilation unit. */ + pos +=3D store_gcov_u32(buffer, pos, 0); +#endif + for (fi_idx =3D 0; fi_idx < info->n_functions; fi_idx++) { fi_ptr =3D info->functions[fi_idx]; =20 /* Function record. */ pos +=3D store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION); - pos +=3D store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH); + pos +=3D store_gcov_u32(buffer, pos, + GCOV_TAG_FUNCTION_LENGTH * GCOV_UNIT_SIZE); pos +=3D store_gcov_u32(buffer, pos, fi_ptr->ident); pos +=3D store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum); pos +=3D store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); @@ -458,7 +471,8 @@ static size_t convert_to_gcda(char *buff /* Counter record. */ pos +=3D store_gcov_u32(buffer, pos, GCOV_TAG_FOR_COUNTER(ct_idx)); - pos +=3D store_gcov_u32(buffer, pos, ci_ptr->num * 2); + pos +=3D store_gcov_u32(buffer, pos, + ci_ptr->num * 2 * GCOV_UNIT_SIZE); =20 for (cv_idx =3D 0; cv_idx < ci_ptr->num; cv_idx++) { pos +=3D store_gcov_u64(buffer, pos,