Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [boot-wrapper PATCH] model.lds.S: Quote file paths
@ 2023-01-02 13:24 Kevin Brodsky
  2023-01-30 14:41 ` Mark Rutland
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Brodsky @ 2023-01-02 13:24 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Mark Rutland, Kevin Brodsky

Inserting arbitrary paths in a linker script verbatim can be
problematic, even if they don't contain whitespaces, as ld has a
special interpretation for certain special characters (such as @).

Fix this by quoting all user-provided paths in model.lds.S using the
preprocessor.

Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
---
 model.lds.S | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/model.lds.S b/model.lds.S
index dacaa25ba9fd..e07cbc04b9fa 100644
--- a/model.lds.S
+++ b/model.lds.S
@@ -7,6 +7,9 @@
  * found in the LICENSE.txt file.
  */
 
+#define _STR(s) #s
+#define STR(s) _STR(s)
+
 #ifdef BOOTWRAPPER_32
 OUTPUT_FORMAT("elf32-littlearm")
 OUTPUT_ARCH(arm)
@@ -17,13 +20,13 @@ OUTPUT_ARCH(aarch64)
 TARGET(binary)
 
 #ifdef XEN
-INPUT(XEN)
+INPUT(STR(XEN))
 #endif
-INPUT(KERNEL)
+INPUT(STR(KERNEL))
 INPUT(./fdt.dtb)
 
 #ifdef USE_INITRD
-INPUT(FILESYSTEM)
+INPUT(STR(FILESYSTEM))
 #endif
 
 ENTRY(_start)
@@ -36,14 +39,14 @@ SECTIONS
 	 */
 	.kernel (PHYS_OFFSET + KERNEL_OFFSET): {
 		kernel__start = .;
-		KERNEL
+		STR(KERNEL)
 		kernel__end = .;
 	}
 
 #ifdef XEN
 	.xen (PHYS_OFFSET + XEN_OFFSET): {
 		xen__start = .;
-		XEN
+		STR(XEN)
 		xen__end = .;
 	}
 
@@ -62,7 +65,7 @@ SECTIONS
 #ifdef USE_INITRD
 	.filesystem (PHYS_OFFSET + FS_OFFSET): {
 		filesystem__start = .;
-		FILESYSTEM
+		STR(FILESYSTEM)
 		filesystem__end = .;
 	}
 #endif
-- 
2.38.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [boot-wrapper PATCH] model.lds.S: Quote file paths
  2023-01-02 13:24 [boot-wrapper PATCH] model.lds.S: Quote file paths Kevin Brodsky
@ 2023-01-30 14:41 ` Mark Rutland
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Rutland @ 2023-01-30 14:41 UTC (permalink / raw)
  To: Kevin Brodsky; +Cc: linux-arm-kernel

On Mon, Jan 02, 2023 at 01:24:46PM +0000, Kevin Brodsky wrote:
> Inserting arbitrary paths in a linker script verbatim can be
> problematic, even if they don't contain whitespaces, as ld has a
> special interpretation for certain special characters (such as @).
> 
> Fix this by quoting all user-provided paths in model.lds.S using the
> preprocessor.
> 
> Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>

Thanks; applied.

Mark.

> ---
>  model.lds.S | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/model.lds.S b/model.lds.S
> index dacaa25ba9fd..e07cbc04b9fa 100644
> --- a/model.lds.S
> +++ b/model.lds.S
> @@ -7,6 +7,9 @@
>   * found in the LICENSE.txt file.
>   */
>  
> +#define _STR(s) #s
> +#define STR(s) _STR(s)
> +
>  #ifdef BOOTWRAPPER_32
>  OUTPUT_FORMAT("elf32-littlearm")
>  OUTPUT_ARCH(arm)
> @@ -17,13 +20,13 @@ OUTPUT_ARCH(aarch64)
>  TARGET(binary)
>  
>  #ifdef XEN
> -INPUT(XEN)
> +INPUT(STR(XEN))
>  #endif
> -INPUT(KERNEL)
> +INPUT(STR(KERNEL))
>  INPUT(./fdt.dtb)
>  
>  #ifdef USE_INITRD
> -INPUT(FILESYSTEM)
> +INPUT(STR(FILESYSTEM))
>  #endif
>  
>  ENTRY(_start)
> @@ -36,14 +39,14 @@ SECTIONS
>  	 */
>  	.kernel (PHYS_OFFSET + KERNEL_OFFSET): {
>  		kernel__start = .;
> -		KERNEL
> +		STR(KERNEL)
>  		kernel__end = .;
>  	}
>  
>  #ifdef XEN
>  	.xen (PHYS_OFFSET + XEN_OFFSET): {
>  		xen__start = .;
> -		XEN
> +		STR(XEN)
>  		xen__end = .;
>  	}
>  
> @@ -62,7 +65,7 @@ SECTIONS
>  #ifdef USE_INITRD
>  	.filesystem (PHYS_OFFSET + FS_OFFSET): {
>  		filesystem__start = .;
> -		FILESYSTEM
> +		STR(FILESYSTEM)
>  		filesystem__end = .;
>  	}
>  #endif
> -- 
> 2.38.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-30 17:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-02 13:24 [boot-wrapper PATCH] model.lds.S: Quote file paths Kevin Brodsky
2023-01-30 14:41 ` Mark Rutland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox