Re: [PATCH 2/3] MODSIGN: Avoid using .incbin in C source
From: Michal Marek
Date: Wed Dec 05 2012 - 04:50:53 EST
On Wed, Dec 05, 2012 at 08:39:11AM +0100, Takashi Iwai wrote:
> At Wed, 05 Dec 2012 10:28:48 +1030,
> Rusty Russell wrote:
> >
> > David Howells <dhowells@xxxxxxxxxx> writes:
> >
> > > Michal Marek <mmarek@xxxxxxx> wrote:
> > >
> > >> Using the asm .incbin statement in C sources breaks any gcc wrapper which
> > >> assumes that preprocessed C source is self-contained. Use a separate .S
> > >> file to include the siging key and certificate.
> > >
> > > I was trying to avoid that as .S files generally don't crop up in generic
> > > code and the format of the assembly varies with the arch. However, you don't
> > > seem to have anything that should cause a problem - so:
> > >
> > > Acked-by: David Howells <dhowells@xxxxxxxxxx>
> >
> > GLOBAL() is defined in x86 only, AFAICT.
Sorry for that, the Tested-by actually meant Tested-on-x86_64-by :/
> How about the revised patch below?
[...]
> diff --git a/kernel/modsign_certificate.S b/kernel/modsign_certificate.S
> new file mode 100644
> index 0000000..695d4e3
> --- /dev/null
> +++ b/kernel/modsign_certificate.S
> @@ -0,0 +1,18 @@
> +#ifndef SYMBOL_PREFIX
> +#define ASM_SYMBOL(sym) sym
> +#else
> +#define PASTE2(x,y) x##y
> +#define PASTE(x,y) PASTE2(x,y)
> +#define ASM_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym)
> +#endif
It looks good, but looking at your patch, I just noticed that we have two
versions of the SYMBOL_PREFIX macro in the kernel now:
scripts/Makefile.lib has had since some time
ifdef CONFIG_SYMBOL_PREFIX
_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
_cpp_flags += $(_sym_flags)
_a_flags += $(_sym_flags)
endif
while include/linux/kernel.h now has
/* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */
#ifdef CONFIG_SYMBOL_PREFIX
#define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
#else
#define SYMBOL_PREFIX ""
#endif
So depending on whether you include <linux/kernel.h> or not,
SYMBOL_PREFIX expands to either a string or a token. James, Rusty, how
about the patch below? If Takashi's patch is applied first, then
obviously the modsign_pubkey.c part should be dropped and the ASM_SYMBOL
definition in modsign_certificate.S can be simplified instead.
Michal