[PATCH v2 1/5] elf: Define note name macros
Baoquan He
bhe at redhat.com
Sun Jan 5 22:06:45 PST 2025
On 01/06/25 at 02:07pm, Akihiko Odaki wrote:
> On 2025/01/06 11:21, Baoquan He wrote:
> > On 01/04/25 at 11:38pm, Akihiko Odaki wrote:
> > > elf.h had a comment saying:
> > > > Notes used in ET_CORE. Architectures export some of the arch register
> > > > sets using the corresponding note types via the PTRACE_GETREGSET and
> > > > PTRACE_SETREGSET requests.
> > > > The note name for these types is "LINUX", except NT_PRFPREG that is
> > > > named "CORE".
> > >
> > > However, NT_PRSTATUS is also named "CORE". It is also unclear what
> > > "these types" refers to.
> > >
> > > To fix these problems, define a name for each note type. The added
> > > definitions are macros so the kernel and userspace can directly refer to
> > > them.
> > >
> > > Signed-off-by: Akihiko Odaki <akihiko.odaki at daynix.com>
> > > ---
> > > include/uapi/linux/elf.h | 86 ++++++++++++++++++++++++++++++++++++++++++++++--
> > > 1 file changed, 83 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
> > > index b44069d29cec..014b705b97d7 100644
> > > --- a/include/uapi/linux/elf.h
> > > +++ b/include/uapi/linux/elf.h
> > > @@ -372,8 +372,6 @@ typedef struct elf64_shdr {
> > > * Notes used in ET_CORE. Architectures export some of the arch register sets
> > > * using the corresponding note types via the PTRACE_GETREGSET and
> > > * PTRACE_SETREGSET requests.
> > > - * The note name for these types is "LINUX", except NT_PRFPREG that is named
> > > - * "CORE".
> > > */
> > > #define NT_PRSTATUS 1
> > > #define NT_PRFPREG 2
> > > @@ -460,9 +458,91 @@ typedef struct elf64_shdr {
> > > #define NT_LOONGARCH_HW_BREAK 0xa05 /* LoongArch hardware breakpoint registers */
> > > #define NT_LOONGARCH_HW_WATCH 0xa06 /* LoongArch hardware watchpoint registers */
> > > -/* Note types with note name "GNU" */
> > > +/* Note used in ET_EXEC and ET_DYN. */
> > > #define NT_GNU_PROPERTY_TYPE_0 5
> > > +/* Note names */
> > > +#define NN_PRSTATUS "CORE"
> > > +#define NN_PRFPREG "CORE"
> > > +#define NN_PRPSINFO "CORE"
> > > +#define NN_TASKSTRUCT "CORE"
> > > +#define NN_AUXV "CORE"
> > > +#define NN_SIGINFO "CORE"
> > > +#define NN_FILE "CORE"
> > > +#define NN_PRXFPREG "LINUX"
> >
> > No objection to make them clearer. Thanks for the effort.
> >
> > Wondering where below arch specific macros are used. So you just
> > added all NN_xxx for the corresponding NT_xxx? Not sure if this is
> > needed if we don't use them at all in the current kernel.
>
> Indeed I just added all NN_xxx. The kernel won't use the macros that are
> defined as "LINUX"; fs/binfmt_elf.c uses "LINUX" by default as the notes
> named "CORE" or "GNU" are exceptional.
>
> Userspace applications may still be interested in these macros as
> demonstrated in:
> https://lore.kernel.org/r/Z3f7zJwu8bu8HYln@e133380.arm.com
>
> These macros also serve as documentation; correcting and clarifying the
> documentation is the main purpose of this series.
I see, thanks. Then the overall series looks good to me.
More information about the kexec
mailing list