[PATCH] powerpc: Don't change the section in _GLOBAL()

Nicholas Piggin npiggin at gmail.com
Thu Sep 15 13:54:03 AEST 2016


On Thu, 15 Sep 2016 10:40:20 +1000
Michael Ellerman <mpe at ellerman.id.au> wrote:

> Currently the _GLOBAL() macro unilaterally sets the assembler section to
> ".text" at the start of the macro. This is rude as the caller may be
> using a different section.
> 
> So let the caller decide which section to emit the code into. On big
> endian we do need to switch to the ".opd" section to emit the OPD, but
> do that with pushsection/popsection, thereby leaving the original
> section intact.
> 
> The only place I could find where this requires changes to the code is
> in misc_32.S, where we need to switch back to ".text" after
> flush_icache_range() which is in ".kprobes.text".
> 
> I verified that the order of all entries in System.map is unchanged
> after this patch. The actual addresses shift around slightly so you
> can't just diff the System.map.
> 
> Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>

Excellent, thanks for going through it.

Reviewed-by: Nicholas Piggin <npiggin at gmail.com>

> ---
> 
> If anyone can think of a better method to verify we are still emitting
> everything in the same sections let me know.
> 
> 
>  arch/powerpc/include/asm/ppc_asm.h | 8 ++------
>  arch/powerpc/kernel/misc_32.S      | 3 +++
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
> index d5d5b5e348f2..479287045166 100644
> --- a/arch/powerpc/include/asm/ppc_asm.h
> +++ b/arch/powerpc/include/asm/ppc_asm.h
> @@ -201,14 +201,12 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
>  #ifdef PPC64_ELF_ABI_v2
>  
>  #define _GLOBAL(name) \
> -	.section ".text"; \
>  	.align 2 ; \
>  	.type name, at function; \
>  	.globl name; \
>  name:
>  
>  #define _GLOBAL_TOC(name) \
> -	.section ".text"; \
>  	.align 2 ; \
>  	.type name, at function; \
>  	.globl name; \
> @@ -232,16 +230,15 @@ name:
>  #define GLUE(a,b) XGLUE(a,b)
>  
>  #define _GLOBAL(name) \
> -	.section ".text"; \
>  	.align 2 ; \
>  	.globl name; \
>  	.globl GLUE(.,name); \
> -	.section ".opd","aw"; \
> +	.pushsection ".opd","aw"; \
>  name: \
>  	.quad GLUE(.,name); \
>  	.quad .TOC. at tocbase; \
>  	.quad 0; \
> -	.previous; \
> +	.popsection; \

I think you can still use .section and .previous here, but it's
much of a muchness.


More information about the Linuxppc-dev mailing list