BPF List
 help / color / mirror / Atom feed
From: Indu Bhagat <indu.bhagat@oracle.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	James Hilliard <james.hilliard1@gmail.com>
Cc: bpf <bpf@vger.kernel.org>
Subject: Re: bpftool gen object doesn't handle GCC built BPF ELF files
Date: Mon, 11 Jul 2022 17:34:46 -0700	[thread overview]
Message-ID: <6138056c-fb57-69bd-90a0-8b51b870759f@oracle.com> (raw)
In-Reply-To: <CAEf4BzZVq2VZg=S2xZinfth2-f50zxhMm-fPVQGUoeYPC5J4XA@mail.gmail.com>

On 7/6/22 10:20 AM, Andrii Nakryiko wrote:
> On Wed, Jul 6, 2022 at 10:13 AM James Hilliard
> <james.hilliard1@gmail.com> wrote:
>>
>> Note I'm testing with the following patches:
>> https://lore.kernel.org/bpf/20220706111839.1247911-1-james.hilliard1@gmail.com/
>> https://lore.kernel.org/bpf/20220706140623.2917858-1-james.hilliard1@gmail.com/
>>
>> It would appear there's some compatibility issues with bpftool gen and
>> GCC, not sure what side though is wrong here:
>> /home/buildroot/buildroot/output/per-package/systemd/host/sbin/bpftool
>> gen object src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.o
>> src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.unstripped.o
>> libbpf: failed to find BTF info for global/extern symbol 'sd_restrictif_i'
>> Error: failed to link
>> 'src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.unstripped.o':
>> Unknown error -2 (-2)
>>
>> Relevant difference seems to be this:
>> GCC:
>> [55] FUNC 'sd_restrictif_i' type_id=47 linkage=static
>> Clang:
>> [27] FUNC 'sd_restrictif_i' type_id=26 linkage=global
>>
> 
> GCC is wrong, clearly. This function is global ([0]) and libbpf
> expects it to be marked as such in BTF.
> 
> https://github.com/systemd/systemd/blob/main/src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.c#L42-L50
> 

How about updating the BTF format documentation in btf.rst to reflect 
the specification for BTF_KIND_FUNC ?

Thanks

diff --git a/Documentation/bpf/btf.rst b/Documentation/bpf/btf.rst
index f49aeef62d0c..b3a9d5ac882c 100644
--- a/Documentation/bpf/btf.rst
+++ b/Documentation/bpf/btf.rst
@@ -369,7 +369,7 @@ No additional type data follow ``btf_type``.
    * ``name_off``: offset to a valid C identifier
    * ``info.kind_flag``: 0
    * ``info.kind``: BTF_KIND_FUNC
-  * ``info.vlen``: 0
+  * ``info.vlen``: linkage information (static=0, global=1)
    * ``type``: a BTF_KIND_FUNC_PROTO type

  No additional type data follow ``btf_type``.

> 
>> GCC:
>>
>> [1] INT 'signed char' size=1 bits_offset=0 nr_bits=8 encoding=UNKN
>> [2] INT 'unsigned char' size=1 bits_offset=0 nr_bits=8 encoding=CHAR
>> [3] TYPEDEF '__u8' type_id=2
>> [4] CONST '(anon)' type_id=3
> 
> [...]
> 


  parent reply	other threads:[~2022-07-12  0:35 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06 17:11 bpftool gen object doesn't handle GCC built BPF ELF files James Hilliard
2022-07-06 17:20 ` Andrii Nakryiko
2022-07-06 17:49   ` James Hilliard
2022-07-08 11:55     ` Jose E. Marchesi
2022-07-08 12:23       ` James Hilliard
2022-07-08 13:46         ` Jose E. Marchesi
2022-07-08 13:53           ` James Hilliard
2022-07-08 14:39             ` Jose E. Marchesi
2022-07-08 14:51   ` Jose E. Marchesi
2022-07-08 18:33     ` Jose E. Marchesi
2022-07-08 20:59       ` James Hilliard
2022-07-09 17:24         ` Jose E. Marchesi
2022-07-09 17:28           ` James Hilliard
2022-07-09 20:20             ` Jose E. Marchesi
2022-07-09 20:32               ` James Hilliard
2022-07-09 20:39                 ` James Hilliard
2022-07-09 22:41                   ` Jose E. Marchesi
2022-07-09 22:54                     ` James Hilliard
2022-07-10  9:38                       ` Jose E. Marchesi
2022-07-10 12:16                         ` James Hilliard
2022-07-10 13:06                           ` Jose E. Marchesi
2022-07-10 19:49                             ` Jose E. Marchesi
2022-07-10 20:22                               ` Jose E. Marchesi
2022-07-11  1:55                                 ` Jose E. Marchesi
     [not found]                                 ` <CADvTj4o-36iuru665BW0XnEauXBeszW438QTtpt4_VUEjf5nXg@mail.gmail.com>
2022-08-01 22:51                                   ` Andrii Nakryiko
2022-08-01 23:35                                     ` James Hilliard
2022-08-02 21:28                                       ` Andrii Nakryiko
2022-08-02 22:05                                         ` James Hilliard
2022-08-03  0:29                                           ` Andrii Nakryiko
2022-08-03  1:49                                             ` James Hilliard
2022-08-03 16:57                                               ` Andrii Nakryiko
2022-08-03 19:24                                                 ` James Hilliard
2022-09-30 21:52                                                   ` James Hilliard
2022-09-30 22:50                                                     ` Andrii Nakryiko
2022-08-04 17:29                                                 ` Alexei Starovoitov
2022-08-02 15:57       ` Jose E. Marchesi
2022-07-12  0:34   ` Indu Bhagat [this message]
2022-07-13  4:28     ` Yonghong Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6138056c-fb57-69bd-90a0-8b51b870759f@oracle.com \
    --to=indu.bhagat@oracle.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox