Received: by 10.223.176.5 with SMTP id f5csp994647wra; Fri, 2 Feb 2018 09:24:24 -0800 (PST) X-Google-Smtp-Source: AH8x225suI3XEAtmlgMiaYwzCBcj/YCj+eGEm8rO9q5/xlixzOwdjjr8TO+fQEQ0QNflpuCHvMgO X-Received: by 10.99.117.28 with SMTP id q28mr25231658pgc.37.1517592264076; Fri, 02 Feb 2018 09:24:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592264; cv=none; d=google.com; s=arc-20160816; b=pQvXHnogmjapZP+Uy/TJS48X+ahGQDlYVoM/00WPq+rvuLNM3MullInLBYy+EphCQr 7XW/OyUo3YUuARTzExgNJqJp0WLx5huwrRtQKH1W/xOyysiMOujFWPPxt5YBZKz/VAYN s/+4Xe87W8GC3AcaSXhHSL7UM3nmoxGHhCCoal0fPrtlCLX3UNIPl1uguQn8wQTdc94X ltEPFyLdzgi3QEmlbvg8S5RHxld/juhXlX5FX3u1x/fiSxM8FGBPDfpajrra+/D6Zz/P el5opgfV9RGu86Y4V6Od55tl+TB6h/SWqHQWKiMlJaGHFboJikorqMPEL+a4XkhDdY/6 SCbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vwPauLzrJzyMYYsaAgjfygYF+F2lUSOYXJQfAi0+SBw=; b=QXNLDlOvtrO8p/A83BGOvmmajz599n4c/RXTRAVJpAuT0wBR62IiMAoevyP7mFFoWa Pq182Wt1x4BzqFYPrMI4NKtA5Zo0B5xvYb55sNYQbKec7+fI52D5OO4wm59TDhBkuQEd u9N1dPmn46x3xuGH+U045clqku3cZ0cpUwR2XswUkOUdct6hAi3v6pnk0fhVgIWjuIu+ CWoov2AfUUo86RR3ePDcJ00rk4Cwz9sJBqgKnuy1atJqRCB1lkPboco0bu5p4AcGUiX1 CMNCAPrSSkHnauVHzgQM5SK4WXnBB8lwE5I8nFgHzQ6QiK/2pwnA867y0AiuRRaaZ/jb YS8w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k185si197066pge.131.2018.02.02.09.24.09; Fri, 02 Feb 2018 09:24:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753571AbeBBRVo (ORCPT + 99 others); Fri, 2 Feb 2018 12:21:44 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39234 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753411AbeBBRNL (ORCPT ); Fri, 2 Feb 2018 12:13:11 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3DF09E27; Fri, 2 Feb 2018 17:13:10 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Changcheng , Kate Stewart , NeilBrown , Thomas Gleixner , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 103/156] scripts/faddr2line: extend usage on generic arch Date: Fri, 2 Feb 2018 17:58:04 +0100 Message-Id: <20180202140844.857269882@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- scripts/faddr2line | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) --- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -44,9 +44,16 @@ set -o errexit set -o nounset +READELF="${CROSS_COMPILE}readelf" +ADDR2LINE="${CROSS_COMPILE}addr2line" +SIZE="${CROSS_COMPILE}size" +NM="${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" usage() { echo "usage: faddr2line ..." >&2 @@ -69,10 +76,10 @@ die() { find_dir_prefix() { local objfile=$1 - local start_kernel_addr=$(readelf -sW $objfile | awk '$8 == "start_kernel" {printf "0x%s", $2}') + local start_kernel_addr=$(${READELF} -sW $objfile | awk '$8 == "start_kernel" {printf "0x%s", $2}') [[ -z $start_kernel_addr ]] && return - local file_line=$(addr2line -e $objfile $start_kernel_addr) + local file_line=$(${ADDR2LINE} -e $objfile $start_kernel_addr) [[ -z $file_line ]] && return local prefix=${file_line%init/main.c:*} @@ -104,7 +111,7 @@ __faddr2line() { # Go through each of the object's symbols which match the func name. # In rare cases there might be duplicates. - file_end=$(size -Ax $objfile | awk '$1 == ".text" {print $2}') + file_end=$(${SIZE} -Ax $objfile | awk '$1 == ".text" {print $2}') while read symbol; do local fields=($symbol) local sym_base=0x${fields[0]} @@ -156,10 +163,10 @@ __faddr2line() { # 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=1 - done < <(nm -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }') + done < <(${NM} -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }') } [[ $# -lt 2 ]] && usage