linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] elfnote: mark all .note sections SHF_ALLOC
@ 2020-03-25 23:12 Nick Desaulniers
  2020-04-03 22:13 ` Nick Desaulniers
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Desaulniers @ 2020-03-25 23:12 UTC (permalink / raw)
  To: Thomas Gleixner, Andrew Morton
  Cc: clang-built-linux, Nick Desaulniers, Jeremy Fitzhardinge,
	Ilie Halip, Vincenzo Frascino, linux-kernel

ELFNOTE_START allows callers to specify flags for .pushsection assembler
directives.  All callsites but ELF_NOTE use "a" for SHF_ALLOC. For
vdso's that explicitly use ELF_NOTE_START and BUILD_SALT, the same
section is specified twice after preprocessing, once with "a" flag, once
without. Example:

.pushsection .note.Linux, "a", @note ;
.pushsection .note.Linux, "", @note ;

While GNU as allows this ordering, it warns for the opposite ordering,
making these directives position dependent. We'd prefer not to precisely
match this behavior in Clang's integrated assembler.  Instead, the non
__ASSEMBLY__ definition of ELF_NOTE uses
__attribute__((section(".note.Linux"))) which is created with SHF_ALLOC,
so let's make the __ASSEMBLY__ definition of ELF_NOTE consistent with C
and just always use "a" flag.

This allows Clang to assemble a working mainline (5.6) kernel via:
$ make CC=clang AS=clang

Link: https://github.com/ClangBuiltLinux/linux/issues/913
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Debugged-by: Ilie Halip <ilie.halip@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
Ilie has further treewide cleanups:
https://github.com/ihalip/linux/commits/elfnote
This patch is the simplest to move us forwards.

 include/linux/elfnote.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
index 594d4e78654f..69b136e4dd2b 100644
--- a/include/linux/elfnote.h
+++ b/include/linux/elfnote.h
@@ -54,7 +54,7 @@
 .popsection				;
 
 #define ELFNOTE(name, type, desc)		\
-	ELFNOTE_START(name, type, "")		\
+	ELFNOTE_START(name, type, "a")		\
 		desc			;	\
 	ELFNOTE_END
 
-- 
2.26.0.rc2.310.g2932bb562d-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] elfnote: mark all .note sections SHF_ALLOC
  2020-03-25 23:12 [PATCH] elfnote: mark all .note sections SHF_ALLOC Nick Desaulniers
@ 2020-04-03 22:13 ` Nick Desaulniers
  2020-04-03 22:24   ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Desaulniers @ 2020-04-03 22:13 UTC (permalink / raw)
  To: Thomas Gleixner, Andrew Morton
  Cc: clang-built-linux, Ilie Halip, Vincenzo Frascino, LKML

dropping Jeremy; I got bounceback from the email address. Ping for review?

