linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: patchwork-bot+netdevbpf@kernel.org,
	Ard Biesheuvel <ardb+git@google.com>,
	 linux-kernel@vger.kernel.org, arnd@arndb.de,
	martin.lau@linux.dev,  linux-arch@vger.kernel.org,
	linux-kbuild@vger.kernel.org, bpf@vger.kernel.org,
	 andrii@kernel.org, olsajiri@gmail.com
Subject: Re: [PATCH v4 0/3] kbuild: Avoid weak external linkage where possible
Date: Sat, 20 Apr 2024 15:56:31 +0200	[thread overview]
Message-ID: <CAMj1kXEbXfsNarFMbDC-Dzk6H9X9C4Ax2pWPSZhmt93mV4_Q2w@mail.gmail.com> (raw)
In-Reply-To: <CAK7LNAT9Y5C+Shr1Pq=xrL2tcBK6rpBn05iovdZ2=kMHW5UCkw@mail.gmail.com>

On Sat, 20 Apr 2024 at 15:42, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Sat, Apr 20, 2024 at 9:35 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > On Sat, 20 Apr 2024 at 14:32, Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > On Fri, Apr 19, 2024 at 4:57 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> > > >
> > > > On Tue, 16 Apr 2024 at 16:40, <patchwork-bot+netdevbpf@kernel.org> wrote:
> > > > >
> > > > > Hello:
> > > > >
> > > > > This series was applied to bpf/bpf-next.git (master)
> > > > > by Daniel Borkmann <daniel@iogearbox.net>:
> > > > >
> > > > > On Mon, 15 Apr 2024 18:20:42 +0200 you wrote:
> > > > > > From: Ard Biesheuvel <ardb@kernel.org>
> > > > > >
> > > > > > Weak external linkage is intended for cases where a symbol reference
> > > > > > can remain unsatisfied in the final link. Taking the address of such a
> > > > > > symbol should yield NULL if the reference was not satisfied.
> > > > > >
> > > > > > Given that ordinary RIP or PC relative references cannot produce NULL,
> > > > > > some kind of indirection is always needed in such cases, and in position
> > > > > > independent code, this results in a GOT entry. In ordinary code, it is
> > > > > > arch specific but amounts to the same thing.
> > > > > >
> > > > > > [...]
> > > > >
> > > > > Here is the summary with links:
> > > > >   - [v4,1/3] kallsyms: Avoid weak references for kallsyms symbols
> > > > >     (no matching commit)
> > > > >   - [v4,2/3] vmlinux: Avoid weak reference to notes section
> > > > >     (no matching commit)
> > > > >   - [v4,3/3] btf: Avoid weak external references
> > > > >     https://git.kernel.org/bpf/bpf-next/c/fc5eb4a84e4c
> > > > >
> > > >
> > > >
> > > > Thanks.
> > > >
> > > > Masahiro, could you pick up patches #1 and #2 please?
> > > >
> > >
> > >
> > > I do not like PROVIDE() because it potentially shifts
> > > a build error (i.e. link error) into
> > > a run-time error, which is usually more difficult to debug
> > > than build error.
> > >
> > > If someone references the kallsyms_* symbols
> > > when CONFIG_KALLSYMS=n, it is likely a mistake.
> > > In general, it should be reported as a link error.
> > >
> >
> > OK, so the PROVIDE() should be conditional on CONFIG_KALLSYM=y. I can fix that.
>
>
> You may need to take care of the dependency
> between CONFIG_KALLSYMS and CONFIG_VMCORE_INFO
> because kernel/vmcore_info.c has references
> to the kallsyms_* symbols.
>
> (I am still not a big fan of PROVIDE() though)
>


OK, how about we use weak definitions (as opposed to weak references)
in kernel/kallsyms.c, which will get superseded by the actual ones in
the second linker pass.

The only difference is that we will use some space in the binary for
the weak definitions that are never used in the final build.

  reply	other threads:[~2024-04-20 13:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 16:20 [PATCH v4 0/3] kbuild: Avoid weak external linkage where possible Ard Biesheuvel
2024-04-15 16:20 ` [PATCH v4 1/3] kallsyms: Avoid weak references for kallsyms symbols Ard Biesheuvel
2024-04-23 13:44   ` Masahiro Yamada
2024-04-15 16:20 ` [PATCH v4 2/3] vmlinux: Avoid weak reference to notes section Ard Biesheuvel
2024-04-20 13:42   ` Masahiro Yamada
2024-04-15 16:20 ` [PATCH v4 3/3] btf: Avoid weak external references Ard Biesheuvel
2024-04-16 14:40 ` [PATCH v4 0/3] kbuild: Avoid weak external linkage where possible patchwork-bot+netdevbpf
2024-04-19  7:57   ` Ard Biesheuvel
2024-04-20 12:31     ` Masahiro Yamada
2024-04-20 12:35       ` Ard Biesheuvel
2024-04-20 13:41         ` Masahiro Yamada
2024-04-20 13:56           ` Ard Biesheuvel [this message]
2024-04-20 13:59             ` Ard Biesheuvel
2024-04-20 14:05               ` Masahiro Yamada

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=CAMj1kXEbXfsNarFMbDC-Dzk6H9X9C4Ax2pWPSZhmt93mV4_Q2w@mail.gmail.com \
    --to=ardb@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ardb+git@google.com \
    --cc=arnd@arndb.de \
    --cc=bpf@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=olsajiri@gmail.com \
    --cc=patchwork-bot+netdevbpf@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).