Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1794873ioo; Mon, 23 May 2022 03:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx27d7+ncKXnVISqltzQzWYf+BJMbSLJnY97b9LcAWyltOx3KN4a8m50dteBmn4k+OKJSL/ X-Received: by 2002:a17:902:d58e:b0:161:ea63:6649 with SMTP id k14-20020a170902d58e00b00161ea636649mr17410065plh.168.1653302016683; Mon, 23 May 2022 03:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653302016; cv=none; d=google.com; s=arc-20160816; b=kKYSqHwUfi1FNiu087UQy1HtMWqNzR7ZQzCVJKKBlcR0DoYHUU1guYIzfbbCPBVfw+ CqZMoKXIPp+NHQpLwC+d/yHKcRDMOyZg/acugTjPM8cOv8W0TiOBUMlRlPf+xeWXCK/g 8MmURixBK9StfafJ5mUWi8UeSvRN2n7W9oylUizU4agcXfsLP9BpwQLLHFtbQONZm9K0 bw5yV3aEgAAaOXavHGWyCHYLv4IQXne5k2Xu3yiinnhIz4322WWCcr0cfbLb71Z0cknL tpW2oMyCIRPyDC26ka1T6i1suX8yIGLjylxfdEcadw4mOGZPEcODHN8xG6SW87jDBQs4 3sJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=MpADgjNecDe+3keIBbYGPxa6vPeCrM0H2iBwtILBnFg=; b=ihBDKpQJtilT2OjmCFsKdeQZgeDTBj5TSZNSABZXZuDn4qs6TTxSGPvVEqfMLj/07j QBStRJBxFfzuy5wcBmZjYPsBmUFZlZCbkIv0rEA6T9Hzhmr0XPI9DCMS0siqge2vujAY 5SqN0UDCgx2SKt3qhk6NOeToThoiZcyGpeK0yt1AKaFrmAhfdTQvfhngmSZNsRG7C2r8 Ias5rQSmTgC6rTD+BubMyTyR+7XIG5ElSchGIO0lOq5C/alqyuZghkIQWC16+A87vsk0 CEWqt69cl79aNj1AG/01bI2DXyoDoWHp8Ecpx6bsIVT2LgFlyEWkmzPonJRonZwNBgHY yjLg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a6-20020a170902900600b00153b2d16659si8609728plp.609.2022.05.23.03.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 03:33:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 81E0B5593; Mon, 23 May 2022 03:32:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234082AbiEWKbe (ORCPT + 99 others); Mon, 23 May 2022 06:31:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234204AbiEWKbW (ORCPT ); Mon, 23 May 2022 06:31:22 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3BB9D2C1; Mon, 23 May 2022 03:31:21 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ECA6511FB; Mon, 23 May 2022 03:31:20 -0700 (PDT) Received: from e126130.arm.com (unknown [10.57.81.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 51E7B3F73D; Mon, 23 May 2022 03:31:17 -0700 (PDT) From: Douglas RAILLARD To: bpf@vger.kernel.org Cc: beata.michalska@arm.com, Douglas Raillard , Alexei Starovoitov , Daniel Borkmann , 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 Subject: [PATCH v2] libbpf: Fix determine_ptr_size() guessing Date: Mon, 23 May 2022 11:29:55 +0100 Message-Id: <20220523102955.43844-1-douglas.raillard@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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. 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 + ) { if (t->size != 4 && t->size != 8) continue; return t->size; -- 2.25.1