Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame] | 1 | From 7c5e40d9f8699a55ac2187c035429c643e6d0ef0 Mon Sep 17 00:00:00 2001 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 2 | From: Jaxson Han <jaxson.han@arm.com> |
| 3 | Date: Tue, 2 Nov 2021 15:10:28 +0800 |
| 4 | Subject: [PATCH] lds: Rearrange and mark the sections |
| 5 | |
| 6 | To make it possible for the next stage to protect sections with MPU, |
| 7 | boot-wrapper needs to provide the text and data section information. |
| 8 | By rearranging the .data .rodata and .vector sections, all sections |
| 9 | can be split into 2 big sections: |
| 10 | - RO and Executable |
| 11 | - RW and Non-Executable |
| 12 | Add firmware_data to mark the boundry, thus: |
| 13 | firmware_start to firmware_data - 1 indicates RO and Executable section, |
| 14 | firmware_data to firmware_end - 1 indicates RW and Non-Executable |
| 15 | section. |
| 16 | |
| 17 | Also, the firmware_data and firmware_end should align with 64 bytes, |
| 18 | since Armv8R AArch64 MPU requires it. |
| 19 | |
| 20 | Issue-ID: SCM-3816 |
| 21 | Upstream-Status: Inappropriate [other] |
| 22 | Implementation pending further discussion |
| 23 | Signed-off-by: Jaxson Han <jaxson.han@arm.com> |
| 24 | Change-Id: I55342aa7492f2c7b5c16ab9a6472c8cb45cff8fd |
| 25 | --- |
| 26 | model.lds.S | 7 ++++++- |
| 27 | 1 file changed, 6 insertions(+), 1 deletion(-) |
| 28 | |
| 29 | diff --git a/model.lds.S b/model.lds.S |
| 30 | index ab98ddf..85451f9 100644 |
| 31 | --- a/model.lds.S |
| 32 | +++ b/model.lds.S |
| 33 | @@ -63,12 +63,16 @@ SECTIONS |
| 34 | } |
| 35 | #endif |
| 36 | |
| 37 | +#define FIRMWARE_ALIGN . = ALIGN(1 << 6) |
| 38 | .boot PHYS_OFFSET: { |
| 39 | PROVIDE(firmware_start = .); |
| 40 | *(.init) |
| 41 | *(.text*) |
| 42 | - *(.data* .rodata* .bss* COMMON) |
| 43 | *(.vectors) |
| 44 | + *(.rodata*) |
| 45 | + FIRMWARE_ALIGN; |
| 46 | + PROVIDE(firmware_data = .); |
| 47 | + *(.data* .bss* COMMON) |
| 48 | *(.stack) |
| 49 | PROVIDE(etext = .); |
| 50 | } |
| 51 | @@ -77,6 +81,7 @@ SECTIONS |
| 52 | mbox = .; |
| 53 | QUAD(0x0) |
| 54 | } |
| 55 | + FIRMWARE_ALIGN; |
| 56 | PROVIDE(firmware_end = .); |
| 57 | |
| 58 | ASSERT(etext <= (PHYS_OFFSET + TEXT_LIMIT), ".text overflow!") |