]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
linker_script: move .data section to bl_common.ld.h
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 22 Apr 2020 01:50:12 +0000 (10:50 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Sat, 25 Apr 2020 11:09:08 +0000 (20:09 +0900)
Move the data section to the common header.

I slightly tweaked some scripts as follows:

[1] bl1.ld.S has ALIGN(16). I added DATA_ALIGN macro, which is 1
    by default, but overridden by bl1.ld.S. Currently, ALIGN(16)
    of the .data section is redundant because commit 412865907699
    ("Fix boot failures on some builds linked with ld.lld.") padded
    out the previous section to work around the issue of LLD version
    <= 10.0. This will be fixed in the future release of LLVM, so
    I am keeping the proper way to align LMA.

[2] bl1.ld.S and bl2_el3.ld.S define __DATA_RAM_{START,END}__ instead
    of __DATA_{START,END}__. I put them out of the .data section.

[3] SORT_BY_ALIGNMENT() is missing tsp.ld.S, sp_min.ld.S, and
    mediatek/mt6795/bl31.ld.S. This commit adds SORT_BY_ALIGNMENT()
    for all images, so the symbol order in those three will change,
    but I do not think it is a big deal.

Change-Id: I215bb23c319f045cd88e6f4e8ee2518c67f03692
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
bl1/bl1.ld.S
bl2/bl2.ld.S
bl2/bl2_el3.ld.S
bl2u/bl2u.ld.S
bl31/bl31.ld.S
bl32/sp_min/sp_min.ld.S
bl32/tsp/tsp.ld.S
include/common/bl_common.ld.h
plat/mediatek/mt6795/bl31.ld.S

index 4ebe8a02a9fddd4b6c273d432f50d2ae4d20d655..bc23828e496d6dc47bc3f5e4fc7d3b68eec45888 100644 (file)
@@ -4,6 +4,14 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+/*
+ * The .data section gets copied from ROM to RAM at runtime.
+ * Its LMA should be 16-byte aligned to allow efficient copying of 16-bytes
+ * aligned regions in it.
+ * Its VMA must be page-aligned as it marks the first read/write page.
+ */
+#define DATA_ALIGN     16
+
 #include <common/bl_common.ld.h>
 #include <lib/xlat_tables/xlat_tables_defs.h>
 
@@ -87,21 +95,9 @@ SECTIONS
     ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE),
            "BL1_RW_BASE address is not aligned on a page boundary.")
 
-    /*
-     * The .data section gets copied from ROM to RAM at runtime.
-     * Its LMA should be 16-byte aligned to allow efficient copying of 16-bytes
-     * aligned regions in it.
-     * Its VMA must be page-aligned as it marks the first read/write page.
-     *
-     * It must be placed at a lower address than the stacks if the stack
-     * protector is enabled. Alternatively, the .data.stack_protector_canary
-     * section can be placed independently of the main .data section.
-     */
-    .data . : ALIGN(16) {
-        __DATA_RAM_START__ = .;
-        *(SORT_BY_ALIGNMENT(.data*))
-        __DATA_RAM_END__ = .;
-    } >RAM AT>ROM
+    DATA_SECTION >RAM AT>ROM
+    __DATA_RAM_START__ = __DATA_START__;
+    __DATA_RAM_END__ = __DATA_END__;
 
     STACK_SECTION >RAM
     BSS_SECTION >RAM
index 17475f061625da9e9ad5dc9a54751a07589b7a34..37849c3124afae6aa515e648651158a79f399128 100644 (file)
@@ -77,17 +77,7 @@ SECTIONS
      */
     __RW_START__ = . ;
 
-    /*
-     * .data must be placed at a lower address than the stacks if the stack
-     * protector is enabled. Alternatively, the .data.stack_protector_canary
-     * section can be placed independently of the main .data section.
-     */
-    .data . : {
-        __DATA_START__ = .;
-        *(SORT_BY_ALIGNMENT(.data*))
-        __DATA_END__ = .;
-    } >RAM
-
+    DATA_SECTION >RAM
     STACK_SECTION >RAM
     BSS_SECTION >RAM
     XLAT_TABLE_SECTION >RAM
index ea7a23500c0d74a9a8e764eb82693a2ae6131593..8c45d9898f28e8da883647b4f13af219364379ec 100644 (file)
@@ -101,16 +101,9 @@ SECTIONS
      */
     __RW_START__ = . ;
 
-    /*
-     * .data must be placed at a lower address than the stacks if the stack
-     * protector is enabled. Alternatively, the .data.stack_protector_canary
-     * section can be placed independently of the main .data section.
-     */
-    .data . : {
-        __DATA_RAM_START__ = .;
-        *(SORT_BY_ALIGNMENT(.data*))
-        __DATA_RAM_END__ = .;
-    } >RAM AT>ROM
+    DATA_SECTION >RAM AT>ROM
+    __DATA_RAM_START__ = __DATA_START__;
+    __DATA_RAM_END__ = __DATA_END__;
 
     /*
      * .rela.dyn needs to come after .data for the read-elf utility to parse
index 3ab43825c1147fd4217e5899ec7dac6770c37b17..a7752a490c2d78d67b3ed3057933281a16e08c49 100644 (file)
@@ -79,17 +79,7 @@ SECTIONS
      */
     __RW_START__ = . ;
 
