Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2352283ioo; Mon, 23 May 2022 16:52:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEwlA/32L8ZR2mVayT4awL7m9qeCaiySb/U0FHDenJmWwuD76WPKUe7TjYvLJ0JEyc92E9 X-Received: by 2002:a17:902:a413:b0:156:15b:524a with SMTP id p19-20020a170902a41300b00156015b524amr24988819plq.106.1653349959861; Mon, 23 May 2022 16:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653349959; cv=none; d=google.com; s=arc-20160816; b=iFgx+Lvy6sABA0T4cEycXbPnQ6lWm8HkfovjLti3pl81bRVmb2/AwhtsW3A7RhZn2J OwymJ4PZaxcUb486hyCGLEe1Ch7cPmdxALf/Y4YLrah9B7ThtpP4u1AVKWDNwjlVKcKx 9TCMPTKta8ddsBaaj444sIeHk1UClxu0j+A9ZY7rDo+VEK/I6Kg0uLJ/NCIs2/zlmaN6 wpLbAZkk1DyvmzSOF6mMg501QLz0j+q7t+UdfcX9vNU7kFQZdfppt0/TnqGRWfXoQq3J f4gYUgG+QLmmX5xWZc8zoBxKsr7cyTukoytZTGCHLAMSV7R9X4jnkiI/RYU1ZcNpEmqX 9w2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=mGFVT+Ath/C4I9Lyb2XrD17xFfbzfK5p3fot0QZqVAQ=; b=ky0d5VYd27v8vTtoyv53za2oZogY1F1DcWJI/ht6LfOZ0DQGZHg42BfxyfjOvDk3e1 MB5gskEGjcFZwGLLoERST8mXm0OrLvJ/GMX9xaRSTcpKiZzWQa7fIRDdIeQe0ba9UTZ6 wRO6xsRdBiWDitYnkj8yKpMW55j8a0LT14+Nj5htf1sOXY9tH1zYN7mpe1r57/X5MDw5 XQn1JGoyAt034aU3aYmeWGN70BaVxTWF+IUNNmwEP2QRBnGDGtLuxpRJkO8XwkMh+vtZ 8RHdPwhYh7Il81VTy24dV6ELYChw5PPNX4fHkML/pIp55874m5CpYXsinaRzO/2hCvr6 27GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a63384c000000b0039daee7ecf1si10851430pgn.318.2022.05.23.16.52.28; Mon, 23 May 2022 16:52:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbiEWVAl (ORCPT + 99 others); Mon, 23 May 2022 17:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiEWVAe (ORCPT ); Mon, 23 May 2022 17:00:34 -0400 Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B53BF39156; Mon, 23 May 2022 14:00:31 -0700 (PDT) Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ntFAD-00045c-Px; Mon, 23 May 2022 23:00:29 +0200 Received: from [85.1.206.226] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntFAD-000BZ8-9q; Mon, 23 May 2022 23:00:29 +0200 Subject: Re: [PATCH v2] libbpf: Fix determine_ptr_size() guessing To: Douglas RAILLARD , bpf@vger.kernel.org Cc: beata.michalska@arm.com, Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Nathan Chancellor , Nick Desaulniers , Tom Rix , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20220523102955.43844-1-douglas.raillard@arm.com> From: Daniel Borkmann Message-ID: <4268b7c5-458e-32cc-36c4-79058be0480e@iogearbox.net> Date: Mon, 23 May 2022 23:00:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20220523102955.43844-1-douglas.raillard@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.5/26550/Mon May 23 10:05:39 2022) X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/23/22 12:29 PM, Douglas RAILLARD wrote: > From: Douglas Raillard > > One strategy employed by libbpf to guess the pointer size is by finding > the size of "unsigned long" type. This is achieved by looking for a type > of with the expected name and checking its size. > > Unfortunately, the C syntax is friendlier to humans than to computers > as there is some variety in how such a type can be named. Specifically, > gcc and clang do not use the same name in debug info. Could you elaborate for the commit msg what both emit differently? > Lookup all the names for such a type so that libbpf can hope to find the > information it wants. > > Signed-off-by: Douglas Raillard > --- > tools/lib/bpf/btf.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > CHANGELOG > v2: > * Added missing case for "long" > > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c > index 1383e26c5d1f..ab92b3bc2724 100644 > --- a/tools/lib/bpf/btf.c > +++ b/tools/lib/bpf/btf.c > @@ -489,8 +489,19 @@ static int determine_ptr_size(const struct btf *btf) > if (!name) > continue; > > - if (strcmp(name, "long int") == 0 || > - strcmp(name, "long unsigned int") == 0) { > + if ( > + strcmp(name, "long") == 0 || > + strcmp(name, "long int") == 0 || > + strcmp(name, "int long") == 0 || > + strcmp(name, "unsigned long") == 0 || > + strcmp(name, "long unsigned") == 0 || > + strcmp(name, "unsigned long int") == 0 || > + strcmp(name, "unsigned int long") == 0 || > + strcmp(name, "long unsigned int") == 0 || > + strcmp(name, "long int unsigned") == 0 || > + strcmp(name, "int unsigned long") == 0 || > + strcmp(name, "int long unsigned") == 0 > + ) { I was wondering whether strstr(3) or regexec(3) would be better, but then it's probably not worth it and having the different combinations spelled out is probably still better. Pls make sure though to stick to kernel coding convention (similar alignment around strcmp() as the lines you remove). > if (t->size != 4 && t->size != 8) > continue; > return t->size; > Thanks, Daniel