Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5917288ybc; Wed, 27 Nov 2019 11:36:42 -0800 (PST) X-Google-Smtp-Source: APXvYqygLGL6EFugrxSbuX2fAwG49P3okgN+W1lcuOwaClwZvSq0SSQMONIWKYZCWBQJnmFt2Ong X-Received: by 2002:a17:906:5251:: with SMTP id y17mr52147750ejm.108.1574883402320; Wed, 27 Nov 2019 11:36:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574883402; cv=none; d=google.com; s=arc-20160816; b=nSJ0aHn8z/UO+mHSm3GSaOrW8ydWnOm0nhBkGYTesOdDNU02WzgIpEX2RDmj4p1uby ZJqtQD2U2tLAJ+vIDc4k1UtFIReqwI+HYPohYs3xv2PY9OHF+NBuhohELV2Tsth8BT20 gsplEd+PPWWPFM04BspG6PYWoIyjF8aPhVecXgqzbbHvtyeW98VDm4kIDYlySKN3Zy74 wLG17TZCYvS2l28BqU/PmsAPFC7HqyxhQEfZUAh3xoeRPcLbb0y4Oj+5yHvaeiG2xYC7 yBh2bfWJHHOD4E65LZ858oa4FvWisnWaW9q7BOmPB+wfwkWgpxF1ZJ5h6ud4XTWkBgCT v4uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RSx7OTjw0zpOYqU/X0SJ0HyqOXCDIW8v0m9WjClqi/s=; b=YnaRft79cpM4EoMj1fhwveAuoHrhCt6YXMxYohAr0gf44dJ49y0vQpD9ZgqpSIaNEQ y48iyhCUbKE0gCAo18bnXg3XgUIAagH6H3uZOeKKa7xZHN3Q0RJifAIJGEllC9hOjIft GKuVHvqNES6SajIqcfWQxROCCPBh2EkVLNwvZBZZWc80Tz7cTPaLjA0HWf4VUPJVHizj CVeZ1WsgYOXKFOJ36YB2vDfWP1Kfh2YxyRJhGQRQSU2nSbTS6q0CXp5RpNdD03HJzaqd 9YdlA4npMrwhpoXUAWh+ppK1/EIcWKwDAzKf/yHtSHnpO74ooncYxEktaRZHNlvWQFF+ BSpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vIGB6nuy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si10051137ejv.305.2019.11.27.11.36.17; Wed, 27 Nov 2019 11:36:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vIGB6nuy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727837AbfK0TdO (ORCPT + 99 others); Wed, 27 Nov 2019 14:33:14 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:43184 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727822AbfK0TdO (ORCPT ); Wed, 27 Nov 2019 14:33:14 -0500 Received: by mail-lf1-f67.google.com with SMTP id l14so18090616lfh.10; Wed, 27 Nov 2019 11:33:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RSx7OTjw0zpOYqU/X0SJ0HyqOXCDIW8v0m9WjClqi/s=; b=vIGB6nuya7dBARFwL6uh1DiYOzq9Jys1GzivJONLdY04SYXv4UC7ZOPhw6WqAfC23n LPrzYDsE++IHWb7q3NQQIcJtb6xVjkXFvTfth888vv+nGy7XUk9U6qqNDztXIP3064re JCJQmGmKlGV3vYma9bj19BRsJarwG16feKZZm1gh+bhg8BqI79uYYLZPy9CtybMu/la+ qHry2xprY9N581HzFYnT/E1QdgTBgANf+KFi8bhSVhTrNGnaYIhGqzuEbfGLWdFut48J q1C6unGkgI3hjK2QsgjQeJ9MqH8gzcNTN2IkjcFfTp3gdaMGBCX6ShmxnOAYooUbCz8s 9QAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RSx7OTjw0zpOYqU/X0SJ0HyqOXCDIW8v0m9WjClqi/s=; b=J6z7czPM1xNMWvOuzgXnUfHcdK06Ia/RgUk6455NR729eLoFJSmxy6fObSzBtgPfi3 m0C/HqijyRPK6IpFhmva3S+3x0vztC8JNJnPiY+KPRovPtMgm8Y2xZAk+wkzdtY/yCbB krrp9kMzZcqaNssctInAz7tDPzVDOUz0shxKlKeYFqYv3Ma/CUsicpH3aV01Py96Ixru 0NQ5F4jcHX50h1iXmRqndTkAyDu42BFKh6lp8uSQVyztXElh9J5u6RWwJ1mt5qBfjGTm sSu5tx4nyoAaF0X/6jvh04V1Wxq2Dvx3Z+AIweQvD/P0XL/P6KUoop1g9OhgVZ0XyOEu UlKw== X-Gm-Message-State: APjAAAW5jP0hA6mtklvwFUJhxVq8rXZazWISR/WoYf3n3fBRKrfbEg1z 9ZYwVuosS0dzphILHWLrkH+O47kQm/drXPQBRTOvEg== X-Received: by 2002:a19:888:: with SMTP id 130mr20156546lfi.167.1574883191745; Wed, 27 Nov 2019 11:33:11 -0800 (PST) MIME-Version: 1.0 References: <20191126183451.GC29071@kernel.org> <87d0dexyij.fsf@toke.dk> <20191126190450.GD29071@kernel.org> <20191126221018.GA22719@kernel.org> <20191126221733.GB22719@kernel.org> <20191126231030.GE3145429@mini-arch.hsd1.ca.comcast.net> <20191126155228.0e6ed54c@cakuba.netronome.com> <20191127013901.GE29071@kernel.org> <20191127134553.GC22719@kernel.org> In-Reply-To: <20191127134553.GC22719@kernel.org> From: Alexei Starovoitov Date: Wed, 27 Nov 2019 11:33:00 -0800 Message-ID: Subject: Re: [PATCH] libbpf: Use PRIu64 for sym->st_value to fix build on 32-bit arches To: Arnaldo Carvalho de Melo Cc: Andrii Nakryiko , Jakub Kicinski , Stanislav Fomichev , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Andrii Nakryiko , Adrian Hunter , Alexei Starovoitov , Daniel Borkmann , Jiri Olsa , Martin KaFai Lau , Namhyung Kim , bpf , Networking , linux-perf-users@vger.kernel.org, Linux Kernel Mailing List , Quentin Monnet Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 27, 2019 at 5:45 AM Arnaldo Carvalho de Melo wrote: > > Another fix I'm carrying in my perf/core branch, > > Regards, > > - Arnaldo > > commit 98bb09f90a0ae33125fabc8f41529345382f1498 > Author: Arnaldo Carvalho de Melo > Date: Wed Nov 27 09:26:54 2019 -0300 > > libbpf: Use PRIu64 for sym->st_value to fix build on 32-bit arches > > The st_value field is a 64-bit value, so use PRIu64 to fix this error on > 32-bit arches: > > In file included from libbpf.c:52: > libbpf.c: In function 'bpf_program__record_reloc': > libbpf_internal.h:59:22: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'Elf64_Addr' {aka 'const long long unsigned int'} [-Werror=format=] > libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \ > ^~~~~~~~~~ > libbpf_internal.h:62:27: note: in expansion of macro '__pr' > #define pr_warn(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__) > ^~~~ > libbpf.c:1822:4: note: in expansion of macro 'pr_warn' > pr_warn("bad call relo offset: %lu\n", sym->st_value); > ^~~~~~~ > libbpf.c:1822:37: note: format string is defined here > pr_warn("bad call relo offset: %lu\n", sym->st_value); > ~~^ > %llu > > Fixes: 1f8e2bcb2cd5 ("libbpf: Refactor relocation handling") > Cc: Alexei Starovoitov > Cc: Andrii Nakryiko > Link: https://lkml.kernel.org/n/tip-iabs1wq19c357bkk84p7blif@git.kernel.org > Signed-off-by: Arnaldo Carvalho de Melo > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index b20f82e58989..6b0eae5c8a94 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -1819,7 +1819,7 @@ static int bpf_program__record_reloc(struct bpf_program *prog, > return -LIBBPF_ERRNO__RELOC; > } > if (sym->st_value % 8) { > - pr_warn("bad call relo offset: %lu\n", sym->st_value); > + pr_warn("bad call relo offset: %" PRIu64 "\n", sym->st_value); Looking at this more... I never liked this PRI stuff. It makes for such unreadable code. How about just typecasting st_value to (long) ?