From patchwork Mon Feb 1 17:25:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 12059499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE0C8C433DB for ; Mon, 1 Feb 2021 17:26:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DA8464EAC for ; Mon, 1 Feb 2021 17:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231216AbhBAR0T (ORCPT ); Mon, 1 Feb 2021 12:26:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231150AbhBAR0O (ORCPT ); Mon, 1 Feb 2021 12:26:14 -0500 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8318C0613D6 for ; Mon, 1 Feb 2021 09:25:59 -0800 (PST) Received: by mail-wr1-x44a.google.com with SMTP id h18so10816898wrr.5 for ; Mon, 01 Feb 2021 09:25:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=bySTPITy9sEnX+OFrzSlCOjPXE0Wa2TKXWqG2xvgd+c=; b=u8+A7I39tOd9zkrrMGHaFVw5BoE5GnWa2aSfeajcOa+GlpgI0FEG0aW67lmSZOUB12 cQfH1YTKJzqjGIcB6hC72ZeZRHURRRlQdVYx7CgN5vIA34vrQtEt4MUuqygxK+HWxO5F aKNL18FIxU1nSgRZJ4qFhMZ+lEHXYvUI7LUvChyU2EFhrd62zN/dI1dX1h+sj/ZaJeip QsmxEw/QknfaGzPW7Sp+qxtLvhY3NUTjah4MRb+mGF4dDc5f5QvYPOowVw58vmHYAc6t fQUMt2gyKAQTAlbRQJ2L3QQDFwEyuo3Yy2YY960xF2SdaIWhm2OnJHxsRUOJP8/nmfaY EaEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bySTPITy9sEnX+OFrzSlCOjPXE0Wa2TKXWqG2xvgd+c=; b=YjGuhhAD8IfXLcq5asfqvxpirFPF82dbi+tEKCPmC1nvtVJ0lcx1KI+FDyT00PaVc+ 5+OdKeVuWawIo6Lmi4ii671l8Kx0J6FJ/dp99eo2gwTwNIQCOclCHT+8CSTO+RCWfzjK XQyxVxIHG9yQ5M4m7FUmBluU5g/2ysUXKtprgu5zobLjs1fEAS3pqbQiGMSQujIuGv0S YZSv+rVPtSNRPxF2kjIxEFF/UcVCn6Xg3hY+1aoZT82j2kxctBASA+sAXLZmR4CRE+Ds LmLBLwoFgjuXzQrSEfDZvzBbcORo24ZHNLwURNdYPXhmaoh0Kcs5XeHMbFXWkky6w5C8 UmzA== X-Gm-Message-State: AOAM530lzdTJuIYXREbO01FeZqayGIhKI2aSuLFaiQ3d606w0ychFP0+ FuSOEGiJ6mWQqZhq4u1BkflIw09OpB2F0w== X-Google-Smtp-Source: ABdhPJwJqVGtfXk95YE5FB941yz9MW9nsqyP8zx/EwScVXa+eMv7vjwup5OsI9K+ctRUuvac/eydimMW2Jbgqg== Sender: "gprocida via sendgmr" X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:210:6893:b158:d9db:277c]) (user=gprocida job=sendgmr) by 2002:a7b:cb54:: with SMTP id v20mr16412653wmj.148.1612200358590; Mon, 01 Feb 2021 09:25:58 -0800 (PST) Date: Mon, 1 Feb 2021 17:25:26 +0000 In-Reply-To: <87a83353155506cc02141e6e4108d89aa4e7d284> Message-Id: <20210201172530.1141087-1-gprocida@google.com> Mime-Version: 1.0 References: <87a83353155506cc02141e6e4108d89aa4e7d284> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH dwarves v2 0/4] BTF ELF writing changes From: Giuliano Procida To: dwarves@vger.kernel.org Cc: acme@kernel.org, andrii@kernel.org, ast@kernel.org, gprocida@google.com, maennich@google.com, kernel-team@android.com, kernel-team@fb.com, bpf@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Note: The 4 patches in this series supersede patches 2-4 of the previous version of this series (patch 1 was applied). pahole -J currently uses llvm-objcopy to add .BTF as a section (and segment) to an ELF object containing DWARF debug information. If a .BTF section is already present it is rewritten but segment information is not updated. In terms of the current Linux linker script, all that's needed is either a dump of the raw BTF or a file containing a .BTF section. This is because the script dumps .BTF out to a file, creates a single-section ELF file and then links this into a final vmlinux. The first commit in this series removes the dependency on llvm-objcopy. The remaining commits attempt to roughly duplicate the desired end result, namely adding a .BTF section which is also a loadable segment. They may not be sufficient. In terms of non-kernel .BTF use, they are probably not necessary. Nevertheless, this was an interesting exercise and removing the llvm-objcopy dependency is a worthwhile goal. I'm not well-placed to test the viability of vmlinux with .BTF as generated by these patches, so any feedback is very welcome. Giuliano Procida (4): btf_encoder: Add .BTF section using libelf btf_encoder: Manually lay out updated ELF sections btf_encoder: Add .BTF as a loadable segment btf_encoder: Align .BTF section/segment to 8 bytes libbtf.c | 240 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 197 insertions(+), 43 deletions(-)