
Patch from: https://github.com/xdp-project/xdp-tools/pull/341

From b1377b35cd05daf4d3afc3d59839e9889a642ffb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Holger=20Hoffst=C3=A4tte?= <holger@applied-asynchrony.com>
Date: Sat, 8 Jul 2023 12:34:20 +0200
Subject: [PATCH] libxdp: don't use direct call to readelf for symbol table
 comparison
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Gentoo CI previously reported symbol mismatches in libxdp
(see #302 and https://bugs.gentoo.org/899742). This was
caused by a direct call to 'readelf' instead of using the
command injected by the environment/toolchain.
The fix is simple: use $(READELF).

Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
---
 lib/libxdp/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libxdp/Makefile b/lib/libxdp/Makefile
index 43de3e8a..532e0687 100644
--- a/lib/libxdp/Makefile
+++ b/lib/libxdp/Makefile
@@ -93,12 +93,12 @@ $(SHARED_OBJDIR)/%.o: %.c $(EXTRA_LIB_DEPS) | $(SHARED_OBJDIR)
 
 XDP_IN_SHARED	:= $(SHARED_OBJDIR)/libxdp.o $(SHARED_OBJDIR)/xsk.o
 
-GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(XDP_IN_SHARED) | \
+GLOBAL_SYM_COUNT = $(shell $(READELF) -s --wide $(XDP_IN_SHARED) | \
 			   cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \
 			   sed 's/\[.*\]//' | \
 			   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}' | \
 			   sort -u | wc -l)
-VERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide $(OBJDIR)/libxdp.so | \
+VERSIONED_SYM_COUNT = $(shell $(READELF) --dyn-syms --wide $(OBJDIR)/libxdp.so | \
 			      grep -Eo '[^ ]+@LIBXDP_' | cut -d@ -f1 | sort -u | wc -l)
 
 check: $(CHECK_RULES)
@@ -110,12 +110,12 @@ check_abi: $(OBJDIR)/libxdp.so
 		     "versioned symbols in $^ ($(VERSIONED_SYM_COUNT))." \
 		     "Please make sure all symbols are"	 \
 		     "versioned in $(VERSION_SCRIPT)." >&2;		 \
-		readelf -s --wide $(XDP_IN_SHARED) |			 \
+		$(READELF) -s --wide $(XDP_IN_SHARED) |			 \
 		    cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' |	 \
 		    sed 's/\[.*\]//' |					 \
 		    awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
 		    sort -u > $(OUTPUT)libxdp_global_syms.tmp;		 \
-		readelf --dyn-syms --wide $(OUTPUT)libxdp.so |		 \
+		$(READELF) --dyn-syms --wide $(OUTPUT)libxdp.so |		 \
 		    grep -Eo '[^ ]+@LIBXDP_' | cut -d@ -f1 |		 \
 		    sort -u > $(OUTPUT)libxdp_versioned_syms.tmp; 	 \
 		diff -u $(OUTPUT)libxdp_global_syms.tmp			 \
