[PATCH v1 3/6] arm: Prepare linker scripts for memory permissions

Richard Henderson richard.henderson at linaro.org
Wed Feb 5 18:23:48 CET 2025


On 2/4/25 23:16, Ilias Apalodimas wrote:
> @@ -98,18 +101,20 @@ SECTIONS
>   	}
>   #endif
>   
> -	. = ALIGN(8);
> -	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
> +	.rodata ALIGN(4096): {
> +	    __start_rodata = .;
> +	    *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
> +	    . = ALIGN(4096);
> +	    __end_rodata = .;
> +	}
>   
> -	. = ALIGN(8);
> -	.data : {
> +	.data ALIGN(4096) : {
> +	    __start_data = .;
>   		*(.data*)
> +	    . = ALIGN(4096);
> +	    __end_data = .;
>   	}
>   
> -	. = ALIGN(8);
> -
> -	. = .;
> -
>   	. = ALIGN(8);
>   	__u_boot_list : {
>   		KEEP(*(SORT(__u_boot_list*)));
> @@ -136,10 +141,10 @@ SECTIONS
>   	/*
>   	 * arch/arm/lib/crt0_64.S assumes __bss_start - __bss_end % 8 == 0
>   	 */
> -	.bss ALIGN(8) : {
> +	.bss ALIGN(4096) : {
>   		__bss_start = .;
>   		*(.bss*)
> -		. = ALIGN(8);
> +		. = ALIGN(4096);
>   		__bss_end = .;
>   	}

You don't need to align .bss because it normally immediately follows .data, and they have 
the same page permissions.

You've got __u_boot_list, .efi_runtime_rel and .rela.dyn in between.  Consider if any of 
that ought to be moved around to become read-only.


r~


More information about the U-Boot mailing list