BPF Archive on lore.kernel.org
 help / color / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: bpf <bpf@vger.kernel.org>, iii@linux.ibm.com
Subject: selftests/bpf - Error: failed to open BPF object file: Endian mismatch
Date: Fri, 2 Apr 2021 09:48:36 +0200
Message-ID: <21e66a09-514f-f426-b9e2-13baab0b938b@csgroup.eu> (raw)


I'm having hard time cross-building bpf selftests on an x86 for a powerpc target.

[root@PC-server-ldb bpf]# make CROSS_COMPILE=ppc-linux- ARCH=powerpc V=1
/root/gen_ldb/linux-powerpc/tools/testing/selftests/bpf/host-tools/sbin/bpftool gen skeleton 
/root/gen_ldb/linux-powerpc/tools/testing/selftests/bpf/atomic_bounds.o > 
libbpf: elf: endianness mismatch in atomic_bounds.
Error: failed to open BPF object file: Endian mismatch

[root@PC-server-ldb bpf]# file atomic_bounds.o
atomic_bounds.o: ELF 64-bit MSB relocatable, eBPF, version 1 (SYSV), with debug_info, not stripped

Seems like the just-built host bpftool doesn't take into account target's endianness.

I see the patch https://github.com/torvalds/linux/commit/313e7f6f ("selftest/bpf: Use -m{little, 
big}-endian for clang") in bpf selftest to enable cross-compilation, but it seems it is not enough.

What should I do to get bpftool work with the target's endianness ?


             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02  7:48 Christophe Leroy [this message]
2021-04-02  8:02 ` Christophe Leroy
2021-04-03 16:01   ` Andrii Nakryiko

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21e66a09-514f-f426-b9e2-13baab0b938b@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=bpf@vger.kernel.org \
    --cc=iii@linux.ibm.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
	public-inbox-index bpf

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git