Re: [PATCH] ARM: fix __start_rodata_section_aligned on XIP

From: Geert Uytterhoeven
Date: Tue Feb 16 2016 - 14:20:56 EST


Hi Kees,

On Tue, Feb 16, 2016 at 7:38 PM, Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> This fixes the build for both allnoconfig (!CONFIG_MMU) and with
> XIP_KERNEL (due to missing pieces in the linker script), as seen after
> both "ARM: 8502/1: mm: mark section-aligned portion of rodata NX" and
> "ARM: 8513/1: xip: Move XIP linking to a separate file".
>
> Reported-by: Russell King <linux@xxxxxxxxxxxxxxxx>
> Reported-by: Arnd Bergmann <arnd@xxxxxxxx>
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>

> diff --git a/arch/arm/kernel/vmlinux-xip.lds.S b/arch/arm/kernel/vmlinux-xip.lds.S
> index 40bc4cadb959..2da60cd1b295 100644
> --- a/arch/arm/kernel/vmlinux-xip.lds.S
> +++ b/arch/arm/kernel/vmlinux-xip.lds.S

> @@ -310,6 +311,17 @@ SECTIONS
> }
>
> /*
> + * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will
> + * be the first section-aligned location after __start_rodata. Otherwise,
> + * it will be equal to __start_rodata.
> + */
> +#ifdef CONFIG_MMU

CONFIG_DEBUG_ALIGN_RODATA or CONFIG_MMU?

> +__start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT);
> +#else
> +__start_rodata_section_aligned = __start_rodata;
> +#endif
> +
> +/*
> * These must never be empty
> * If you have to comment these two assert statements out, your
> * binutils is too old (for other reasons as well)
> diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
> index 1707b9431761..f13960e44955 100644
> --- a/arch/arm/kernel/vmlinux.lds.S
> +++ b/arch/arm/kernel/vmlinux.lds.S
> @@ -328,7 +328,11 @@ SECTIONS
> * be the first section-aligned location after __start_rodata. Otherwise,
> * it will be equal to __start_rodata.
> */
> +#ifdef CONFIG_MMU

Likewise (the out-of-scope comment says CONFIG_DEBUG_ALIGN_RODATA)?

> __start_rodata_section_aligned = ALIGN(__start_rodata, 1 << SECTION_SHIFT);
> +#else
> +__start_rodata_section_aligned = __start_rodata;
> +#endif

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds