From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Jim Cromie <jim.cromie@gmail.com>
Cc: Alexander Lobakin <alexandr.lobakin@intel.com>,
jbaron@akamai.com, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] vmlinux.lds.h: add HEADERED_SECTION_* macros
Date: Fri, 16 Dec 2022 19:11:07 +0100 [thread overview]
Message-ID: <20221216181107.687254-1-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <20221216162500.3023331-1-alexandr.lobakin@intel.com>
> From: Jim Cromie <jim.cromie@gmail.com>
> Date: Wed, 16 Nov 2022 17:20:22 -0700
>
> > These macros elaborate on BOUNDED_SECTION_(PRE|POST)_LABEL macros,
> > prepending an optional KEEP(.gnu.linkonce##_sec_) reservation, and a
> > linker-symbol to address it.
> >
> > This allows a developer to define a header struct (which must fit with
> > the section's base struct-type), and could contain:
>
> [...]
>
> > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> > index 85d5d5b203dc..a3b6aa30a525 100644
> > --- a/include/asm-generic/vmlinux.lds.h
> > +++ b/include/asm-generic/vmlinux.lds.h
> > @@ -214,6 +214,21 @@
> >
> > #define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec)
> >
Also, those two pasting ops below:
> > +#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
> > + _HDR_##_label_ = .; \
> > + KEEP(*(.gnu.linkonce.##_sec_)) \
^^
> > + BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
> > +
> > +#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
> > + _label_##_HDR_ = .; \
> > + KEEP(*(.gnu.linkonce.##_sec_)) \
^^
will produce incorrect results when @_sec_ starts with a dot (not
a rare thing for section names):
HEADERED_SECTION_BY(.entry_sites, _entry_sites)
vmlinux.map:
.entry_sites 0xffffffff83c89ca0 0x37118 load address 0x0000000003c89ca0
0xffffffff83c89ca0 __header_entry_sites = .
*(.gnu.linkonce. .entry_sites)
here ^^^
.entry_sites 0xffffffff83c89ca0 0x37118 vmlinux.o
0xffffffff83cc0db8 __start_entry_sites = .
*(.entry_sites)
0xffffffff83cc0db8 __stop_entry_sites = .
^ as a result, all .entry_sites entries went to the "header" instead
of the "body".
Sorta dangerous stuff as for me, maybe that could be handled
differently?
> > + BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
> > +
> > +#define HEADERED_SECTION_BY(_sec_, _label_) \
> > + HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
>
> Now HEADERED_SECTION_PRE_LABEL() takes 5 arguments, but this line
> passes only 4 to it. This went unnoticed probably due to that the
> macro is not used anywhere, thus can't trigger a compiler error.
> Would you prefer to fix it yourself or me to send the fix?[*]
>
> > +
> > +#define HEADERED_SECTION(_sec) HEADERED_SECTION_BY(_sec, _sec)
> > +
> > #ifdef CONFIG_TRACE_BRANCH_PROFILING
> > #define LIKELY_PROFILE() \
> > BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)
> > --
> > 2.38.1
>
> [*] If it needs fixing at all -- some people over the MLs say that
> if there's no trigger, then there's nothing to fix :clownface:
>
> Thanks,
> Olek
Thanks,
Olek
prev parent reply other threads:[~2022-12-16 18:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-22 22:56 [PATCH 0/2] RESEND vmlinux.lds.h tweaks Jim Cromie
2022-10-22 22:56 ` [PATCH 1/2] vmlinux.lds.h: add BOUNDED_SECTION* macros Jim Cromie
2022-10-22 22:56 ` [PATCH 2/2] vmlinux.lds.h: place optional header space in BOUNDED_SECTION Jim Cromie
2022-11-10 18:09 ` [PATCH 0/2] RESEND vmlinux.lds.h tweaks Greg KH
2022-11-11 22:36 ` jim.cromie
2022-11-17 0:20 ` [driver-core-next] vmlinux.lds.h fix Jim Cromie
2022-11-17 0:20 ` [PATCH 1/2] vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros Jim Cromie
2022-11-17 6:29 ` Greg KH
2022-11-17 16:43 ` jim.cromie
2022-11-17 17:16 ` [driver-core-next] vmlinux.lds.h fix (corrected) Jim Cromie
2022-11-17 17:16 ` [PATCH 1/2] vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros Jim Cromie
2022-11-17 17:16 ` [PATCH 2/2] vmlinux.lds.h: add HEADERED_SECTION_* macros Jim Cromie
2022-11-17 18:38 ` [driver-core-next] vmlinux.lds.h fix (corrected) Greg KH
2022-11-17 0:20 ` [PATCH 2/2] vmlinux.lds.h: add HEADERED_SECTION_* macros Jim Cromie
2022-12-16 16:25 ` Alexander Lobakin
2022-12-16 18:11 ` Alexander Lobakin [this message]
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=20221216181107.687254-1-alexandr.lobakin@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbaron@akamai.com \
--cc=jim.cromie@gmail.com \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®