blob: a17b8b8b027c1cc8a252e8d4fd806da413d9478b [file] [log] [blame]
From da5cddfb13fdf8357ea85a1592f7c8e39e29ad24 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <>
Date: Thu, 4 Jun 2020 16:50:49 -0700
Subject: [PATCH] elfnote: mark all .note sections SHF_ALLOC
commit 51da9dfb7f20911ae4e79e9b412a9c2d4c373d4b upstream.
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.
.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
Signed-off-by: Nick Desaulniers <>
Signed-off-by: Andrew Morton <>
Reviewed-by: Nathan Chancellor <>
Reviewed-by: Fangrui Song <>
Cc: Jeremy Fitzhardinge <>
Cc: Thomas Gleixner <>
Cc: Vincenzo Frascino <>
Debugged-by: Ilie Halip <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Paul Gortmaker <>
diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
index f236f5b931b2..7fdd7f355b52 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 ; \