[PATCH 0/9] eBPF support for GNU binutils

Alexei Starovoitov alexei.starovoitov@gmail.com
Tue May 21 18:18:00 GMT 2019


On Tue, May 21, 2019 at 8:41 AM Jiong Wang <jiong.wang@netronome.com> wrote:
> >
> > Despite using a different syntax for the assembler (the llvm assembler
> > uses a C-ish expression-based syntax while the GNU assembler opts for
> > a more classic assembly-language syntax) this implementation tries to
> > provide inter-operability with clang/llvm generated objects.
>
> I also noticed your implementation doesn’t seem to use the same sub-register
> syntax as what LLVM assembler is doing.
>
>   x register for 64-bit, and w register for 32-bit sub-register.
>
> So:
>   add r0, r1, r2 means BPF_ALU64 | BPF_ADD | BFF_X
>   add w0, w1, w1 means BPF_ALU | BPF_ADD | BPF_X
>
> ASAICT, different register prefix for different register width is also adopted
> by quite a few other GNU assembler targets like AArch64, X86_64.

there is also Ed's assembler:
https://github.com/solarflarecom/ebpf_asm
It uses 2 ops style.
I think 3 ops style "add r0,r1,r2" is not a good fit for bpf isa.

I think we need to converge on one asm syntax for gas/bfd.
At this point we cannot change llvm's asm output,
so my preference would be to make gas accept it.
But I understand the implementation difficulties to fit it into bfd infra.
So I'm ok with more traditional asm the way Dave implemented it few
years back.
One asm syntax for gas and another asm syntax for clang is, imo, acceptable.

Jose, can you combine Dave's patches with yours?

I think Ed had an idea on how to specify BTF in asm syntax.
BTF has to be supported by the assembler as well
along with .btf.ext, lineinfo, etc
Currently llvm emits btf as '.byte 0x...', but that's far from ideal.



More information about the Binutils mailing list