Received: by 10.223.176.46 with SMTP id f43csp275981wra; Tue, 23 Jan 2018 20:51:43 -0800 (PST) X-Google-Smtp-Source: AH8x227GWL6zJJhqj6MAYuPJwHy9J1GZspwWMDy6cbVVEQ0gJr4NBOA/JfjblyInRpKo9V21dyhs X-Received: by 2002:a17:902:590e:: with SMTP id o14-v6mr6834036pli.78.1516769503511; Tue, 23 Jan 2018 20:51:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516769503; cv=none; d=google.com; s=arc-20160816; b=A2douBvtyOQbLmlM7mO62Ach9KGxAG/P4htSFUHhogLw19RvJwM3RA5+hTDg1OQqJk o/MyfiyoHjXKTK4w4YCBERyB/K9LuGY1Dhlfh7ETZ2a5TzOhcTScpn7Hvy9QfnFdZeEK Lv65j9T1F6ITqk7hyHc35FV4l87c/VFCzKCo5+YsK+RpfA0HTxx50S6hnicklRHXwr7C K4dqhSsEMCEa/HOLHynzn2r1zzQ2xywT43mjwqP8d3V5f8DsS+tTA4ghaaLIoWuNKeBb uZgYLk5trZHHrN8L2N5TlREv63OZ8a8Ubp+pC69l4ccmhAQAXwa+DSQA2nly2tvcqzIg NTDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=xHmyHd/C/Qw6ybEsosNnvetpovL8dirs42l+ToE7+R8=; b=EX41A+j+njaE0euOIsVKitvnnQhQdycrfEig0SwhL80BMIMU5C/Dw/MeD1+D60XeMu fhuZa547VACjgSPiZO9s2MZOrVzY3cPc4R+OzwRZPvk944gqass5t8YSqeJodXnhIKLQ nnyWgt8dBZT/tnD6hFbva6lVdWiqNK8TPCxQCDzWPrzgELzZiKAT+AUa+IrEkJw3mzTb qaalKkPNHhwijNoGpkhD93Cf+XnM6jU633U5GTP2wQzHAd94tnQMcaDRvoYFSVpLuhPM Gwc2DPc6HukHH8jFiBzT6jnYSc/BLdkHCSrYAoTTmPs2tbFbWJ5hKlhdTQSZZmfHBs+g AycQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=RjwHE7L+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g29si15659989pgn.132.2018.01.23.20.51.29; Tue, 23 Jan 2018 20:51:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=RjwHE7L+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932721AbeAXEug (ORCPT + 99 others); Tue, 23 Jan 2018 23:50:36 -0500 Received: from mail-by2nam03on0117.outbound.protection.outlook.com ([104.47.42.117]:41259 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932478AbeAXEQF (ORCPT ); Tue, 23 Jan 2018 23:16:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=xHmyHd/C/Qw6ybEsosNnvetpovL8dirs42l+ToE7+R8=; b=RjwHE7L+wAvAS7b6vTQ0r1KTPKoQuoIPYd1PJl5jGAoBnP1ld8VR0b8ZvX5p6Qksjg7J4RGz0zxp1FJ2CdnF8Xl6vFrpWnqqmk7DtDbyPhX64c6rP4EM9lZ9LYO8dpsG9hPUqADhgtQSBNmM/n8Npk8OWgmuXOfEqpLH7aHoFlI= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1078.namprd21.prod.outlook.com (52.132.130.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.1; Wed, 24 Jan 2018 04:15:59 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:15:59 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: "Liu, Changcheng" , Kate Stewart , NeilBrown , Thomas Gleixner , Greg Kroah-Hartman , "Andrew Morton" , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 076/100] scripts/faddr2line: extend usage on generic arch Thread-Topic: [PATCH AUTOSEL for 4.14 076/100] scripts/faddr2line: extend usage on generic arch Thread-Index: AQHTlMnpNzynPNo47UmUBuqcVnYIOw== Date: Wed, 24 Jan 2018 04:15:04 +0000 Message-ID: <20180124041414.32065-76-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1078;7:JQP6yt0T1gBegjbXDWUElpV8xR6AS49CcSV2yBXR+6lQt0drFLs6+PtqfvWgfKh9qAwqbwkXygEDrMum5KM21wyKKn2FJOQh4yQS/hKg5ZisHg4WF4WRb4XB/K7PCNi6Nwks8pzcPaFrgH7ytHe/t/fpK73Kj4sVCLMa/0U0kKErg9VzqyOYdFJ88XJmxXHBZxaDzT35FJelMresOys5T1hYOhQ4LQ3q1FeXNuEvVezaQqjtaAnwxl0P1OhgnsD5 x-ms-office365-filtering-correlation-id: 352d7332-01b9-45d9-fc3c-08d562e12c83 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB1078; x-ms-traffictypediagnostic: DM5PR2101MB1078: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(42068640409301)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231046)(2400081)(944501161)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1078;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1078; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(39860400002)(366004)(396003)(39380400002)(199004)(189003)(86612001)(22452003)(6436002)(106356001)(107886003)(102836004)(105586002)(305945005)(5250100002)(2501003)(14454004)(3280700002)(4326008)(7736002)(97736004)(6306002)(6512007)(36756003)(8936002)(2950100002)(3846002)(6116002)(6506007)(86362001)(54906003)(76176011)(110136005)(966005)(2906002)(6666003)(53936002)(66066001)(72206003)(6346003)(5660300001)(8676002)(478600001)(10290500003)(68736007)(81156014)(10090500001)(1076002)(3660700001)(25786009)(316002)(2900100001)(99286004)(575784001)(26005)(6486002)(81166006)(22906009)(41533002)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1078;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: m/jET5NMpIkFe2SeE1U48gCMJq2qu+TYjA7wzibfwWaDVB9OjApkkK8ETWZOBZo2xMnoEKx15EMIfXolK9t2lg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 352d7332-01b9-45d9-fc3c-08d562e12c83 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:15:04.3241 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1078 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Liu, Changcheng" [ Upstream commit 95a87982541932503d3f59aba4c30b0bde0a6294 ] When cross-compiling, fadd2line should use the binary tool used for the target system, rather than that of the host. Link: http://lkml.kernel.org/r/20171121092911.GA150711@sofia Signed-off-by: Liu Changcheng Cc: Kate Stewart Cc: NeilBrown Cc: Thomas Gleixner Cc: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- scripts/faddr2line | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/faddr2line b/scripts/faddr2line index 1f5ce959f596..39e07d8574dd 100755 --- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -44,9 +44,16 @@ set -o errexit set -o nounset =20 +READELF=3D"${CROSS_COMPILE}readelf" +ADDR2LINE=3D"${CROSS_COMPILE}addr2line" +SIZE=3D"${CROSS_COMPILE}size" +NM=3D"${CROSS_COMPILE}nm" + command -v awk >/dev/null 2>&1 || die "awk isn't installed" -command -v readelf >/dev/null 2>&1 || die "readelf isn't installed" -command -v addr2line >/dev/null 2>&1 || die "addr2line isn't installed" +command -v ${READELF} >/dev/null 2>&1 || die "readelf isn't installed" +command -v ${ADDR2LINE} >/dev/null 2>&1 || die "addr2line isn't installed" +command -v ${SIZE} >/dev/null 2>&1 || die "size isn't installed" +command -v ${NM} >/dev/null 2>&1 || die "nm isn't installed" =20 usage() { echo "usage: faddr2line ..." >&2 @@ -69,10 +76,10 @@ die() { find_dir_prefix() { local objfile=3D$1 =20 - local start_kernel_addr=3D$(readelf -sW $objfile | awk '$8 =3D=3D "start_= kernel" {printf "0x%s", $2}') + local start_kernel_addr=3D$(${READELF} -sW $objfile | awk '$8 =3D=3D "sta= rt_kernel" {printf "0x%s", $2}') [[ -z $start_kernel_addr ]] && return =20 - local file_line=3D$(addr2line -e $objfile $start_kernel_addr) + local file_line=3D$(${ADDR2LINE} -e $objfile $start_kernel_addr) [[ -z $file_line ]] && return =20 local prefix=3D${file_line%init/main.c:*} @@ -104,7 +111,7 @@ __faddr2line() { =20 # Go through each of the object's symbols which match the func name. # In rare cases there might be duplicates. - file_end=3D$(size -Ax $objfile | awk '$1 =3D=3D ".text" {print $2}') + file_end=3D$(${SIZE} -Ax $objfile | awk '$1 =3D=3D ".text" {print $2}') while read symbol; do local fields=3D($symbol) local sym_base=3D0x${fields[0]} @@ -156,10 +163,10 @@ __faddr2line() { =20 # pass real address to addr2line echo "$func+$offset/$sym_size:" - addr2line -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;" + ${ADDR2LINE} -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;" DONE=3D1 =20 - done < <(nm -n $objfile | awk -v fn=3D$func -v end=3D$file_end '$3 =3D=3D= fn { found=3D1; line=3D$0; start=3D$1; next } found =3D=3D 1 { found=3D0; = print line, "0x"$1 } END {if (found =3D=3D 1) print line, end; }') + done < <(${NM} -n $objfile | awk -v fn=3D$func -v end=3D$file_end '$3 =3D= =3D fn { found=3D1; line=3D$0; start=3D$1; next } found =3D=3D 1 { found=3D= 0; print line, "0x"$1 } END {if (found =3D=3D 1) print line, end; }') } =20 [[ $# -lt 2 ]] && usage --=20 2.11.0