From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792794485; b=ZpCmZMLOFGiWdPqrEWd2h/ayupecgZbgH9PmNe4BiEEyWGOd6/6EhC9r9t8QllLX1BU6 meWX+ipvBl0B7oAqxAZQcSrybJM/UuH1w4r/U4cBqeN6XObMoZmMlBBSrURy20G9UmIj7 jQgErwZmZwfpVoVYOyVKWmTv41/g1BzZSJNMp8PD8AfdUDiwa6OrYas5kYE2wpjnuqrRy h/mzHtazeNXdwOh13tLHfSgvPV/Ube1QyrJKiwg7EjtISXecXTURszLZp4swkk2EcO52W Z7woGuvBKDni9PEx7KBqB3m+6/sm9hct3bSj4yL25lsQLTwVAtzO8FJrhTX3g0iMdiw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792794485; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=nfL/6O+UYvR55i4b28y0k8Ew1YOsyUsrcv8efDkJ+Cs=; b=InSb5FIc4rHsmG72ScWXur4zYSzHpnbHJw6AQDMq/Hlf72JADNzpLsT2Uety19VuHiX4 2xZXopB88OBLKEGjTF1bCU47A3Mm4mXeGMhPfKZ9iSP4e7yIPx/M+SOtsUMLZgpizoasO y4E4rbx94GGR4gPxsUvbr0rqkTRLKs/YaY680mg15m0uKaTc9+Mh7m+8Yu2tzo6ob7oZx 388YyWan+EElZ9EnTStEgvP3RnOI+d2spHfiUhf3OFtfO53JcOAo4mW0f9W9N7gLgNDhY I3zRRG+dsL9/WZGplklwVXn2uUlBTjUl7yjvUNiX9N06wT+4IebeZrYM9j9Lpuj1sgw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=MM5cXIVI; arc=none smtp.remote-ip=91.218.175.199 Received: from mta0.migadu.com (out-199.mta0.migadu.com [91.218.175.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BB68606A31A for ; Fri, 23 Oct 2026 22:28:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6BB68606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=MM5cXIVI X-Envelope-To: bpf@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=BFtWNdUo8ncSHplX5nvDfwS76LG+oU8YdeHz6lF6174=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1792794482; v=1; x=1793399282; b=MM5cXIVIaGTXLlsp1viaeYgA3uBV8gXKHbbNHXl6zr2UEIsC0QXLshvUJwlpnkGh22fNv+3U RDXgm69Zh4URXKwSk7bJhDUimUoYu7yuoqgMpC+GufTorJ8kmoaZkplG3GfARWQ6ppYBS0d1lc0 0TAoyM3N8o4jJhp3O3lOy2vk= X-Envelope-To: bpf@vger.kernel.org Received: by mta10.migadu.com with ESMTPS id 4b251ea6c7576f0e; Fri, 23 Oct 2026 22:28:02 +0000 X-Mizu-Trace-ID: 4b251ea6c7576f0e X-Migadu-Flow: FLOW_OUT From: Ihor Solodrai To: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Eduard Zingerman , Kumar Kartikeya Dwivedi , Quentin Monnet Cc: bpf@vger.kernel.org, Alan Maguire , Cupertino Miranda , David Faust , Ian Rogers , "Jose E . Marchesi" , Vineet Gupta , Yonghong Song Subject: [PATCH bpf-next v2 8/8] bpftool: Document __bpf_relocatable and __bpf_static_offset Date: Fri, 23 Oct 2026 15:26:52 -0700 Message-ID: <20261023222652.3927736-9-ihor.solodrai@linux.dev> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261023222652.3927736-1-ihor.solodrai@linux.dev> References: <20261023222652.3927736-1-ihor.solodrai@linux.dev> X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The C dump annotates records with the __bpf_relocatable and __bpf_static_offset macros. Programs control the attributes through these macros and BPF_NO_PRESERVE_ACCESS_INDEX, which disables only __bpf_relocatable. Update bpftool documentation to explain both macros, and how to avoid the Clang crash on CO-RE field-info builtins over __bpf_static_offset types. Signed-off-by: Ihor Solodrai --- .../bpf/bpftool/Documentation/bpftool-btf.rst | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/bpf/bpftool/Documentation/bpftool-btf.rst b/tools/bpf/bpftool/Documentation/bpftool-btf.rst index c6dc445cd4a1..37fef36a14fb 100644 --- a/tools/bpf/bpftool/Documentation/bpftool-btf.rst +++ b/tools/bpf/bpftool/Documentation/bpftool-btf.rst @@ -70,6 +70,30 @@ bpftool btf dump *BTF_SRC* [format *FORMAT*] [root_id *ROOT_ID*] formatting, the output is sorted by default. Use the **unsorted** option to avoid sorting the output. + C output annotates struct and union definitions individually. Most + records carry ``__attribute__((__bpf_relocatable))``. The generated + header defines ``__bpf_relocatable`` as ``preserve_access_index`` where + supported, or as empty when **BPF_NO_PRESERVE_ACCESS_INDEX** is defined + or the compiler lacks the attribute. GCC-BPF can apply CO-RE through + these attributes. + + Context and socket types whose field accesses the verifier rewrites + carry ``__attribute__((__bpf_static_offset))`` instead, and their nested + anonymous records carry no attribute. ``__bpf_static_offset`` expands to + ``preserve_static_offset`` where supported (Clang 18 and later), or to + empty otherwise. The attribute keeps static field offsets in load and + store instruction immediates. **BPF_NO_PRESERVE_ACCESS_INDEX** does + not affect ``__bpf_static_offset``. + + Either macro may be pre-defined as a bare attribute name, such as + ``preserve_access_index``, or as empty to override the policy. + + Clang 18 through 23 crash when ``__builtin_preserve_field_info`` is used + on a type marked ``__bpf_static_offset``, including through + ``bpf_core_field_*`` and the CO-RE bitfield helpers. Compile with + ``-D__bpf_static_offset=`` to use these helpers with an affected + compiler. + **root_id** option can be used to filter a dump to a single type and all its dependent types. It cannot be used with any other types of filtering (such as the "key", "value", or "kv" arguments when dumping BTF for a map). -- 2.56.0