From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B65D286400; Wed, 26 Nov 2025 18:32:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764181964; cv=none; b=JVz3Gw7PpVsxZmKtuBPItxn4ItpMkicikCMVOiR+0DUoEj7yvsSMDwmpNPByn4IsCRZb26ykiC9F4QT1cENz2ANAUT9u/mnMyJXf1eTftlQ/kxCjY4UyN41yoziBr2XbjTWK4BHW0qxxwgsJZmRchaAO5QrAoUzXeHpdRGi6p0Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764181964; c=relaxed/simple; bh=AOoe5JtT1OHWwr9WMwKaAoJ7KKM01g+Aduh6RSFzgEo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=R5XxqC6LVEogD47EKqXXSdKfQJnyR8S149V+QCyuz3gl7A46IUs9rNTfdeBmo/HQcFHuHUYoAoCUh7Y61j0NFiG+pl1QTLyhxk0f6bK4SnY79UuNzU2GDN966gcargeDV6KeKf9gy4C/CFhLLaY7MYQ3SQGfveQsxVp81hMZfCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bugEiiRN; arc=none smtp.client-ip=91.218.175.189 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) header.d=linux.dev header.i=@linux.dev header.b="bugEiiRN" Message-ID: <7fb4b953-449d-4f72-8bc7-2becae3cc639@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1764181960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5kl7ivhO8IEcaYStwnE6ABlTpqXsrzXg6GsRqFQk9Jg=; b=bugEiiRNridTMoZfkk4a3ngi8Awv7I4mc9QqFHPdagwYHMg1n4+0q0IM9mQ6QGsofYSD1R p+g/aLEoNg/uwmche/65NvyMgWtlJURKOQ3kwgqYxYBrvrX36F7k3nY0o8QGXEdvSzNBqe ZiK3HbDVVQ2jF2jxRxUkmXmyu9tt0ok= Date: Wed, 26 Nov 2025 10:32:30 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v1 4/4] resolve_btfids: change in-place update with raw binary output To: Donglin Peng Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , bpf@vger.kernel.org, dwarves@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Alan Maguire References: <20251126012656.3546071-1-ihor.solodrai@linux.dev> <20251126012656.3546071-5-ihor.solodrai@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Ihor Solodrai In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 11/25/25 8:46 PM, Donglin Peng wrote: > On Wed, Nov 26, 2025 at 9:29 AM Ihor Solodrai wrote: >> >> [...] >> static const char * const resolve_btfids_usage[] = { >> @@ -823,12 +875,13 @@ int main(int argc, const char **argv) >> .funcs = RB_ROOT, >> .sets = RB_ROOT, >> }; >> + char out_path[PATH_MAX]; >> bool fatal_warnings = false; >> struct option btfid_options[] = { >> OPT_INCR('v', "verbose", &verbose, >> "be more verbose (show errors, etc)"), >> OPT_STRING(0, "btf", &obj.btf_path, "BTF data", >> - "BTF data"), >> + "input BTF data"), >> OPT_STRING('b', "btf_base", &obj.base_btf_path, "file", >> "path of file providing base BTF"), >> OPT_BOOLEAN(0, "fatal_warnings", &fatal_warnings, >> @@ -844,6 +897,9 @@ int main(int argc, const char **argv) >> >> obj.path = argv[0]; >> >> + if (load_btf(&obj)) >> + goto out; > > I think I can add the BTF sorting function here based on your patch. Correct. Any btf2btf transformations will have to happen before the symbols resolution. > > Thanks, > Donglin >> + >> if (elf_collect(&obj)) >> goto out; >> >> @@ -853,23 +909,37 @@ int main(int argc, const char **argv) >> */ >> if (obj.efile.idlist_shndx == -1 || >> obj.efile.symbols_shndx == -1) { >> - pr_debug("Cannot find .BTF_ids or symbols sections, nothing to do\n"); >> - err = 0; >> - goto out; >> + pr_debug("Cannot find .BTF_ids or symbols sections, skip symbols resolution\n"); >> + goto dump_btf; >> } >> >> if (symbols_collect(&obj)) >> goto out; >> >> - if (load_btf(&obj)) >> - goto out; >> - >> if (symbols_resolve(&obj)) >> goto out; >> >> if (symbols_patch(&obj)) >> goto out; >> >> + strcpy(out_path, obj.path); >> + strcat(out_path, ".btf_ids"); >> + if (dump_raw_btf_ids(&obj, out_path)) >> + goto out; >> + >> +dump_btf: >> + strcpy(out_path, obj.path); >> + strcat(out_path, ".btf"); > > Do we need to add .btf files to the .gitignore file? I don't know. Probably? I take care to cleanup temporary files in the gen-btf.sh, but it makes sense to .gitignore them anyways, since those are temporary build artifacts. > > Thanks, > Donglin > >> + if (dump_raw_btf(obj.btf, out_path)) >> + goto out; >> + >> + if (obj.base_btf) { >> + strcpy(out_path, obj.path); >> + strcat(out_path, ".distilled_base.btf"); >> + if (dump_raw_btf(obj.base_btf, out_path)) >> + goto out; >> + } >> + >> if (!(fatal_warnings && warnings)) >> err = 0; >> out: >> -- >> 2.52.0 >>