Add patches to build libbpf.so with SONAME, link against libelf

This commit is contained in:
Hilko Bengen 2018-11-28 09:42:03 +01:00
parent 014c728272
commit 4f1f7c5735
4 changed files with 96 additions and 0 deletions

3
debian/changelog vendored
View File

@ -44,6 +44,9 @@ linux (4.19.8-1~exp1) UNRELEASED; urgency=medium
* debian/rules: Mark more targets as phony
* libcpupower: Hide private function and drop it from .symbols file
[ Hilko Bengen ]
* Add patches to build libbpf.so with SONAME, link against libelf
-- Uwe Kleine-König <ukleinek@debian.org> Wed, 28 Nov 2018 12:20:46 +0100
linux (4.19.5-1~exp1) experimental; urgency=medium

View File

@ -0,0 +1,69 @@
From: Hilko Bengen <bengen@debian.org>
Date: Sun, 02 Dec 2018 23:26:03 +0000
Subject: libbpf: add SONAME to shared object
tools/lib/bpf/libbpf: Add proper version to the shared object.
Add versioning to the shared object to make it easier on distros to
distribute the library without having to watch for API/ABI versioning.
This is similar to the change made to tools/lib/lockdep/Makefile in
be227b45fb228adff4371b8de9e3989904209ff4.
Signed-off-by: Hilko Bengen <bengen@debian.org>
---
Index: linux/tools/lib/bpf/Makefile
===================================================================
--- linux.orig/tools/lib/bpf/Makefile
+++ linux/tools/lib/bpf/Makefile
@@ -1,10 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# Most of this file is copied from tools/lib/traceevent/Makefile
-BPF_VERSION = 0
-BPF_PATCHLEVEL = 0
-BPF_EXTRAVERSION = 1
-
MAKEFLAGS += --no-print-directory
ifeq ($(srctree),)
@@ -94,17 +90,13 @@ export prefix libdir src obj
libdir_SQ = $(subst ','\'',$(libdir))
libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
-LIB_FILE = libbpf.a libbpf.so
+LIBBPF_VERSION=$(shell make --no-print-directory -sC ../../.. kernelversion)
-VERSION = $(BPF_VERSION)
-PATCHLEVEL = $(BPF_PATCHLEVEL)
-EXTRAVERSION = $(BPF_EXTRAVERSION)
+LIB_FILE = libbpf.a libbpf.so.$(LIBBPF_VERSION)
OBJ = $@
N =
-LIBBPF_VERSION = $(BPF_VERSION).$(BPF_PATCHLEVEL).$(BPF_EXTRAVERSION)
-
# Set compile option CFLAGS
ifdef EXTRA_CFLAGS
CFLAGS := $(EXTRA_CFLAGS)
@@ -168,8 +160,8 @@ $(BPF_IN): force elfdep bpfdep
echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h'" >&2 )) || true
$(Q)$(MAKE) $(build)=libbpf
-$(OUTPUT)libbpf.so: $(BPF_IN)
- $(QUIET_LINK)$(CC) --shared $^ -o $@
+$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN)
+ $(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,$(@F) -o $@
$(OUTPUT)libbpf.a: $(BPF_IN)
$(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^
@@ -184,6 +176,7 @@ endef
install_lib: all_cmd
$(call QUIET_INSTALL, $(LIB_FILE)) \
$(call do_install,$(LIB_FILE),$(libdir_SQ))
+ $(Q)ln -sf libbpf.so.$(LIBBPF_VERSION) $(DESTDIR_SQ)$(libdir_SQ)/libbpf.so
install_headers:
$(call QUIET_INSTALL, headers) \

View File

@ -0,0 +1,22 @@
From: Hilko Bengen <bengen@debian.org>
Date: Sun, 02 Dec 2018 23:26:03 +0000
Subject: libbpf: link shared object with libelf
libbpf.so needs to be linked against libelf to avoid missing symbols.
Signed-off-by: Hilko Bengen <bengen@debian.org>
---
Index: linux/tools/lib/bpf/Makefile
===================================================================
--- linux.orig/tools/lib/bpf/Makefile
+++ linux/tools/lib/bpf/Makefile
@@ -161,7 +161,7 @@ $(BPF_IN): force elfdep bpfdep
$(Q)$(MAKE) $(build)=libbpf
$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN)
- $(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,$(@F) -o $@
+ $(QUIET_LINK)$(CC) --shared $^ -lelf -Wl,-soname,$(@F) -o $@
$(OUTPUT)libbpf.a: $(BPF_IN)
$(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^

View File

@ -149,6 +149,8 @@ bugfix/all/tools-lib-api-fs-fs.c-fix-misuse-of-strncpy.patch
bugfix/all/usbip-fix-misuse-of-strncpy.patch
bugfix/x86/tools-x86_energy_perf_policy-fix-uninitialized-varia.patch
bugfix/x86/tools-turbostat-Add-checks-for-failure-of-fgets-and-.patch
bugfix/all/libbpf-add-soname-to-shared-object.patch
bugfix/all/libbpf-link-shared-object-with-libelf.patch
# wireless: Disable regulatory.db direct loading (until we sort out signing)
debian/wireless-disable-regulatory.db-direct-loading.patch