Skip to content

Commit

Permalink
elfnote: always use the "a" flag for .note.* sections
Browse files Browse the repository at this point in the history
GNU as allows specifying different flags when constructing sections, for
example when the second occurrence has empty flags. But clang may not be so
permissive:
    $ cat test.s
    .pushsection .note.Linux, "a", @note ;
    .pushsection .note.Linux, "", @note ;
    $ as test.s
    $ clang-11 -cc1as -triple x86_64-pc-linux-gnu test.s
    test.s:2:1: error: changed section flags for .note.Linux

The kernel reaches this case when both ELFNOTE_START and ELFNOTE add data
to the same section, because the former is used exclusively with the "a"
flag and the latter always uses empty flags.

In vmlinux, the combined .notes section is marked as SHF_ALLOC, so use
the "a" flag for all these macros.

Link: ClangBuiltLinux#913
Signed-off-by: Ilie Halip <[email protected]>
  • Loading branch information
ihalip committed Mar 5, 2020
1 parent 776e49e commit eee04ad
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/kernel/vdso/note.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <linux/elfnote.h>
#include <linux/build-salt.h>

ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END

Expand Down
2 changes: 1 addition & 1 deletion arch/mips/vdso/elf.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <linux/elfnote.h>
#include <linux/version.h>

ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END

Expand Down
2 changes: 1 addition & 1 deletion arch/nds32/kernel/vdso/note.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#include <linux/version.h>
#include <linux/elfnote.h>

ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END
2 changes: 1 addition & 1 deletion arch/s390/kernel/vdso64/note.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
#include <linux/version.h>
#include <linux/elfnote.h>

ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END
2 changes: 1 addition & 1 deletion arch/sparc/vdso/vdso-note.S
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#include <linux/version.h>
#include <linux/elfnote.h>

ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END
2 changes: 1 addition & 1 deletion arch/sparc/vdso/vdso32/vdso-note.S
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#include <linux/version.h>
#include <linux/elfnote.h>

ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END
2 changes: 1 addition & 1 deletion arch/x86/entry/vdso/vdso-note.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <linux/version.h>
#include <linux/elfnote.h>

ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END

Expand Down
4 changes: 2 additions & 2 deletions arch/x86/entry/vdso/vdso32/note.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/* Ideally this would use UTS_NAME, but using a quoted string here
doesn't work. Remember to change this when changing the
kernel's name. */
ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END

Expand Down Expand Up @@ -39,7 +39,7 @@ BUILD_SALT

#include "../../xen/vdso.h" /* Defines VDSO_NOTE_NONEGSEG_BIT. */

ELFNOTE_START(GNU, 2, "a")
ELFNOTE_START(GNU, 2)
.long 1 /* ncaps */
VDSO32_NOTE_MASK: /* Symbol used by arch/x86/xen/setup.c */
.long 0 /* mask */
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/um/vdso/vdso-note.S
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#include <linux/version.h>
#include <linux/elfnote.h>

ELFNOTE_START(Linux, 0, "a")
ELFNOTE_START(Linux, 0)
.long LINUX_VERSION_CODE
ELFNOTE_END
6 changes: 3 additions & 3 deletions include/linux/elfnote.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
* e.g. ELFNOTE(XYZCo, 42, .asciz, "forty-two")
* ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)
*/
#define ELFNOTE_START(name, type, flags) \
.pushsection .note.name, flags,@note ; \
#define ELFNOTE_START(name, type) \
.pushsection .note.name, "a",@note ; \
.balign 4 ; \
.long 2f - 1f /* namesz */ ; \
.long 4484f - 3f /* descsz */ ; \
Expand All @@ -54,7 +54,7 @@
.popsection ;

#define ELFNOTE(name, type, desc) \
ELFNOTE_START(name, type, "") \
ELFNOTE_START(name, type) \
desc ; \
ELFNOTE_END

Expand Down

0 comments on commit eee04ad

Please sign in to comment.