-    /*
-     * .data must be placed at a lower address than the stacks if the stack
-     * protector is enabled. Alternatively, the .data.stack_protector_canary
-     * section can be placed independently of the main .data section.
-     */
-    .data . : {
-        __DATA_START__ = .;
-        *(SORT_BY_ALIGNMENT(.data*))
-        __DATA_END__ = .;
-    } >RAM
-
+    DATA_SECTION >RAM
     STACK_SECTION >RAM
     BSS_SECTION >RAM
     XLAT_TABLE_SECTION >RAM
index 94d03e3da557e06495acf7d5f083f71f3f646a1e..11e86a3c13ffd2c41c33f6deeb710b74fd437bca 100644 (file)
@@ -114,16 +114,7 @@ SECTIONS
      */
     __RW_START__ = . ;
 
-    /*
-     * .data must be placed at a lower address than the stacks if the stack
-     * protector is enabled. Alternatively, the .data.stack_protector_canary
-     * section can be placed independently of the main .data section.
-     */
-   .data . : {
-        __DATA_START__ = .;
-        *(SORT_BY_ALIGNMENT(.data*))
-        __DATA_END__ = .;
-    } >RAM
+    DATA_SECTION >RAM
 
     /*
      * .rela.dyn needs to come after .data for the read-elf utility to parse
index 8e91cec91bbccffc411957aa3152fdc384762d0f..9e0596f1f056e4917245fb3be953d7b11cc07c36 100644 (file)
@@ -91,11 +91,7 @@ SECTIONS
      */
     __RW_START__ = . ;
 
-    .data . : {
-        __DATA_START__ = .;
-        *(.data*)
-        __DATA_END__ = .;
-    } >RAM
+    DATA_SECTION >RAM
 
 #ifdef BL32_PROGBITS_LIMIT
     ASSERT(. <= BL32_PROGBITS_LIMIT, "BL32 progbits has exceeded its limit.")
index 7428c0345b0fb7629debeb826906062f716e78dd..bdcd2cf708f7923748b81406d18fd49c89ddd0af 100644 (file)
@@ -70,11 +70,7 @@ SECTIONS
      */
     __RW_START__ = . ;
 
-    .data . : {
-        __DATA_START__ = .;
-        *(.data*)
-        __DATA_END__ = .;
-    } >RAM
+    DATA_SECTION >RAM
 
     /*
      * .rela.dyn needs to come after .data for the read-elf utility to parse
index 8ea7d6a8cce6479db3f31cb285cebfc3915fd537..97fed72044eb04614d76d7d8d37c20423e1258b7 100644 (file)
 #define BSS_ALIGN      8
 #endif
 
+#ifndef DATA_ALIGN
+#define DATA_ALIGN     1
+#endif
+
 #define CPU_OPS                                                \
        . = ALIGN(STRUCT_ALIGN);                        \
        __CPU_OPS_START__ = .;                          \
        GOT                                             \
        BASE_XLAT_TABLE_RO
 
+/*
+ * .data must be placed at a lower address than the stacks if the stack
+ * protector is enabled. Alternatively, the .data.stack_protector_canary
+ * section can be placed independently of the main .data section.
+ */
+#define DATA_SECTION                                   \
+       .data . : ALIGN(DATA_ALIGN) {                   \
+               __DATA_START__ = .;                     \
+               *(SORT_BY_ALIGNMENT(.data*))            \
+               __DATA_END__ = .;                       \
+       }
+
 #define STACK_SECTION                                  \
        stacks (NOLOAD) : {                             \
                __STACKS_START__ = .;                   \
index 91ca87cb637949c62f758ed91c6fd6dcf0fc3598..3d881fc433a38ef938e41eb2cfeb60d1487d0c9b 100644 (file)
@@ -59,16 +59,7 @@ SECTIONS
      */
     __RW_START__ = . ;
 
-    /*
-     * .data must be placed at a lower address than the stacks if the stack
-     * protector is enabled. Alternatively, the .data.stack_protector_canary
-     * section can be placed independently of the main .data section.
-     */
-    .data . : {
-        __DATA_START__ = .;
-        *(.data*)
-        __DATA_END__ = .;
-    } >RAM
+    DATA_SECTION >RAM
 
 #ifdef BL31_PROGBITS_LIMIT
     ASSERT(. <= BL31_PROGBITS_LIMIT, "BL3-1 progbits has exceeded its limit.")