feat(build): check that .text section starts at page boundary
Linker may decide to put new unspecified sections before .text
section. That will cause non-working image, because entry point isn't
at __BLXX_START__. Device just not booted with such image.
This happened for example with .note.gnu.build-id section generated
for LTO build in some cases. Now linker will report this situation as
an error.
```
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: .text is not aligned on a page boundary.
collect2: error: ld returned 1 exit status
```
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Change-Id: I5ae46ddd1e6e431e1df1715d1d301f6dd7181cc7
diff --git a/bl32/sp_min/sp_min.ld.S b/bl32/sp_min/sp_min.ld.S
index dd81973..a2d9b7b 100644
--- a/bl32/sp_min/sp_min.ld.S
+++ b/bl32/sp_min/sp_min.ld.S
@@ -29,6 +29,9 @@
#if SEPARATE_CODE_AND_RODATA
.text . : {
+ ASSERT(. == ALIGN(PAGE_SIZE),
+ ".text address is not aligned on a page boundary.");
+
__TEXT_START__ = .;
*entrypoint.o(.text*)
@@ -67,6 +70,9 @@
} >RAM
#else /* SEPARATE_CODE_AND_RODATA */
.ro . : {
+ ASSERT(. == ALIGN(PAGE_SIZE),
+ ".ro address is not aligned on a page boundary.");
+
__RO_START__ = .;
*entrypoint.o(.text*)
diff --git a/bl32/tsp/tsp.ld.S b/bl32/tsp/tsp.ld.S
index 22bf11d..5116b20 100644
--- a/bl32/tsp/tsp.ld.S
+++ b/bl32/tsp/tsp.ld.S
@@ -25,6 +25,9 @@
#if SEPARATE_CODE_AND_RODATA
.text . : {
+ ASSERT(. == ALIGN(PAGE_SIZE),
+ ".text address is not aligned on a page boundary.");
+
__TEXT_START__ = .;
*tsp_entrypoint.o(.text*)
@@ -51,6 +54,9 @@
} >RAM
#else /* SEPARATE_CODE_AND_RODATA */
.ro . : {
+ ASSERT(. == ALIGN(PAGE_SIZE),
+ ".ro address is not aligned on a page boundary.");
+
__RO_START__ = .;
*tsp_entrypoint.o(.text*)