Skip to contentSkip to conversation

Clean up ELF note generation

PATCH In review Jeremy Fitzhardinge 2 participants 2 messages Mar 15, 2007 – Mar 16, 2007 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Clean up ELF note generation

Three cleanups:

1: ELF notes are never mapped, so there's no need to have any access flags in their phdr.

2: When generating them from asm, tell the assembler to use a SHT_NOTE section type. There doesn't seem to be a way to do this from C.

3: Use ANSI rather than traditional cpp behaviour to stringify the macro argument.

---
 arch/i386/kernel/vmlinux.lds.S    |    2 +-
 include/asm-generic/vmlinux.lds.h |    2 +-
 include/linux/elfnote.h           |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

===================================================================

arch/i386/kernel/vmlinux.lds.S +1 -1
@@ -34,7 +34,7 @@ PHDRS {
 PHDRS {
 	text PT_LOAD FLAGS(5);	/* R_E */
 	data PT_LOAD FLAGS(7);	/* RWE */
-	note PT_NOTE FLAGS(4);	/* R__ */
+	note PT_NOTE FLAGS(0);	/* ___ */
 }
 SECTIONS
 {

===================================================================

include/asm-generic/vmlinux.lds.h +1 -1
@@ -208,7 +208,7 @@
 	}
 
 #define NOTES								\
-		.notes : { *(.note.*) } :note
+	.notes : { *(.note.*) } :note
 
 #define INITCALLS							\
   	*(.initcall0.init)						\

===================================================================

include/linux/elfnote.h +2 -2
@@ -39,12 +39,12 @@
  *      ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)
  */
 #define ELFNOTE(name, type, desctype, descdata)	\
-.pushsection .note.name			;	\
+.pushsection .note.name, "",@note	;	\
   .align 4				;	\
   .long 2f - 1f		/* namesz */	;	\
   .long 4f - 3f		/* descsz */	;	\
   .long type				;	\
-1:.asciz "name"				;	\
+1:.asciz #name				;	\
 2:.align 4				;	\
 3:desctype descdata			;	\
 4:.align 4				;	\
#1 lore raw

arch/i386/kernel/vmlinux.lds.S PHDRS { · line 38

Quoted 3 lines
arch/i386/kernel/vmlinux.lds.S +1 -1
-       note PT_NOTE FLAGS(4);  /* R__ */
+       note PT_NOTE FLAGS(0);  /* ___ */
 }

This seems to happen in at least 3 more architectures. Worth a broader cleanup?

Signature · 4 lines
Glauber de Oliveira Costa.
"Free as in Freedom"

"The less confident you are, the more serious you have to act."