Re: Support for gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I used clang and gcc to generate the obj files, and then readelf these
two files, I found that there is a problem with the machine item, the
machine item generated by clang is "Linux BPF", and the one generated
by gcc is my physical machine architecture "x86-64", which makes the
check of "ehdr->e_machine != EM_BPF" fail.
This seems to be a problem with my not specifying a compilation option
similar to clang target  when compiling with gcc.

On Wed, Dec 21, 2022 at 8:34 AM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
>
> On Tue, Dec 20, 2022 at 3:56 AM SuHsueyu <anolasc13@xxxxxxxxx> wrote:
> >
> > Hello, I use gcc 12.1.0 to compile a source file:
> > t.c
> > struct t {
> >   int a:2;
> >   int b:3;
> >   int c:2;
> > } g;
> > with gcc -c -gbtf t.c
> > and try to use libbpf API btf__parse_split, bpf_object__open, and
> > bpf_object__open to parse and load into the kernel, but it failed with
> > "libbpf: elf: /path/to/t.o is not a valid eBPF object file".
>
> if (ehdr->e_type != ET_REL || (ehdr->e_machine && ehdr->e_machine != EM_BPF))
>
> This check is failing in libbpf. So check which of those two are not
> set appropriately. cc Jose to point where to report GCC-BPF specific
> issues.
>
> >
> > Is it wrong for me to do so? Due to some constraint, I cannot use
> > clang but gcc. How to parse and load gcc compiled object file with
> > libbpf?



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux