From patchwork Mon Sep 26 05:53:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tianyi Liu X-Patchwork-Id: 12988228 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD880C07E9D for ; Mon, 26 Sep 2022 05:54:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbiIZFyB (ORCPT ); Mon, 26 Sep 2022 01:54:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbiIZFyA (ORCPT ); Mon, 26 Sep 2022 01:54:00 -0400 Received: from AUS01-ME3-obe.outbound.protection.outlook.com (mail-me3aus01olkn2174.outbound.protection.outlook.com [40.92.63.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F96222B5 for ; Sun, 25 Sep 2022 22:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a96kc4uchasaj8JBToQfR6K3I2N9DYndeKTXB0f9BoTlhlpI1XJMexJgNPUJ096Wp4lUvr9zPznPiyqO4rh/WJOJmkqeCkh097ZR2LW44VrGSJRabWrqkDZ/leehPMBISrAwg4niGIq6gZxZRzGk59CKjv1xjaepd1FPsltgxZaSMt6UiJj77IIP0EKdWqRoLjp38xWQk0yEpV0BzdHpeD/lkAjGhebYcCo7etopEwm6idzDvLRsWDXebNt7Z3+rw3U6FbCVxlO3oG58UO+91kKcbUJmGnYBrIaqckewGVuUhO3IFfIx90sApUPJIwVE7PiN1VLSrelwjxrd9/gN0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o8sbbyi+GmhQfBKTowlwm24/MVC3bPhK/HlpliuyC/M=; b=WBRK+HAdmyRkHMYmNX6VhCps5Iiln4M85pUy0BRr+JCheOJeCuJSjHwdsFKCXDaPwwv40Hr2DmRhJRLpd3zG90HVH1fYYiitPstSQHloCFkDWui8QE2I4jK2ZPqN7xuY8qyBe6Ww6kMfOuVJyXeTX2Vl5p3toJ8RbAwoHVtxjES6MQ8q3XGNiyM9RuZFrv5056A7OfGGuMM+KEhvw9Qd6RGqARQy1U4fSJ7TTmDOOuMbmLCyPW0L1Obyzpi3MORRo+gG73yEs24igClU/5MSNw8wVOJOzzhuDfsEIEuE6sN+PbLCbVS1FKO9nMmNai6358U22yheJgNFpDhFl0rPIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o8sbbyi+GmhQfBKTowlwm24/MVC3bPhK/HlpliuyC/M=; b=uzcyW/M7jSZQcCQuzT4dB+oyA59FcVJJN2jyEvfJAWdWFXN0iTcjue+LRrvw2tZ2zUgAVgn7Q+BAXH/clK746E4Xb2F2tOzdxa4kuensN93pOu9J48nk1RDUwE/xviRKDJfh6krdZdOgqsHOI34ytufpHLyu0hHzksyIG5DnpWKtLQKKCBiLiwIKqmLwMTOOoTXwFUpf04N3lSdDYidU5QBVLtNnKYUeQJOOjW12XBQo++69SZjJMJPqxfTplQcKk4wuHaxU0szhalzcAXzgCBjubeHuhqJomu8iE7mxcVwWOwjh6a3jdR8NTKo/CzKzmqKNkDJ7b9i1hGLLFdsDfA== Received: from SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:ac::13) by SYBP282MB0219.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:64::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.22; Mon, 26 Sep 2022 05:53:55 +0000 Received: from SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM ([fe80::549a:65d7:eae8:3983]) by SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM ([fe80::549a:65d7:eae8:3983%7]) with mapi id 15.20.5654.025; Mon, 26 Sep 2022 05:53:55 +0000 From: Tianyi Liu To: andrii@kernel.org Cc: bpf@vger.kernel.org, trivial@kernel.org, Tianyi Liu Subject: [PATCH] libbpf: Add friendly error prompt for missing .BTF section Date: Mon, 26 Sep 2022 13:53:16 +0800 Message-ID: X-Mailer: git-send-email 2.37.3 X-TMN: [dJrkSN0qj7TrcdPVAftlRYUIqcNgoHjzNMxfrLK/2ONAamC8qL+gjA==] X-ClientProxiedBy: SI2PR02CA0030.apcprd02.prod.outlook.com (2603:1096:4:195::17) To SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:ac::13) X-Microsoft-Original-Message-ID: <20220926055316.2411573-1-i.pear@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SY4P282MB1084:EE_|SYBP282MB0219:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ddc1bad-b817-4110-32fc-08da9f837f06 X-MS-Exchange-SLBlob-MailProps: ZILSnhm0P3kzD6Up0rDzZ8UqTTLWxQanAYElf40bL0Uw++QjI1YBu6kI/fD646wq2WU0aKpS1AnxbnK1+Rlxm4H3sau3Uuy6tE6Z4F3fplUuIELC4zvHqcxlpDoh5gOODjtDjRpTYaWSfr2nVaQz+T/82/M3HmyCJKqWCJ5idewm4VOmgDIJSnowW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psBHkF6Z0kVAie9ND4iXNARMDhwIam29APeIZTk9vX8YV02IycOCUQo94sKkQBKoBhDbdFt4sCTRy6omh0ogAiiBhSWKTRi+dhkYfoyTLIZ+k11+9shTDwTHPBqa3REuAR0UwRwQyGiJb+cuXC0ut8LIfnWTAxd7RBZIbN5jh8vtvlxCEKOaJWYDBLA940xFxz8oUpqh05ooLy7TFV++dTsOsH2kS0BhsWH3nVF03MMSChrOH3M3mwftxtfGOeppueyjkpFhOwHqtdtE/pfie6HQseDNIULmsnVKKLx9xjKddK2jkPweUNfzoSiRKMJGmAiLCB5wxNv2+Sd4yVhZDWvh6kpa8kmiCxdEaI8Oc5wLnKXQ1GPjvCZxXZNbGN/lqJ3dS7ZByBarcHXWkGP9gNIlT15NG3oQnATosWDdOsXBuawOODJR9Vk1Knb5N2F4zH4V2O7JwbBptVEh5MXG/vv0h2jFwSxrv6OzOSoMiYe1fAKBRUcCGxz8ETmzEX+hNDvaNL/SxRTIJA/dzbRd/2uTg5rAok7Ggj0R9HOwb2b8= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ddc1bad-b817-4110-32fc-08da9f837f06 X-MS-Exchange-CrossTenant-AuthSource: SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 05:53:55.1209 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SYBP282MB0219 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Fresh users usually forget to turn on BTF generating flags compiling kernels, and will receive a confusing error "No such file or directory" (from return value ENOENT) with command "bpftool btf dump file vmlinux". Hope this can help them find the mistake. Signed-off-by: Tianyi Liu --- tools/lib/bpf/btf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index 2d14f1a52..9fbae1f3d 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c @@ -990,6 +990,8 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf, err = 0; if (!btf_data) { + pr_warn("Failed to get section %s from ELF %s, check CONFIG_DEBUG_INFO_BTF if compiling kernel\n", + BTF_ELF_SEC, path); err = -ENOENT; goto done; }