From ec72249e3ad524c1ed4127de4c49d9565259bde3 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sun, 18 Oct 2026 18:00:11 -0700 Subject: [PATCH] xdp-tools: Fix embedded BPF objects when linking with lld libxdp turns its BPF programs into linkable objects with a relocatable link of a raw binary input (cc -r -Wl,--format=binary). Because there is no real object among the inputs, lld on riscv64 writes an object with e_flags 0 (soft-float ABI) and a GNU property note with every CFI feature bit set. Linking it then fails with clang: ld.lld: error: libxdp.a(xdp-dispatcher.embed.o): file has conflicting properties: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG ld.lld: error: libxdp.a(xdp-dispatcher.embed.o): cannot link object files with different floating-point ABI from Scrt1.o Build the embed objects from a small .incbin assembly stub instead, so the compiler driver emits them with the correct target ABI. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj --- ...-BPF-objects-with-.incbin-instead-of.patch | 43 +++++++++++++++++++ .../xdp-tools/xdp-tools_1.6.3.bb | 1 + 2 files changed, 44 insertions(+) create mode 100644 meta-oe/recipes-support/xdp-tools/files/0005-lib-libxdp-Embed-BPF-objects-with-.incbin-instead-of.patch diff --git a/meta-oe/recipes-support/xdp-tools/files/0005-lib-libxdp-Embed-BPF-objects-with-.incbin-instead-of.patch b/meta-oe/recipes-support/xdp-tools/files/0005-lib-libxdp-Embed-BPF-objects-with-.incbin-instead-of.patch new file mode 100644 index 0000000000..1309a84aa1 --- /dev/null +++ b/meta-oe/recipes-support/xdp-tools/files/0005-lib-libxdp-Embed-BPF-objects-with-.incbin-instead-of.patch @@ -0,0 +1,43 @@ +From: Khem Raj +Date: Sun, 18 Oct 2026 18:00:00 -0700 +Subject: [PATCH] lib/libxdp: Embed BPF objects with .incbin instead of ld --format=binary + +The embedded BPF objects are made with a relocatable link of a raw binary +input (cc -r -Wl,--format=binary). When the only input is a raw binary, +the linker has no real object to take target attributes from. With lld on +riscv64 the result has e_flags 0 (soft-float ABI) and a +.note.gnu.property where every CFI feature bit is set. Linking it into +libxdp users then fails: + + ld.lld: error: libxdp.a(xdp-dispatcher.embed.o): file has conflicting + properties: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and + GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG + ld.lld: error: libxdp.a(xdp-dispatcher.embed.o): cannot link object + files with different floating-point ABI from Scrt1.o + +Instead, assemble a small stub that pulls in the BPF object with .incbin. +The compiler driver then emits a normal object for the target ABI. The +_binary__start/_end symbol names that libxdp.c uses stay the same. + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + lib/libxdp/Makefile | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/lib/libxdp/Makefile b/lib/libxdp/Makefile +--- a/lib/libxdp/Makefile ++++ b/lib/libxdp/Makefile +@@ -134,8 +134,10 @@ + $(QUIET_M4)$(M4) $(DEFINES) $< > $@ || ( ret=$$?; rm -f $@; exit $$ret ) + + $(EMBEDDED_XDP_OBJS): %.embed.o: %.o +- $(QUIET_CC)$(CC) -r -nostdlib -Wl,-z,noexecstack,--format=binary $(LDFLAGS) -o $@ $< +- $(Q)$(OBJCOPY) --rename-section .data=.rodata,alloc,load,readonly,data,contents $@ ++ $(QUIET_CC)SYM=_binary_$$(echo '$<' | sed 's/[^A-Za-z0-9_]/_/g'); \ ++ printf '\t.section .rodata,"a"\n\t.balign 8\n\t.globl %s_start\n%s_start:\n\t.incbin "%s"\n\t.globl %s_end\n%s_end:\n' \ ++ $$SYM $$SYM '$<' $$SYM $$SYM | \ ++ $(CC) -c -x assembler -Wa,--noexecstack -o $@ - + + $(XDP_OBJS): %.o: %.c $(BPF_HEADERS) $(LIBMK) + $(QUIET_CLANG)$(CLANG) -target $(BPF_TARGET) $(BPF_CFLAGS) -O2 -c -g -o $@ $< diff --git a/meta-oe/recipes-support/xdp-tools/xdp-tools_1.6.3.bb b/meta-oe/recipes-support/xdp-tools/xdp-tools_1.6.3.bb index bcaa8c91c4..577a7b39d5 100644 --- a/meta-oe/recipes-support/xdp-tools/xdp-tools_1.6.3.bb +++ b/meta-oe/recipes-support/xdp-tools/xdp-tools_1.6.3.bb @@ -18,6 +18,7 @@ SRC_URI = " \ file://0002-lib-libxdp-Makefile-use-cp-fRd-to-preserve-symlinks-.patch \ file://0003-lib-util-avoid-struct-ethhdr-redefinition-on-musl.patch \ file://0004-xdp-filter-xdp-dump-avoid-struct-ethhdr-redefinitio.patch \ + file://0005-lib-libxdp-Embed-BPF-objects-with-.incbin-instead-of.patch \ " SRCREV = "8fbad9f0af621a22aa87ff2520b3735915b1f0fd"