From: Xin Liu <liuxin350@huawei.com>
To: <quentin@isovalent.com>
Cc: <andrii@kernel.org>, <ast@kernel.org>, <bpf@vger.kernel.org>,
<daniel@iogearbox.net>, <haoluo@google.com>,
<john.fastabend@gmail.com>, <jolsa@kernel.org>,
<kongweibin2@huawei.com>, <kpsingh@kernel.org>,
<linux-kernel@vger.kernel.org>, <liuxin350@huawei.com>,
<martin.lau@linux.dev>, <sdf@google.com>, <song@kernel.org>,
<wuchangye@huawei.com>, <xiesongyang@huawei.com>,
<yanan@huawei.com>, <yhs@fb.com>, <zhudi2@huawei.com>
Subject: Re: [PATCH 1/2] libbpf: add fPIC option for static library
Date: Wed, 28 Sep 2022 16:32:56 +0800 [thread overview]
Message-ID: <20220928083256.57679-1-liuxin350@huawei.com> (raw)
In-Reply-To: <c5c5cedb-4b32-2569-1d55-fc95cad1b260@isovalent.com>
On Tue, 27 Sep 2022 at 6:21:20 PM Quentin <quentin@isovalent.com> wrote:
> Sat Sep 24 2022 11:12:08 GMT+0100 ~ Xin Liu <liuxin350@huawei.com>
> > Some programs depned on libbpf.a(eg:bpftool). If libbpf.a miss -fPIC,
>
> Typo "depned"
>
> > 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 =
>
> Hi, the two patches look OK to me, but it would be nice to have a bit
> more context on what the flags do other than “fixing this particular
> issue” and how they improve bpftool security. It would also be
> interesting to have a note on what it does on various architectures, my
> understanding is that only some archs are supported (I read AArch64,
> m68k, PowerPC and SPARC), I guess the flags are silently ignored on x86
> for example?
>
> Thanks,
> Quentin
>
This advice is very useful to me. Thank you very much for your reply.
I'll fix it in the V2 version.
Thansk,
Xin Liu
next prev parent reply other threads:[~2022-09-28 8:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-24 10:12 [PATCH 0/2] ebpf: improves bpftool security Xin Liu
2022-09-24 10:12 ` [PATCH 1/2] libbpf: add fPIC option for static library Xin Liu
2022-09-27 10:21 ` Quentin Monnet
2022-09-28 8:32 ` Xin Liu [this message]
2022-09-28 22:59 ` Andrii Nakryiko
2022-09-30 2:16 ` John Fastabend
2022-09-24 10:12 ` [PATCH 2/2] bpftool: add fPIE option for bpftool Xin Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220928083256.57679-1-liuxin350@huawei.com \
--to=liuxin350@huawei.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kongweibin2@huawei.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=quentin@isovalent.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=wuchangye@huawei.com \
--cc=xiesongyang@huawei.com \
--cc=yanan@huawei.com \
--cc=yhs@fb.com \
--cc=zhudi2@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®