Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1465714rdb; Mon, 2 Oct 2023 10:14:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvKtIGPiVMle56Qm0yuOEPMl+Ua4hT+CY0nji18yAREJIwWMA7FSdc/CfOFTPldydyeBD4 X-Received: by 2002:a05:6a21:99a9:b0:15a:4c23:870b with SMTP id ve41-20020a056a2199a900b0015a4c23870bmr246720pzb.23.1696266858689; Mon, 02 Oct 2023 10:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696266858; cv=none; d=google.com; s=arc-20160816; b=pwCebn6v72TbycZpiFcGUspJQcSE7PphbrUCoPc/J3gXBVIiKVT9/3RRd4CvjZLWFD 7ITTfY9AN0vTMs6Lfz1686FNrI8hNzsoiYrnT+NTJeaFj/Ss59dRiWPZcS0egAfZyrvP c0vAwDK02v4qBMOAwtMlTcHJJa88Vikp4TCwXzKzuJJw0dSEhlz3PIIMeJupMi4MBtii czYynBU1cflXH3a0LAZdExU1XiwhvXbbswkVYQQpytI+ql9hPdp9aAqbxTt3z9M8Zrqs cBcOqzjkBr5jG7xDG5cnMu2OGek9CK/qSmdEDhZ9enyWZhqRbhjWEdAOUEJOIk3bbwFH Rp2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B4uK+QPSy4uIhY7R+BFV64JW37Qs22KfohUkE3hrJ98=; fh=wjEl6BofP0c7WzG34c/USSQ7C1FfAme8r/K9vYTfZuw=; b=dY4uz5EV+i9X+n6tn1bP8XBX0oZ9+8Skr8+4EANJAudbEvG1cmMUfWR4pJq6GetzHl Pick5BLxNQN+odu/+bUguFJvePvO0wrYXbyPnLG20VfJNqJ9hepsGq7L/vuVEYMpbv0x pl0Q330DPEdPkJJFCPFCIf1hcWu9hXDW+WMOHSx7ElXqFQeANEBxcWysmZjSHd26vSpt CVMekoyNXcQ6167en6bq4W3bQM4iecZNM4G5j+0MRlXndJA/aIz7l+iZoEX9LX+ReHg8 0N+cdUAH+DVloIbSjkKXozdAKapN4niDSuaNQCptji+lulY6N7RzM+wNruzaHW4Ff4D9 FrtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=smS5zvrQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k21-20020a628415000000b00692a899f7a1si24863102pfd.40.2023.10.02.10.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 10:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=smS5zvrQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2FB2D802A9D9; Mon, 2 Oct 2023 09:58:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238564AbjJBQ6H (ORCPT + 99 others); Mon, 2 Oct 2023 12:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238546AbjJBQ6G (ORCPT ); Mon, 2 Oct 2023 12:58:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0264B8; Mon, 2 Oct 2023 09:58:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CEE9C433C7; Mon, 2 Oct 2023 16:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696265882; bh=q5YCA8p0CGC7cTGNfTdRfhSsu0Oi56m79bI+z6AlhIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=smS5zvrQR+zwmmjSJOrtQGBHEGCoK9wYqujaWmDDRGeHNtGeUZ5yPgbZGMXTK2u+x AW8tODwGP5hVzlD0/G6LuTLfzTslF9o5X2rhAtCDzLOxadA0j66DBebRXWUi1sbp+9 TdNm6VV3MivgjNXLYi2V84DAQ0hVShAmQWPUjodVam4s7JTCbMBhPKV73ml/++V3uN jwAvEyLfyzujWkMNOrIRG/MzGBudnLWmnHCjOu0cWcfdKuyOZwsnUSwt7wBCwKrjCG mXABdfgP2hAdr52MbifgZup1jO4ZM6unX39omk5yuoYov7cKTzppRQoOPcTIZOJdzA pG3ghlndlW0wQ== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, Will Deacon , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Josh Poimboeuf , John Stultz , linux-kbuild@vger.kernel.org Subject: [PATCH v5 2/3] scripts/faddr2line: Use LLVM addr2line and readelf if LLVM=1 Date: Mon, 2 Oct 2023 17:57:48 +0100 Message-Id: <20231002165750.1661-3-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20231002165750.1661-1-will@kernel.org> References: <20231002165750.1661-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 09:58:31 -0700 (PDT) GNU utilities cannot necessarily parse objects built by LLVM, which can result in confusing errors when using 'faddr2line': $ CROSS_COMPILE=aarch64-linux-gnu- ./scripts/faddr2line vmlinux do_one_initcall+0xf4/0x260 aarch64-linux-gnu-addr2line: vmlinux: unknown type [0x13] section `.relr.dyn' aarch64-linux-gnu-addr2line: DWARF error: invalid or unhandled FORM value: 0x25 do_one_initcall+0xf4/0x260: aarch64-linux-gnu-addr2line: vmlinux: unknown type [0x13] section `.relr.dyn' aarch64-linux-gnu-addr2line: DWARF error: invalid or unhandled FORM value: 0x25 $x.73 at main.c:? Although this can be worked around by setting CROSS_COMPILE to "llvm=-", it's cleaner to follow the same syntax as the top-level Makefile and accept LLVM= as an indication to use the llvm- tools, optionally specifying their location or specific version number. Cc: Josh Poimboeuf Cc: John Stultz Suggested-by: Masahiro Yamada Signed-off-by: Will Deacon --- scripts/faddr2line | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/faddr2line b/scripts/faddr2line index a35a420d0f26..6b8206802157 100755 --- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -58,8 +58,21 @@ die() { exit 1 } -READELF="${CROSS_COMPILE:-}readelf" -ADDR2LINE="${CROSS_COMPILE:-}addr2line" +UTIL_SUFFIX="" +if [[ "${LLVM:-}" == "" ]]; then + UTIL_PREFIX=${CROSS_COMPILE:-} +else + UTIL_PREFIX=llvm- + + if [[ "${LLVM}" == *"/" ]]; then + UTIL_PREFIX=${LLVM}${UTIL_PREFIX} + elif [[ "${LLVM}" == "-"* ]]; then + UTIL_SUFFIX=${LLVM} + fi +fi + +READELF="${UTIL_PREFIX}readelf${UTIL_SUFFIX}" +ADDR2LINE="${UTIL_PREFIX}addr2line${UTIL_SUFFIX}" AWK="awk" GREP="grep" -- 2.42.0.582.g8ccd20d70d-goog