From patchwork Wed Feb 26 11:33:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11406297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF9E5930 for ; Wed, 26 Feb 2020 11:42:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BBE3824687 for ; Wed, 26 Feb 2020 11:42:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="XYBhg+R8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBE3824687 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j6v3s-0002sc-2Q; Wed, 26 Feb 2020 11:41:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j6v3q-0002rx-Qo for xen-devel@lists.xenproject.org; Wed, 26 Feb 2020 11:41:06 +0000 X-Inumbo-ID: df8c658a-588c-11ea-a490-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id df8c658a-588c-11ea-a490-bc764e2007e4; Wed, 26 Feb 2020 11:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582717267; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CgqtPNdj3Dl7hyOtfntE04Kdu5PkFy1yAtmPoJq5ApA=; b=XYBhg+R8BxMwWQ4qc+ihGsvEWe0dg1uPi6ytxiVgCHgiaTuDAXsXkKAj jeTSB9Eg5ohy6cmKSenvnz+O02laIPGlAEr24bCzavAOEl6QgsEqJImre MokfXjhvsgiTjugGbzMVSpCzDdHEvgC+cTa4PnZJ0WNlwP/cCl3Yt51i0 k=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: AetCv0TGQ5Zx2JsD6BVOR0tcUMLdZuaz0pl+3ajTcyztKcpWKMQl9qazH3ftVWIre0q3goZc7M bj+XQ2+d4GNyf2SgqOADpk3mk9r0nR3X3EdR7zc5QNsrFmTEBkO7FR2Qy5uOdazmSIQ4TLjfSd Sc065fln3YhWje7rls726pTd3H29lV2NVB3bDhlZIgWf84KIm5eZ9gfbc0Dp3ND85qpDBLmi5b ksFLGyc8jiXvh7PY8o8aYI4mP0r1bLMdBwSwHsTXbcQzGppCdXAHWjS+TvNykvA7p6Wfh36zLP MlQ= X-SBRS: 2.7 X-MesageID: 13211249 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,487,1574139600"; d="scan'208";a="13211249" From: Anthony PERARD To: Date: Wed, 26 Feb 2020 11:33:54 +0000 Message-ID: <20200226113355.2532224-23-anthony.perard@citrix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200226113355.2532224-1-anthony.perard@citrix.com> References: <20200226113355.2532224-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH v3 22/23] xen, symbols: rework file symbols selection 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 , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Rework symbols so it prefer file symbols that names an object file to file symbols that have a directory component. But have symbols still prefer the first file symbol if one of the above is true, or prefer the second file symbols if it names a source file without directory component. In a future patch, we are going want to run $(CC) from the root directory (xen.git/xen that is). So the guest_walk_%.o files are going to have two file symbols, one with a directory component and another one which name an object file. We still want to prefer the file symbols that names an object file, no mater if it is first or second. And before running everything from the root directory, we will be able to use the same runes to build the guest_%.o as to build any other %.o files from %.c files (the rule with the objcopy --redefine-sym). Signed-off-by: Anthony PERARD --- xen/tools/symbols.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/xen/tools/symbols.c b/xen/tools/symbols.c index 9f9e2c990061..b7a00b4be487 100644 --- a/xen/tools/symbols.c +++ b/xen/tools/symbols.c @@ -80,11 +80,17 @@ static inline int is_arm_mapping_symbol(const char *str) && (str[2] == '\0' || str[2] == '.'); } +enum symbol_type { + symbol = 0, + single_source = 1, + dir_source = 2, + obj_source = 3, +}; static int read_symbol(FILE *in, struct sym_entry *s) { char str[500], type[20] = ""; char *sym, stype; - static enum { symbol, single_source, multi_source } last; + static enum symbol_type last; static char *filename; int rc = -1; @@ -125,13 +131,19 @@ static int read_symbol(FILE *in, struct sym_entry *s) * prefer the first one if that names an object file or has a * directory component (to cover multiply compiled files). */ - bool multi = strchr(str, '/') || (sym && sym[1] == 'o'); - - if (multi || last != multi_source) { + enum symbol_type current; + if (sym && sym[1] == 'o') + current = obj_source; + else if (strchr(str, '/')) + current = dir_source; + else + current = single_source; + + if (current > last || last == single_source) { free(filename); filename = *str ? strdup(str) : NULL; + last = current; } - last = multi ? multi_source : single_source; goto skip_tail; }