Received: from 66-220-155-179.mail-mxout.facebook.com (66-220-155-179.mail-mxout.facebook.com [66.220.155.179]) (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 4262C383990 for ; Thu, 25 Jun 2026 02:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.220.155.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782352938; cv=none; b=DTPGSsKTTsI3NbSPBhki/1TjoP/+wjsklip4Qs3nTKF4diwfb39uKmv9gzGvagHJKxtItjZyjB2ONd9ZRUKHtU2O/6KnlZQ9gbHzMCpJNZfTZOayYGnGdpz8H80wtYl/XX/qk7DH1DhW2H0RMoUYQ9F1fZk8C6MnjnlrJb3Btbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782352938; c=relaxed/simple; bh=wNs5eoAvIdfkM/TJ9gcA8BPJMY0wnrfn4DdnAYgbstw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C6m/v8Yz01bgfX+GTNasXykf3ADqtiG/f22eqAoSVO6FgC8pYSMdl51sKODJ7nGzaKv3cJQDmO5SugAfaF5rAfmmhBIeq6KyQev+x+WCb/UrCAsX6MB2EBVhAfUPVhVCmOqhUl/uaXoVB1tXaIKZKxjwhReKgsKk8Nqy/1XgAgg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=fail smtp.mailfrom=linux.dev; arc=none smtp.client-ip=66.220.155.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.dev Received: by devvm16039.vll0.facebook.com (Postfix, from userid 128203) id 0BDB919D960602; Wed, 24 Jun 2026 19:02:08 -0700 (PDT) From: Yonghong Song To: Alan Maguire , Arnaldo Carvalho de Melo , dwarves@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , bpf@vger.kernel.org, kernel-team@fb.com Subject: [PATCH dwarves v10 4/5] btf_encoder: Emit true function signatures Date: Wed, 24 Jun 2026 19:02:08 -0700 Message-ID: <20260625020208.1886111-1-yonghong.song@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260625020148.1883082-1-yonghong.song@linux.dev> References: <20260625020148.1883082-1-yonghong.song@linux.dev> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable When true_signature is enabled, consume the per-parameter analysis the DWARF loader recorded while saving a function's BTF: - Drop parameters that were optimized out of a signature-changed functio= n (ftype->signature_changed && param->optimized), adjusting the saved parameter count accordingly. - When a parameter was reduced to a single aggregate member (param->true_sig_member_name is set), emit it under the synthesized na= me "__" so the BTF reflects the value actually passed = in the register. Signed-off-by: Yonghong Song --- btf_encoder.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/btf_encoder.c b/btf_encoder.c index d5af706..38455a4 100644 --- a/btf_encoder.c +++ b/btf_encoder.c @@ -1297,14 +1297,38 @@ static int32_t btf_encoder__save_func(struct btf_= encoder *encoder, struct functi state->reordered_parm =3D ftype->reordered_parm; ftype__for_each_parameter(ftype, param) { const char *name; + char *final_name =3D NULL; =20 /* No location info/optimized + reordered means optimized out. */ if (ftype->reordered_parm && (!param->has_loc || param->optimized)) { state->nr_parms--; continue; } - name =3D parameter__name(param) ?: ""; + if (encoder->true_signature && ftype->signature_changed && param->opti= mized) { + state->nr_parms--; + continue; + } + + name =3D parameter__name(param); + if (!name) { + name =3D ""; + } else if (encoder->true_signature && + ftype->signature_changed && + param->true_sig_member_name) { + /* Non-null param->true_sig_member_name indicates that the parameter + * name is __. + */ + if (asprintf(&final_name, "%s__%s", name, param->true_sig_member_name= ) =3D=3D -1) { + err =3D -ENOMEM; + goto out; + } + name =3D final_name; + } + str_off =3D btf__add_str(btf, name); + if (final_name) + free(final_name); + if (str_off < 0) { err =3D str_off; goto out; --=20 2.53.0-Meta