On Wed, Mar 25, 2020 at 4:13 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> ELFNOTE_START allows callers to specify flags for .pushsection assembler
> directives.  All callsites but ELF_NOTE use "a" for SHF_ALLOC. For
> vdso's that explicitly use ELF_NOTE_START and BUILD_SALT, the same
> section is specified twice after preprocessing, once with "a" flag, once
> without. Example:
>
> .pushsection .note.Linux, "a", @note ;
> .pushsection .note.Linux, "", @note ;
>
> While GNU as allows this ordering, it warns for the opposite ordering,
> making these directives position dependent. We'd prefer not to precisely
> match this behavior in Clang's integrated assembler.  Instead, the non
> __ASSEMBLY__ definition of ELF_NOTE uses
> __attribute__((section(".note.Linux"))) which is created with SHF_ALLOC,
> so let's make the __ASSEMBLY__ definition of ELF_NOTE consistent with C
> and just always use "a" flag.
>
> This allows Clang to assemble a working mainline (5.6) kernel via:
> $ make CC=clang AS=clang
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/913
> Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
> Debugged-by: Ilie Halip <ilie.halip@gmail.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> Ilie has further treewide cleanups:
> https://github.com/ihalip/linux/commits/elfnote
> This patch is the simplest to move us forwards.
>
>  include/linux/elfnote.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
> index 594d4e78654f..69b136e4dd2b 100644
> --- a/include/linux/elfnote.h
> +++ b/include/linux/elfnote.h
> @@ -54,7 +54,7 @@
>  .popsection                            ;
>
>  #define ELFNOTE(name, type, desc)              \
> -       ELFNOTE_START(name, type, "")           \
> +       ELFNOTE_START(name, type, "a")          \
>                 desc                    ;       \
>         ELFNOTE_END
>
> --
> 2.26.0.rc2.310.g2932bb562d-goog
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] elfnote: mark all .note sections SHF_ALLOC
  2020-04-03 22:13 ` Nick Desaulniers
@ 2020-04-03 22:24   ` Nathan Chancellor
  2020-04-04  0:40     ` Fangrui Song
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2020-04-03 22:24 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Thomas Gleixner, Andrew Morton, clang-built-linux, Ilie Halip,
	Vincenzo Frascino, LKML

On Fri, Apr 03, 2020 at 03:13:34PM -0700, 'Nick Desaulniers' via Clang Built Linux wrote:
> dropping Jeremy; I got bounceback from the email address. Ping for review?
> 
> On Wed, Mar 25, 2020 at 4:13 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > ELFNOTE_START allows callers to specify flags for .pushsection assembler
> > directives.  All callsites but ELF_NOTE use "a" for SHF_ALLOC. For
> > vdso's that explicitly use ELF_NOTE_START and BUILD_SALT, the same
> > section is specified twice after preprocessing, once with "a" flag, once
> > without. Example:
> >
> > .pushsection .note.Linux, "a", @note ;
> > .pushsection .note.Linux, "", @note ;
> >
> > While GNU as allows this ordering, it warns for the opposite ordering,
> > making these directives position dependent. We'd prefer not to precisely
> > match this behavior in Clang's integrated assembler.  Instead, the non
> > __ASSEMBLY__ definition of ELF_NOTE uses
> > __attribute__((section(".note.Linux"))) which is created with SHF_ALLOC,
> > so let's make the __ASSEMBLY__ definition of ELF_NOTE consistent with C
> > and just always use "a" flag.
> >
> > This allows Clang to assemble a working mainline (5.6) kernel via:
> > $ make CC=clang AS=clang
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/913
> > Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
> > Debugged-by: Ilie Halip <ilie.halip@gmail.com>
> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

> > ---
> > Ilie has further treewide cleanups:
> > https://github.com/ihalip/linux/commits/elfnote
> > This patch is the simplest to move us forwards.
> >
> >  include/linux/elfnote.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
> > index 594d4e78654f..69b136e4dd2b 100644
> > --- a/include/linux/elfnote.h
> > +++ b/include/linux/elfnote.h
> > @@ -54,7 +54,7 @@
> >  .popsection                            ;
> >
> >  #define ELFNOTE(name, type, desc)              \
> > -       ELFNOTE_START(name, type, "")           \
> > +       ELFNOTE_START(name, type, "a")          \
> >                 desc                    ;       \
> >         ELFNOTE_END
> >
> > --
> > 2.26.0.rc2.310.g2932bb562d-goog
> >
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] elfnote: mark all .note sections SHF_ALLOC
  2020-04-03 22:24   ` Nathan Chancellor
@ 2020-04-04  0:40     ` Fangrui Song
  2020-04-10 19:12       ` Nick Desaulniers
  0 siblings, 1 reply; 5+ messages in thread
From: Fangrui Song @ 2020-04-04  0:40 UTC (permalink / raw)
  To: Nathan Chancellor, Nick Desaulniers
  Cc: Thomas Gleixner, Andrew Morton, clang-built-linux, Ilie Halip,
	Vincenzo Frascino, LKML

On 2020-04-03, Nathan Chancellor wrote:
>On Fri, Apr 03, 2020 at 03:13:34PM -0700, 'Nick Desaulniers' via Clang Built Linux wrote:
>> dropping Jeremy; I got bounceback from the email address. Ping for review?
>>
>> On Wed, Mar 25, 2020 at 4:13 PM Nick Desaulniers
>> <ndesaulniers@google.com> wrote:
>> >
>> > ELFNOTE_START allows callers to specify flags for .pushsection assembler
>> > directives.  All callsites but ELF_NOTE use "a" for SHF_ALLOC. For
>> > vdso's that explicitly use ELF_NOTE_START and BUILD_SALT, the same
>> > section is specified twice after preprocessing, once with "a" flag, once
>> > without. Example:
>> >
>> > .pushsection .note.Linux, "a", @note ;
>> > .pushsection .note.Linux, "", @note ;
>> >
>> > While GNU as allows this ordering, it warns for the opposite ordering,
>> > making these directives position dependent. We'd prefer not to precisely
>> > match this behavior in Clang's integrated assembler.  Instead, the non
>> > __ASSEMBLY__ definition of ELF_NOTE uses
>> > __attribute__((section(".note.Linux"))) which is created with SHF_ALLOC,
>> > so let's make the __ASSEMBLY__ definition of ELF_NOTE consistent with C
>> > and just always use "a" flag.
>> >
>> > This allows Clang to assemble a working mainline (5.6) kernel via:
>> > $ make CC=clang AS=clang
>> >
>> > Link: https://github.com/ClangBuiltLinux/linux/issues/913
>> > Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
>> > Debugged-by: Ilie Halip <ilie.halip@gmail.com>
>> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
>
>Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

I asked on binutils@sourceware.org whether GNU as is willing to change.
https://sourceware.org/pipermail/binutils/2020-March/109997.html
I'll also ping that thread.


Reviewed-by: Fangrui Song <maskray@google.com>

