Skip to contentSkip to conversation

elfnote: mark all .note sections SHF_ALLOC

PATCH Applied Nick Desaulniers 3 participants 5 messages Mar 25, 2020 – Apr 10, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 elfnote: mark all .note sections SHF_ALLOC

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

---
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(-)
include/linux/elfnote.h +1 -1
index 594d4e78654f..69b136e4dd2b 100644
@@ -54,7 +54,7 @@
 .popsection				;
 
 #define ELFNOTE(name, type, desc)		\
-	ELFNOTE_START(name, type, "")		\
+	ELFNOTE_START(name, type, "a")		\
 		desc			;	\
 	ELFNOTE_END
 
Signature · 1 line
2.26.0.rc2.310.g2932bb562d-goog
#1 lore raw

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

Quoted 49 lines · Nick Desaulniers

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

---
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(-)
include/linux/elfnote.h +1 -2
index 594d4e78654f..69b136e4dd2b 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers
Reviewed-by
#2 lore raw
Quoted 29 lines · Nick Desaulniers' via Clang Built Linux

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

Quoted 25 lines · Nick Desaulniers

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
Quoted 29 lines
Quoted 24 lines

---
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(-)
include/linux/elfnote.h +1 -2
index 594d4e78654f..69b136e4dd2b 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers
Reviewed-by
#3 lore raw
Quoted 26 lines · Nathan Chancellor
Quoted 25 lines · Nick Desaulniers' via Clang Built Linux

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

Quoted 21 lines · Nick Desaulniers

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
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

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

Quoted 35 lines
Quoted 29 lines
Quoted 22 lines

---
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(-)
include/linux/elfnote.h +1 -2
index 594d4e78654f..69b136e4dd2b 100644
@@ -54,7 +54,7 @@
 .popsection                            ;
 
 #define ELFNOTE(name, type, desc)              \
-       ELFNOTE_START(name, type, "")           \
+       ELFNOTE_START(name, type, "a")          \
                desc                    ;       \
        ELFNOTE_END
 
--
Quoted 2 lines

2.26.0.rc2.310.g2932bb562d-goog

--
Thanks,
~Nick Desaulniers

Signature · 3 lines
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 [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200403222458.GA49554%40ubuntu-m2-xlarge-x86.
#4 lore raw

(bumping for review)

Quoted 64 lines · Fangrui Song
Quoted 26 lines · Nathan Chancellor
Quoted 25 lines · Nick Desaulniers' via Clang Built Linux

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

Quoted 21 lines · Nick Desaulniers

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
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

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

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

---
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(-)
include/linux/elfnote.h +1 -2
index 594d4e78654f..69b136e4dd2b 100644
@@ -54,7 +54,7 @@
 .popsection                            ;
 
 #define ELFNOTE(name, type, desc)              \
-       ELFNOTE_START(name, type, "")           \
+       ELFNOTE_START(name, type, "a")          \
                desc                    ;       \
        ELFNOTE_END
 
--
Signature · 2 lines
Thanks,
~Nick Desaulniers