[PATCH v4 02/26] arm64/sysreg: Add LINKER_SCRIPT guards for sysreg.h

Mark Rutland mark.rutland at arm.com
Wed Jun 22 04:11:10 PDT 2022


On Mon, Jun 20, 2022 at 01:43:43PM +0100, Mark Brown wrote:
> Linker scripts are preprocessed with __ASSEMBLY__ defined which works well
> for most things but not for assembler macros. In preparation for allowing
> sysreg.h to be included in linker files add some LINKER_SCRIPT guard
> defines around assembler macros in headers so the headers are safe for
> inclusion in linker scripts.

Where does that need to happen?

I couldn't spot a direct include; does that happen as a transitive dependency
later in the series?

Mark.

> Signed-off-by: Mark Brown <broonie at kernel.org>
> ---
>  arch/arm64/include/asm/gpr-num.h | 3 +++
>  arch/arm64/include/asm/sysreg.h  | 2 ++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/gpr-num.h b/arch/arm64/include/asm/gpr-num.h
> index 05da4a7c5788..72c44f63fb41 100644
> --- a/arch/arm64/include/asm/gpr-num.h
> +++ b/arch/arm64/include/asm/gpr-num.h
> @@ -4,12 +4,15 @@
>  
>  #ifdef __ASSEMBLY__
>  
> +#ifndef LINKER_SCRIPT
> +
>  	.irp	num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
>  	.equ	.L__gpr_num_x\num, \num
>  	.equ	.L__gpr_num_w\num, \num
>  	.endr
>  	.equ	.L__gpr_num_xzr, 31
>  	.equ	.L__gpr_num_wzr, 31
> +#endif /* !LINKER_SCRIPT */
>  
>  #else /* __ASSEMBLY__ */
>  
> diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
> index 42ff95dba6da..6c7be1a2114b 100644
> --- a/arch/arm64/include/asm/sysreg.h
> +++ b/arch/arm64/include/asm/sysreg.h
> @@ -1219,6 +1219,7 @@
>  
>  #ifdef __ASSEMBLY__
>  
> +#ifndef LINKER_SCRIPT
>  	.macro	mrs_s, rt, sreg
>  	 __emit_inst(0xd5200000|(\sreg)|(.L__gpr_num_\rt))
>  	.endm
> @@ -1226,6 +1227,7 @@
>  	.macro	msr_s, sreg, rt
>  	__emit_inst(0xd5000000|(\sreg)|(.L__gpr_num_\rt))
>  	.endm
> +#endif /* !LINKER_SCRIPT */
>  
>  #else
>  
> -- 
> 2.30.2
> 



More information about the linux-arm-kernel mailing list