From patchwork Mon Oct 24 11:29:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp433989wru; Mon, 24 Oct 2022 05:51:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HW7EiAZaxJp4+PD78SUoJkGSwhwyYMTaUyLSH2pI7BCQybMA2HIs3ZK29tc73/MTAA0E0 X-Received: by 2002:a17:907:3da2:b0:78d:45df:b4f with SMTP id he34-20020a1709073da200b0078d45df0b4fmr26809535ejc.651.1666615864575; Mon, 24 Oct 2022 05:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615864; cv=none; d=google.com; s=arc-20160816; b=tv7WPBa1QXgPnytxMeyg9CtbI5OtctKyTeH3goQsmUsLVk2wbQczQWq2ASMDmr+6+2 YrBnm79y2AC4nj8G9COrFvmmF/CnzDGzKMaMtvG3LLo3wVfflMGY8TRxjmOsjdufGxpQ /5zDoa1bJKQ5YHrbzoFYrZBZdH09wTEXyID4Sg0EehoomGgR7fPtWh9GrtP/klYTXGPA /cQUJqShidUpmN6uiX1M/ZRdLK+QPUSNiNrasm5S+hy/TMmI/lZMCUWY/j1bjwIWU6gB uLUTQYaDnwR0pnUaMeG7sFJVzO7RdmZlZ83a1ZejGzIZoClrGB3VJqvfP1tcpMSujuW8 Pt+A== 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=pFbvJ17t4cnFzFaMItM/oI0Pcu3pvuGoGrxnvTG1UWOhgtK4eaQpQhu/+baj6vWCAT z+pMZ3mhrsAmQ5u7w00ESe29ojVlayT3B2N5Oa3PIJQC66kCP/Zp8fa5IrKjzf5RKEDY G1B/oDyJHqatyTH/YRqYyKhPCaokpj2doCZo+TlzCjsuUwhQJLI0OJ7aN9Iyy0QpegyG A8Vj6UhwmJRWM2G7uMlsgEmEV7sIRoWmRn6lO1rjCQ2+n66aBkab8+VRW/ZFdveVk/mx ibF3eOiS78YjRXYjThL83jhkpYKB4s1P0uBVLVGuFRNIqPXJVTQxpsxpFkM0FzC/43Nb PANg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fNPn1cCL; 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 du18-20020a17090772d200b007835897050esi8869309ejc.404.2022.10.24.05.50.37; Mon, 24 Oct 2022 05:51:04 -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=fNPn1cCL; 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 S234835AbiJXMtc (ORCPT + 99 others); Mon, 24 Oct 2022 08:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234476AbiJXMo4 (ORCPT ); Mon, 24 Oct 2022 08:44:56 -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 E731F201BD; Mon, 24 Oct 2022 05:09:39 -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 92A51612BE; Mon, 24 Oct 2022 12:08:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2FCFC433D6; Mon, 24 Oct 2022 12:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613327; bh=QHolA/OG9b0aq0+4xFDwS22hchZVMgKudTulwkkkeH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fNPn1cCLK7QzJz0Jp2xpnjUj/S1v4vvYFl6nU8YEI1t7Q8Y4yc1cNRH5m2vCXDRCo iZD5Dl2t35TNbeqUeTKMkUD0fEtt4yyGn9rgosRAipk0qQIRQHpwmFSs6l8tOLF3IM +a5SWCZRmxLAysntQEz8gL6ud5Y38piwnBssJ6EY= 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.4 055/255] gcov: support GCC 12.1 and newer compilers Date: Mon, 24 Oct 2022 13:29:25 +0200 Message-Id: <20221024113004.332068147@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573397054692783?= X-GMAIL-MSGID: =?utf-8?q?1747573397054692783?= 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,