>> > ---
>> > Ilie has further treewide cleanups:
>> > https://github.com/ihalip/linux/commits/elfnote
>> > This patch is the simplest to move us forwards.
>> >
>> >  include/linux/elfnote.h | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
>> > index 594d4e78654f..69b136e4dd2b 100644
>> > --- a/include/linux/elfnote.h
>> > +++ b/include/linux/elfnote.h
>> > @@ -54,7 +54,7 @@
>> >  .popsection                            ;
>> >
>> >  #define ELFNOTE(name, type, desc)              \
>> > -       ELFNOTE_START(name, type, "")           \
>> > +       ELFNOTE_START(name, type, "a")          \
>> >                 desc                    ;       \
>> >         ELFNOTE_END
>> >
>> > --
>> > 2.26.0.rc2.310.g2932bb562d-goog
>> >
>>
>>
>> --
>> Thanks,
>> ~Nick Desaulniers
>
>
>-- 
>You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
>To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200403222458.GA49554%40ubuntu-m2-xlarge-x86.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] elfnote: mark all .note sections SHF_ALLOC
  2020-04-04  0:40     ` Fangrui Song
@ 2020-04-10 19:12       ` Nick Desaulniers
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Desaulniers @ 2020-04-10 19:12 UTC (permalink / raw)
  To: Thomas Gleixner, Andrew Morton
  Cc: Nathan Chancellor, clang-built-linux, Ilie Halip,
	Vincenzo Frascino, LKML, Fangrui Song

(bumping for review)

On Fri, Apr 3, 2020 at 5:40 PM Fangrui Song <maskray@google.com> wrote:
>
> On 2020-04-03, Nathan Chancellor wrote:
> >On Fri, Apr 03, 2020 at 03:13:34PM -0700, 'Nick Desaulniers' via Clang Built Linux wrote:
> >> dropping Jeremy; I got bounceback from the email address. Ping for review?
> >>
> >> On Wed, Mar 25, 2020 at 4:13 PM Nick Desaulniers
> >> <ndesaulniers@google.com> wrote:
> >> >
> >> > ELFNOTE_START allows callers to specify flags for .pushsection assembler
> >> > directives.  All callsites but ELF_NOTE use "a" for SHF_ALLOC. For
> >> > vdso's that explicitly use ELF_NOTE_START and BUILD_SALT, the same
> >> > section is specified twice after preprocessing, once with "a" flag, once
> >> > without. Example:
> >> >
> >> > .pushsection .note.Linux, "a", @note ;
> >> > .pushsection .note.Linux, "", @note ;
> >> >
> >> > While GNU as allows this ordering, it warns for the opposite ordering,
> >> > making these directives position dependent. We'd prefer not to precisely
> >> > match this behavior in Clang's integrated assembler.  Instead, the non
> >> > __ASSEMBLY__ definition of ELF_NOTE uses
> >> > __attribute__((section(".note.Linux"))) which is created with SHF_ALLOC,
> >> > so let's make the __ASSEMBLY__ definition of ELF_NOTE consistent with C
> >> > and just always use "a" flag.
> >> >
> >> > This allows Clang to assemble a working mainline (5.6) kernel via:
> >> > $ make CC=clang AS=clang
> >> >
> >> > Link: https://github.com/ClangBuiltLinux/linux/issues/913
> >> > Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
> >> > Debugged-by: Ilie Halip <ilie.halip@gmail.com>
> >> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> >
> >Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
>
> I asked on binutils@sourceware.org whether GNU as is willing to change.
> https://sourceware.org/pipermail/binutils/2020-March/109997.html
> I'll also ping that thread.
>
>
> Reviewed-by: Fangrui Song <maskray@google.com>
>
> >> > ---
> >> > Ilie has further treewide cleanups:
> >> > https://github.com/ihalip/linux/commits/elfnote
> >> > This patch is the simplest to move us forwards.
> >> >
> >> >  include/linux/elfnote.h | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
> >> > index 594d4e78654f..69b136e4dd2b 100644
> >> > --- a/include/linux/elfnote.h
> >> > +++ b/include/linux/elfnote.h
> >> > @@ -54,7 +54,7 @@
> >> >  .popsection                            ;
> >> >
> >> >  #define ELFNOTE(name, type, desc)              \
> >> > -       ELFNOTE_START(name, type, "")           \
> >> > +       ELFNOTE_START(name, type, "a")          \
> >> >                 desc                    ;       \
> >> >         ELFNOTE_END
> >> >
> >> > --

-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-10 19:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 23:12 [PATCH] elfnote: mark all .note sections SHF_ALLOC Nick Desaulniers
2020-04-03 22:13 ` Nick Desaulniers
2020-04-03 22:24   ` Nathan Chancellor
2020-04-04  0:40     ` Fangrui Song
2020-04-10 19:12       ` Nick Desaulniers

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).