Received: by 10.223.164.202 with SMTP id h10csp4909187wrb; Tue, 21 Nov 2017 01:31:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMac76Zo/O5YyilPORxN5TeUAHbu3Ahyo9qIDeqc55HQHNbzQJpWvLK3/N3G72AkXQfa3Hpa X-Received: by 10.99.117.70 with SMTP id f6mr16804369pgn.339.1511256707417; Tue, 21 Nov 2017 01:31:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511256707; cv=none; d=google.com; s=arc-20160816; b=FFyuLoVvN/MdtgQjdSihS2LW/ChQFZ7X8BH6H618bWfjbv/38lOEvfpgYqwBfZJu9E 2bqH1clhcF6TcCcFlIWimxnIJawBScqnGjyK7avf92puNWiAYe7oOhehYMq+fyA+t6tj 0V1WYo94XHYsYXgd9TxneKq6tZ+sUbbUes/vLMcl2gKciiTNsWMUGM8My6i9Dsh8Xn2I hwBQfAIWQUiRQAMHaJOo+R39oNOVrq5itgRW4xJgCTeSu1BJ/1rmC/aQeB9GMRrg04/S kgErU4G2Nzp1wPSu9RGlVnkfKa+Gxo423WP0OZlTNjUYOH3Lf+y5ukMBbe4czxHwc6ta rpYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=KniB6/n/+seyQ/sKYvhL5jbiI9ReRYBZ6GRvvKDFO6M=; b=bBSIidlaq0WZgAbzcuQGoxq+v76LiiNDmxi6ky5S0PotAqiGDGE/xkCjJcwUjR50Gq bjB3YuRRDcI0iwyqX3ByqElBsvzmc4j1MUWRvbU/qtOVOfvTRoFe3dvSvNqFOCgGJ1qh AWJ26Kl3rUGEMrN+N//s7vuXFk4QaR/VLqZBENmJjAgOR0pnNq6AM61GePMvBa3k/nEt czjbm3GlzFzXywXlL6d6Q7V7wHcHd+z2Lzw3Ak7vX1DszeKpfwM4IdKAl10rnCzyKg1J d9K0cuGROZGgiB441E42xos3WzXM5XoOfVxzcJUqaWVRg4KvBso5QQDIks69pXV1zBRe Sfig== 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 n69si11482192pfk.214.2017.11.21.01.31.36; Tue, 21 Nov 2017 01:31:47 -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 S1751935AbdKUJad (ORCPT + 72 others); Tue, 21 Nov 2017 04:30:33 -0500 Received: from mga11.intel.com ([192.55.52.93]:47647 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751741AbdKUJa2 (ORCPT ); Tue, 21 Nov 2017 04:30:28 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2017 01:30:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,432,1505804400"; d="scan'208,217";a="151729628" Received: from sofia.sh.intel.com (HELO sofia) ([10.239.147.120]) by orsmga004.jf.intel.com with ESMTP; 21 Nov 2017 01:30:26 -0800 Date: Tue, 21 Nov 2017 17:29:12 +0800 From: "Liu, Changcheng" To: kstewart@linuxfoundation.org, neilb@suse.com, tglx@linutronix.de, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, changcheng.liu@intel.com Subject: [PATCH] scripts/faddr2line: extend usage on generic arch Message-ID: <20171121092911.GA150711@sofia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fadd2line script should use the binary tool used for the target system. Signed-off-by: Liu Changcheng diff --git a/scripts/faddr2line b/scripts/faddr2line index 1f5ce95..39e07d8 100755 --- 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 -- 2.7.4 From 1585993432727553631@xxx Wed Dec 06 00:46:42 +0000 2017 X-GM-THRID: 1585993432727553631 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread