lkml.org 
[lkml]   [2022]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] libbpf: add fPIC option for static library
Date
Some programs depned on libbpf.a(eg:bpftool). If libbpf.a miss -fPIC,
this will cause a similar error at compile time:

/usr/bin/ld: .../libbpf.a(libbpf-in.o): relocation
R_AARCH64_ADR_PREL_PG_HI21 against symbol `stderr@@GLIBC_2.17' which
may bind externally can not be used when making a sharedobject;
recompile with -fPIC

Use -fPIC for static library compilation to solve this problem.

Signed-off-by: Xin Liu <liuxin350@huawei.com>
---
tools/lib/bpf/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 4c904ef0b47e..427e971f4fcd 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -91,9 +91,10 @@ override CFLAGS += $(INCLUDES)
override CFLAGS += -fvisibility=hidden
override CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
override CFLAGS += $(CLANG_CROSS_FLAGS)
+override CFLAGS += -fPIC

# flags specific for shared library
-SHLIB_FLAGS := -DSHARED -fPIC
+SHLIB_FLAGS := -DSHARED

ifeq ($(VERBOSE),1)
Q =
--
2.33.0
\
 
 \ /
  Last update: 2022-09-24 12:13    [W:0.083 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site