On Tue, Sep 3, 2024 at 12:34 AM Tony Ambardar <tony.ambardar@xxxxxxxxx> wrote: > > Allow static linking object files of either endianness, checking that input > files have consistent byte-order, and setting output endianness from input. > > Linking requires in-memory processing of programs, relocations, sections, > etc. in native endianness, and output conversion to target byte-order. This > is enabled by built-in ELF translation and recent BTF/BTF.ext endianness > functions. Further add local functions for swapping byte-order of sections > containing BPF insns. > > Signed-off-by: Tony Ambardar <tony.ambardar@xxxxxxxxx> > --- > tools/lib/bpf/linker.c | 78 +++++++++++++++++++++++++++++++++--------- > 1 file changed, 62 insertions(+), 16 deletions(-) > This one looks nice, simple and straightforward, thanks. > diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c > index 7489306cd6f7..85562e26c3de 100644 > --- a/tools/lib/bpf/linker.c > +++ b/tools/lib/bpf/linker.c > @@ -135,6 +135,7 @@ struct bpf_linker { > int fd; > Elf *elf; > Elf64_Ehdr *elf_hdr; > + bool swapped_endian; > [...]