Re: [PATCH bpf-next v1 5/8] libbpf: Support opening bpf objects of either endianness

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

 



On Wed, Aug 21, 2024 at 2:10 AM Tony Ambardar <tony.ambardar@xxxxxxxxx> wrote:
>
>
> +static inline void bpf_insn_bswap(struct bpf_insn *insn)
> +{
> +       /* dst_reg & src_reg nibbles */
> +       __u8 *regs = (__u8 *)insn + offsetofend(struct bpf_insn, code);
> +
> +       *regs = (*regs >> 4) | (*regs << 4);
> +       insn->off = bswap_16(insn->off);
> +       insn->imm = bswap_32(insn->imm);
> +}

This is really great!
Thank you for working on it.

This idea was brought up a couple times, since folks want to compile
bpf prog once, embed it into their user space binary,
and auto adjust to target endianness.
Cross compilation isn't important to them,
but the ability to embed a single .o instead of two .o-s is a big win.

It's great that the above insn, elf and btf adjustments are working.
Since endianness is encoded in elf what's the point of
extra btf_ext__endianness libbpf api?
Aren't elf and btf.ext suppose to be in the same endianness all the time?





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux