From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 550072475F7 for ; Tue, 20 Jan 2026 01:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768874102; cv=none; b=QlzJmmKchNirI+n89NcUDPyXtnVUif23sw2rTrtUa2xEeDK61RhgWkNhGSiX19BmTZ2eJgjvd5Cj72yMzTP5iNOD/upAn7GVxSsntSaBrsOshiL5Tpepbfl5bWMFnHNzuq4/JX2lUGOYfj4h7llFsaB/aigsB0/FyxGe8brdEME= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768874102; c=relaxed/simple; bh=h1bzrV3t+W8hh2TRR/gZqlbk4hfM8u7QilZdJ5qMIjs=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=SvYJ08OodI9iBoYq+TdV3sTNdyyuKQHUISSbviATv3ycw5YlYNvTKWk0D3ZBaAbCYAkcRfTUbl6djWIwSxB1ienFoHooH4uNJHhE6R284+/0JH8FFbozvkvNVGGiHdKCP159qfiza+iGhUIrs4pItPOCGiZbt5STVxaWU0Xvv6I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U1yIFwoT; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U1yIFwoT" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-8c538d17816so644684485a.0 for ; Mon, 19 Jan 2026 17:55:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768874100; x=1769478900; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=C5BHzdBy9bZIqFc6VCkjIoouQALwj1cU2ODrGGe4Wds=; b=U1yIFwoTCWixGikxtSXOKXeZaOdSi2arE/3kAJM0sjqGGfUck2lkvO0o+5YC4vA5bj ovFKiZjOARYSiQNArg8nu+bdWeYjjaDO4iYkALXTJb7W6QePovv01lkO5Pvd/1KEFXQw /oJqdEZ0SJy/k+X3RFi5mwD9MBoJFO7FK6OFkzgKHG+AOrACzKhnLnnn347OyG+XXthz 49KFPEtq0Zlp6CzVVrbPVtHonh5ttsg0bYk78/KFGlEMJ/CJSHZYQd6kqYyZBuR6823l ohsTNUplwquIvI/0Bj9faq+HyQB1EopzCttgO9bvTFsHjGcUqoYzYj5SWLc73ogjupXm 4B+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768874100; x=1769478900; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=C5BHzdBy9bZIqFc6VCkjIoouQALwj1cU2ODrGGe4Wds=; b=VBbuW7t/iG8V7REsLG8RIuPrwV33DhXhW4XDzgVJDem2DV6w0k7g/KiWR7Irse5iXH 4ZSlCAeTVjZ6PTFDrV7HBx6IVxsgtnbKIDmsHuLAs8U9Byu48nDHKpMj+3oaDOI5sbL+ eUCIOm8PBFs/PZw9+Zkr8mNb/8XYnGyxGnmN1ygVQknlF27C4FcUi+S3OIrkr2TeQ/Qm JoVl/rcwoxr7q3dLUIajoaeTlJkZLHyFAY7Fa1DDH4iWvsn0cbsdJ6xoaPbBZHxFBkW5 CXqk+IesoQcfx3KzLZUSDs3en6s+gpZYNr/uwGX2c2DriP78X/57ygUyQhGd+7sh8Qpp kJFw== X-Forwarded-Encrypted: i=1; AJvYcCVJL+jpLEMNycxRpWPPW8+ZTk/3q10FNfQ1SeEXEXMbh0R9LRy92Cx6HslHmgwMKVAkmxb8bF2D6kUmjmQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwCU/AwJii3dSGWjeH9KbuVpVip23lIJT47YXi2bcP19KVYw/d/ fDZGgAhuHLd7qvRv+LYt6C6u4DXTpQS1c1zVRL23PcP7x4wiwwxwiuuCENHRURBF X-Gm-Gg: AY/fxX6ceu+sWWgh/blFldi5ajMAwt7aGEBjIBHA0Q+4YDMByefrdO4vXLeLbt/Nf4r AXbbhI/i5+jsG1hVH9EN1P+5GTmchPgpZUNjpNJPGoOJK+zKevQOeGt4J1l7bXyeDLKy+0MxzQ1 ZkbFtif2OOeUvQXb5EoCWrtmsBA3aKMBMwXRuOA/lbky4gF+fsNufiZlGnQPEIJUzAiLci7NozL xLusgALSEExqKAxX702J/9oxEi0j5LWTnvhMhnDi8WgVVmhmwW2yx8vocqCu+8a/fpjwPKWqqb9 k1TkInp+H5gcm7fIU/4roka9YrFXyykpZ2L+DXPRIsIRFQGsi1IfZ0v9GaM6Kkhq+PFrxORXgSo Zzgrd2Zd7zdHas9G9+Y3HWHW/B3ayAyJZtDBqYROUinqU8KfVx251ttjTDfu3oTTW4CCQfQl1H2 +0crnDp/tYFuolAa7EDhFNUNO90wKQehhO7dL8RQd971e3WXJgRJP0VStOtwgJ3foKgw== X-Received: by 2002:a05:7300:6c89:b0:2ae:4f61:892e with SMTP id 5a478bee46e88-2b6b4eaddf6mr9036820eec.36.1768868006151; Mon, 19 Jan 2026 16:13:26 -0800 (PST) Received: from ?IPv6:2a03:83e0:115c:1:4cd6:17bf:3333:255f? ([2620:10d:c090:500::aa81]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b6b3502c91sm14832564eec.9.2026.01.19.16.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jan 2026 16:13:25 -0800 (PST) Message-ID: Subject: Re: [PATCH bpf-next v2 04/13] resolve_btfids: Introduce finalize_btf() step From: Eduard Zingerman To: Ihor Solodrai , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau Cc: Mykyta Yatsenko , Tejun Heo , Alan Maguire , Benjamin Tissoires , Jiri Kosina , Amery Hung , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, sched-ext@lists.linux.dev Date: Mon, 19 Jan 2026 16:13:23 -0800 In-Reply-To: <20260116201700.864797-5-ihor.solodrai@linux.dev> References: <20260116201700.864797-1-ihor.solodrai@linux.dev> <20260116201700.864797-5-ihor.solodrai@linux.dev> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 (3.58.2-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-01-16 at 12:16 -0800, Ihor Solodrai wrote: > Since recently [1][2] resolve_btfids executes final adjustments to the > kernel/module BTF before it's embedded into the target binary. >=20 > To keep the implementation simple, a clear and stable "pipeline" of > how BTF data flows through resolve_btfids would be helpful. Some BTF > modifications may change the ids of the types, so it is important to > maintain correct order of operations with respect to .BTF_ids > resolution too. >=20 > This patch refactors the BTF handling to establish the following > sequence: > - load target ELF sections > - load .BTF_ids symbols > - this will be a dependency of btf2btf transformations in > subsequent patches > - load BTF and its base as is > - (*) btf2btf transformations will happen here > - finalize_btf(), introduced in this patch > - does distill base and sort BTF > - resolve and patch .BTF_ids >=20 > This approach helps to avoid fixups in .BTF_ids data in case the ids > change at any point of BTF processing, because symbol resolution > happens on the finalized, ready to dump, BTF data. >=20 > This also gives flexibility in BTF transformations, because they will > happen on BTF that is not distilled and/or sorted yet, allowing to > freely add, remove and modify BTF types. >=20 > [1] https://lore.kernel.org/bpf/20251219181321.1283664-1-ihor.solodrai@li= nux.dev/ > [2] https://lore.kernel.org/bpf/20260109130003.3313716-1-dolinux.peng@gma= il.com/ >=20 > Signed-off-by: Ihor Solodrai > --- Acked-by: Eduard Zingerman > @@ -1099,12 +1116,22 @@ int main(int argc, const char **argv) > if (obj.efile.idlist_shndx =3D=3D -1 || > obj.efile.symbols_shndx =3D=3D -1) { > pr_debug("Cannot find .BTF_ids or symbols sections, skip symbols resol= ution\n"); > - goto dump_btf; > + resolve_btfids =3D false; > } > =20 > - if (symbols_collect(&obj)) > + if (resolve_btfids) > + if (symbols_collect(&obj)) > + goto out; Nit: check obj.efile.idlist_shndx and obj.efile.symbols_shndx inside symbol= s_collect()? To avoid resolve_btfids flag and the `goto dump_btf;` below. > + > + if (load_btf(&obj)) > goto out; > =20 > + if (finalize_btf(&obj)) > + goto out; > + > + if (!resolve_btfids) > + goto dump_btf; > + > if (symbols_resolve(&obj)) > goto out; > =20