From patchwork Tue Jun 11 06:02:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenbaodong X-Patchwork-Id: 10985995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E48614B6 for ; Tue, 11 Jun 2019 06:04:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0442827F85 for ; Tue, 11 Jun 2019 06:04:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC6F02870C; Tue, 11 Jun 2019 06:04:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1025E27F85 for ; Tue, 11 Jun 2019 06:04:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haZrk-0000DY-Gl; Tue, 11 Jun 2019 06:02:40 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haZrj-0000DT-Lk for xen-devel@lists.xenproject.org; Tue, 11 Jun 2019 06:02:39 +0000 X-Inumbo-ID: 82ad88bb-8c0e-11e9-8980-bc764e045a96 Received: from mxnavi-mail.mxnavi.com (unknown [116.90.87.199]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 82ad88bb-8c0e-11e9-8980-bc764e045a96; Tue, 11 Jun 2019 06:02:37 +0000 (UTC) Received: from localhost.localdomain (61.161.186.150) by mxnavi-mail.mxnavi.com (116.90.87.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Tue, 11 Jun 2019 13:59:26 +0800 From: Baodong Chen To: Date: Tue, 11 Jun 2019 14:02:29 +0800 Message-ID: <1560232949-10673-1-git-send-email-chenbaodong@mxnavi.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [61.161.186.150] X-ClientProxiedBy: mxnavi-mail.mxnavi.com (116.90.87.199) To mxnavi-mail.mxnavi.com (116.90.87.199) Subject: [Xen-devel] [PATCH] xen/coverage: wrap coverage related things under 'CONFIG_COVERAGE' X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Baodong Chen , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Constructors between '__ctors_start' and '__ctors_end' only used for code-coverage, not by xen itself, so use 'CONFIG_COVERAGE' wrap them. Signed-off-by: Baodong Chen --- xen/arch/arm/xen.lds.S | 2 ++ xen/arch/x86/xen.lds.S | 2 ++ xen/common/lib.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 1e72906..320ff68 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -172,12 +172,14 @@ SECTIONS *(.init.data.rel) *(.init.data.rel.*) +#if defined(CONFIG_COVERAGE) . = ALIGN(8); __ctors_start = .; *(.ctors) *(.init_array) *(SORT(.init_array.*)) __ctors_end = .; +#endif #if defined(CONFIG_HAS_VPCI) && !defined(CONFIG_LATE_HWDOM) . = ALIGN(POINTER_ALIGN); diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index cb42dc8..604353f 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -240,12 +240,14 @@ SECTIONS *(.altinstructions) __alt_instructions_end = .; +#if defined(CONFIG_COVERAGE) . = ALIGN(8); __ctors_start = .; *(.ctors) *(.init_array) *(SORT(.init_array.*)) __ctors_end = .; +#endif #if defined(CONFIG_HAS_VPCI) && !defined(CONFIG_LATE_HWDOM) . = ALIGN(POINTER_ALIGN); diff --git a/xen/common/lib.c b/xen/common/lib.c index 8ebec81..b8fc165 100644 --- a/xen/common/lib.c +++ b/xen/common/lib.c @@ -491,15 +491,20 @@ unsigned long long parse_size_and_unit(const char *s, const char **ps) return ret; } +#if defined(CONFIG_COVERAGE) typedef void (*ctor_func_t)(void); extern const ctor_func_t __ctors_start[], __ctors_end[]; +#endif +/* see 'docs/hypervisor-guide/code-coverage.rst' */ void __init init_constructors(void) { +#if defined(CONFIG_COVERAGE) const ctor_func_t *f; for ( f = __ctors_start; f < __ctors_end; ++f ) (*f)(); +#endif /* Putting this here seems as good (or bad) as any other place. */ BUILD_BUG_ON(sizeof(size_t) != sizeof(ssize_t)); }