From: Ian Campbell <Ian.Campbell@xensource.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andrew Morton <akpm@osdl.org>,
Virtualization <virtualization@lists.osdl.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Translate asm version of ELFNOTE macro into preprocessor macro
Date: Wed, 23 Aug 2006 20:43:27 +0100 [thread overview]
Message-ID: <1156362207.19808.69.camel@localhost.localdomain> (raw)
In-Reply-To: <44EC94C2.9080608@goop.org>
On Wed, 2006-08-23 at 10:47 -0700, Jeremy Fitzhardinge wrote:
>
> I remember now why I decided to use the assembler macro rather than
> cpp. The macro names the section after the note name (".note.NAME"),
> and it needs to be quoted so that the name can have spaces and other
> characters which would otherwise upset the assembler. I couldn't work
> out a clean way to do this with the C preprocessor, since "as" doesn't
> support string concatenation like C does.
Surprisingly string concatenation doesn't appear to be required for the
majority of punctuation, at least so far as I can tell with this test
patch (this is a xen-unstable kernel I had lying around so don't pay too
much attention to head-xen.S bit). The only problem I found is comma,
which can't be escaped.
I've no idea how reliably this works across tool chain versions etc
though. It worked for me ;-)
--- ref-linux-2.6.16.13/include/linux/elfnote.h 2006-08-23 20:08:56.000000000 +0100
+++ linux-2.6.16.13-xen/include/linux/elfnote.h 2006-08-23 20:10:00.000000000 +0100
@@ -39,7 +39,7 @@
* ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)
*/
#define ELFNOTE(name, type, desctype, descdata) \
-.pushsection .note.name ; \
+.pushsection ".note.name" ; \
.align 4 ; \
.long 2f - 1f /* namesz */ ; \
.long 4f - 3f /* descsz */ ; \
diff -r 58b5141c8309 linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S
--- a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S Wed Aug 23 14:43:48 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S Wed Aug 23 20:27:05 2006 +0100
@@ -199,3 +199,11 @@ ENTRY(cpu_gdt_table)
ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "no")
#endif
ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
+
+ ELFNOTE(XYZ Co., 42, .asciz, "forty-two")
+ ELFNOTE(XYZ Co., 12, .long, 0xdeadbeef)
+ ELFNOTE(!\"£$%^\\&, 12, .long, 0xdeadbeef)
+ ELFNOTE(*\(\)-+-=<, 12, .long, 0xdeadbeef)
+ ELFNOTE(>./?\;\'#:, 12, .long, 0xdeadbeef)
+ ELFNOTE(@~, 12, .long, 0xdeadbeef)
+
$ readelf -S --segments arch/i386/kernel/head-xen.o
...
[ 7] .note.Xen NOTE 00000000 002260 000144 00 0 0 4
[ 8] .rel.note.Xen REL 00000000 003018 000010 08 15 7 4
[ 9] .note.XYZ Co. NOTE 00000000 0023a4 000038 00 0 0 4
[10] .note.!"£$%^\& NOTE 00000000 0023dc 00001c 00 0 0 4
[11] .note.*()-+-=< NOTE 00000000 0023f8 00001c 00 0 0 4
[12] .note.>./?;'#: NOTE 00000000 002414 00001c 00 0 0 4
[13] .note.@~ NOTE 00000000 002430 000014 00 0 0 4
...
$ objdump -j .notes -s vmlinux
...
85a8 72696300 08000000 0a000000 2a000000 ric.........*...
85b8 58595a20 436f2e00 666f7274 792d7477 XYZ Co..forty-tw
85c8 6f000000 08000000 04000000 0c000000 o...............
85d8 58595a20 436f2e00 efbeadde 0a000000 XYZ Co..........
85e8 04000000 0c000000 2122c2a3 24255e5c ........!"..$%^\
85f8 26000000 efbeadde 09000000 04000000 &...............
8608 0c000000 2a28292d 2b2d3d3c 00000000 ....*()-+-=<....
8618 efbeadde 09000000 04000000 0c000000 ................
8628 3e2e2f3f 3b27233a 00000000 efbeadde >./?;'#:........
8638 03000000 04000000 0c000000 407e0000 ............@~..
8648 efbeadde ....
...
next prev parent reply other threads:[~2006-08-23 19:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-23 11:49 [PATCH] Translate asm version of ELFNOTE macro into preprocessor macro Ian Campbell
2006-08-23 14:49 ` Jeremy Fitzhardinge
2006-08-23 15:14 ` Ian Campbell
2006-08-23 15:23 ` Jeremy Fitzhardinge
2006-08-23 17:11 ` Eric W. Biederman
2006-08-23 17:47 ` Jeremy Fitzhardinge
2006-08-23 19:43 ` Ian Campbell [this message]
2006-08-23 21:02 ` Jeremy Fitzhardinge
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=1156362207.19808.69.camel@localhost.localdomain \
--to=ian.campbell@xensource.com \
--cc=akpm@osdl.org \
--cc=ebiederm@xmission.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.osdl.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).