linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: julien.grall@linaro.org (Julien Grall)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] Extend zImage format to support notes
Date: Mon, 07 Apr 2014 14:59:53 +0100	[thread overview]
Message-ID: <5342AF59.3030405@linaro.org> (raw)

Hello all,

Currently ELF is supporting notes (see include/linux/elfnote.h) which
is used by Xen to know the feature supported by the kernel.

On ARM world, the zImage format is mainly used by the distribution.
Rather than ELF, it's currently not possible to add notes on it.

==== Current zImage format ====

The header starts at offset 0x24:
    uint32_t  magic      /* Magic number: 0x016f2818 */
    uint32_t  start      /* absolute load/run zImage address */
    uint32_t  end        /* zImage end address */

==== Extension proposed to zImage format ===

The header stays compatible with the current format and starts at offset 0x24:
    uint32_t  magic0     /* Magic number : 0x16f2818 */
    uint32_t  start      /* absolute load/run zImage address */
    uint32_t  end        /* zImage end address */
    uint32_t  magic1     /* Magic number : "ARM\x32" */
    uint32_t  note_start /* Notes section offset */
    uint32_t  note_end   /* Notes sections end */

I was thinking to also add a version field in case we might want to extend the
format in the future.

The notes section will contains a list of note (see description below).

==== Format of a note ====

The format is compatible with ELF note:

Name size : 4 bytes
Desc size : 4 bytes
Type :  4 bytes: identify the type of the note
Name : variable size, padded to 4 byte boundary
Desc : variable size, padded to 4 byte boundary : contains data related to the note type.

The "Name size", "Desc size" and "Type" fields are interpreted as an integer.

I wrote a quick patch to show what would be the modification on Linux side (see below).

Comments and questions are welcomed.

Sincerely yours,

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 066b034..104d862 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -133,6 +138,12 @@ start:
                .word   0x016f2818              @ Magic numbers to help the loader
                .word   start                   @ absolute load/run zImage address
                .word   _edata                  @ zImage end address
+               .byte   0x41                    @ Magic number, "ARM\x32"
+               .byte   0x52
+               .byte   0x4d
+               .byte   0x32
+               .word   _note_start             @ Notes section offset
+               .word   _note_end               @ Notes section end
  THUMB(                .thumb                  )
 1:
  ARM_BE8(      setend  be )                    @ go BE8 if compiled for BE8
diff --git a/arch/arm/boot/compressed/vmlinux.lds.in b/arch/arm/boot/compressed/vmlinux.lds.in
index 4919f2a..d3287ff 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.in
+++ b/arch/arm/boot/compressed/vmlinux.lds.in
@@ -52,6 +52,10 @@ SECTIONS
   .got                 : { *(.got) }
   _got_end = .;
 
+  _note_start = .;
+  .note                        : { *(.note*) }
+  _note_end = .;
+
   /* ensure the zImage file size is always a multiple of 64 bits */
   /* (without a dummy byte, ld just ignores the empty section) */
   .pad                 : { BYTE(0); . = ALIGN(8); }
diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
index 278e3ef..9ad4488 100644
--- a/include/linux/elfnote.h
+++ b/include/linux/elfnote.h
@@ -39,7 +39,7 @@
  *      ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)
  */
 #define ELFNOTE_START(name, type, flags)       \
-.pushsection .note.name, flags, at note   ;       \
+.pushsection .note.name, flags,%note   ;       \
   .balign 4                            ;       \
   .long 2f - 1f                /* namesz */    ;       \
   .long 4484f - 3f     /* descsz */    ;       \


-- 
Julien Grall

             reply	other threads:[~2014-04-07 13:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-07 13:59 Julien Grall [this message]
2014-04-07 16:04 ` [RFC] Extend zImage format to support notes Mark Rutland
2014-04-07 17:28   ` Julien Grall
2014-04-07 18:25     ` Mark Rutland
2014-04-09 16:31       ` Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5342AF59.3030405@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).