BPF List
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: James Hilliard <james.hilliard1@gmail.com>,
	bpf <bpf@vger.kernel.org>,
	david.faust@oracle.com
Subject: Re: bpftool gen object doesn't handle GCC built BPF ELF files
Date: Fri, 08 Jul 2022 16:51:58 +0200	[thread overview]
Message-ID: <87wncnd5dd.fsf@oracle.com> (raw)
In-Reply-To: <CAEf4BzZVq2VZg=S2xZinfth2-f50zxhMm-fPVQGUoeYPC5J4XA@mail.gmail.com> (Andrii Nakryiko's message of "Wed, 6 Jul 2022 10:20:47 -0700")


> 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

For functions GCC generates a BTF_KIND_FUNC entry, which has no linkage
information, or so we thought: I just looked at bpftool/btf.c and I
found the linkage info for function types is expected to be encoded in
the vlen field of BTF_KIND_FUNC entries (why not adding a btf_func
instead???) which is surprising to say the least.

We are changing GCC to encode the linkage info in vlen for these types.
Thanks for reporting this.

> 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
>
>
>> 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-08 14:52 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 [this message]
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
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=87wncnd5dd.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=david.faust@oracle.com \
    --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