From nobody Thu Apr 2 15:02:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08C29C6FA86 for ; Sat, 24 Sep 2022 10:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233680AbiIXKNa (ORCPT ); Sat, 24 Sep 2022 06:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233437AbiIXKN1 (ORCPT ); Sat, 24 Sep 2022 06:13:27 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E24FA3D6B; Sat, 24 Sep 2022 03:13:24 -0700 (PDT) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MZPtP63MSzHqQZ; Sat, 24 Sep 2022 18:11:09 +0800 (CST) Received: from dggpeml500010.china.huawei.com (7.185.36.155) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 24 Sep 2022 18:13:22 +0800 Received: from huawei.com (10.175.101.6) by dggpeml500010.china.huawei.com (7.185.36.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 24 Sep 2022 18:13:21 +0800 From: Xin Liu To: , , , , , , , , , , CC: , , , , , , , Subject: [PATCH 1/2] libbpf: add fPIC option for static library Date: Sat, 24 Sep 2022 18:12:08 +0800 Message-ID: <20220924101209.50653-2-liuxin350@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220924101209.50653-1-liuxin350@huawei.com> References: <20220924101209.50653-1-liuxin350@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500010.china.huawei.com (7.185.36.155) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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 +=3D $(INCLUDES) override CFLAGS +=3D -fvisibility=3Dhidden override CFLAGS +=3D -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 override CFLAGS +=3D $(CLANG_CROSS_FLAGS) +override CFLAGS +=3D -fPIC =20 # flags specific for shared library -SHLIB_FLAGS :=3D -DSHARED -fPIC +SHLIB_FLAGS :=3D -DSHARED =20 ifeq ($(VERBOSE),1) Q =3D --=20 2.33.0