2020-03-09 08:39:48 +00:00
|
|
|
/*
|
2020-10-05 10:02:54 +01:00
|
|
|
* Copyright (c) 2020-2021, ARM Limited and Contributors. All rights reserved.
|
2020-03-09 08:39:48 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BL_COMMON_LD_H
|
|
|
|
#define BL_COMMON_LD_H
|
|
|
|
|
2020-03-26 01:51:39 +00:00
|
|
|
#include <platform_def.h>
|
|
|
|
|
|
|
|
#ifdef __aarch64__
|
|
|
|
#define STRUCT_ALIGN 8
|
linker_script: move bss section to bl_common.ld.h
Move the bss section to the common header. This adds BAKERY_LOCK_NORMAL
and PMF_TIMESTAMP, which previously existed only in BL31. This is not
a big deal because unused data should not be compiled in the first
place. I believe this should be controlled by BL*_SOURCES in Makefiles,
not by linker scripts.
I investigated BL1, BL2, BL2U, BL31 for plat=fvp, and BL2-AT-EL3,
BL31, BL31 for plat=uniphier. I did not see any more unexpected
code addition.
The bss section has bigger alignment. I added BSS_ALIGN for this.
Currently, SORT_BY_ALIGNMENT() is missing in sp_min.ld.S, and with this
change, the BSS symbols in SP_MIN will be sorted by the alignment.
This is not a big deal (or, even better in terms of the image size).
Change-Id: I680ee61f84067a559bac0757f9d03e73119beb33
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-03-26 04:16:33 +00:00
|
|
|
#define BSS_ALIGN 16
|
2020-03-26 01:51:39 +00:00
|
|
|
#else
|
|
|
|
#define STRUCT_ALIGN 4
|
linker_script: move bss section to bl_common.ld.h
Move the bss section to the common header. This adds BAKERY_LOCK_NORMAL
and PMF_TIMESTAMP, which previously existed only in BL31. This is not
a big deal because unused data should not be compiled in the first
place. I believe this should be controlled by BL*_SOURCES in Makefiles,
not by linker scripts.
I investigated BL1, BL2, BL2U, BL31 for plat=fvp, and BL2-AT-EL3,
BL31, BL31 for plat=uniphier. I did not see any more unexpected
code addition.
The bss section has bigger alignment. I added BSS_ALIGN for this.
Currently, SORT_BY_ALIGNMENT() is missing in sp_min.ld.S, and with this
change, the BSS symbols in SP_MIN will be sorted by the alignment.
This is not a big deal (or, even better in terms of the image size).
Change-Id: I680ee61f84067a559bac0757f9d03e73119beb33
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-03-26 04:16:33 +00:00
|
|
|
#define BSS_ALIGN 8
|
2020-03-26 01:51:39 +00:00
|
|
|
#endif
|
|
|
|
|
linker_script: move .data section to bl_common.ld.h
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>
2020-04-22 02:50:12 +01:00
|
|
|
#ifndef DATA_ALIGN
|
|
|
|
#define DATA_ALIGN 1
|
|
|
|
#endif
|
|
|
|
|
2020-03-26 01:51:39 +00:00
|
|
|
#define CPU_OPS \
|
|
|
|
. = ALIGN(STRUCT_ALIGN); \
|
|
|
|
__CPU_OPS_START__ = .; \
|
|
|
|
KEEP(*(cpu_ops)) \
|
|
|
|
__CPU_OPS_END__ = .;
|
|
|
|
|
|
|
|
#define PARSER_LIB_DESCS \
|
|
|
|
. = ALIGN(STRUCT_ALIGN); \
|
|
|
|
__PARSER_LIB_DESCS_START__ = .; \
|
|
|
|
KEEP(*(.img_parser_lib_descs)) \
|
|
|
|
__PARSER_LIB_DESCS_END__ = .;
|
|
|
|
|
|
|
|
#define RT_SVC_DESCS \
|
|
|
|
. = ALIGN(STRUCT_ALIGN); \
|
|
|
|
__RT_SVC_DESCS_START__ = .; \
|
|
|
|
KEEP(*(rt_svc_descs)) \
|
|
|
|
__RT_SVC_DESCS_END__ = .;
|
|
|
|
|
|
|
|
#define PMF_SVC_DESCS \
|
|
|
|
. = ALIGN(STRUCT_ALIGN); \
|
|
|
|
__PMF_SVC_DESCS_START__ = .; \
|
|
|
|
KEEP(*(pmf_svc_descs)) \
|
|
|
|
__PMF_SVC_DESCS_END__ = .;
|
|
|
|
|
|
|
|
#define FCONF_POPULATOR \
|
|
|
|
. = ALIGN(STRUCT_ALIGN); \
|
|
|
|
__FCONF_POPULATOR_START__ = .; \
|
|
|
|
KEEP(*(.fconf_populator)) \
|
|
|
|
__FCONF_POPULATOR_END__ = .;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keep the .got section in the RO section as it is patched prior to enabling
|
|
|
|
* the MMU and having the .got in RO is better for security. GOT is a table of
|
|
|
|
* addresses so ensure pointer size alignment.
|
|
|
|
*/
|
|
|
|
#define GOT \
|
|
|
|
. = ALIGN(STRUCT_ALIGN); \
|
|
|
|
__GOT_START__ = .; \
|
|
|
|
*(.got) \
|
|
|
|
__GOT_END__ = .;
|
|
|
|
|
2020-03-26 04:18:48 +00:00
|
|
|
/*
|
|
|
|
* The base xlat table
|
|
|
|
*
|
|
|
|
* It is put into the rodata section if PLAT_RO_XLAT_TABLES=1,
|
|
|
|
* or into the bss section otherwise.
|
|
|
|
*/
|
|
|
|
#define BASE_XLAT_TABLE \
|
|
|
|
. = ALIGN(16); \
|
|
|
|
*(base_xlat_table)
|
|
|
|
|
|
|
|
#if PLAT_RO_XLAT_TABLES
|
|
|
|
#define BASE_XLAT_TABLE_RO BASE_XLAT_TABLE
|
|
|
|
#define BASE_XLAT_TABLE_BSS
|
|
|
|
#else
|
|
|
|
#define BASE_XLAT_TABLE_RO
|
|
|
|
#define BASE_XLAT_TABLE_BSS BASE_XLAT_TABLE
|
|
|
|
#endif
|
|
|
|
|
linker_script: replace common read-only data with RODATA_COMMON
The common section data are repeated in many linker scripts (often
twice in each script to support SEPARATE_CODE_AND_RODATA). When you
add a new read-only data section, you end up with touching lots of
places.
After this commit, you will only need to touch bl_common.ld.h when
you add a new section to RODATA_COMMON.
Replace a series of RO section with RODATA_COMMON, which contains
6 sections, some of which did not exist before.
This is not a big deal because unneeded data should not be compiled
in the first place. I believe this should be controlled by BL*_SOURCES
in Makefiles, not by linker scripts.
When I was working on this commit, the BL1 image size increased
due to the fconf_populator. Commit c452ba159c14 ("fconf: exclude
fconf_dyn_cfg_getter.c from BL1_SOURCES") fixed this issue.
I investigated BL1, BL2, BL2U, BL31 for plat=fvp, and BL2-AT-EL3,
BL31, BL31 for plat=uniphier. I did not see any more unexpected
code addition.
Change-Id: I5d14d60dbe3c821765bce3ae538968ef266f1460
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-03-26 01:57:12 +00:00
|
|
|
#define RODATA_COMMON \
|
|
|
|
RT_SVC_DESCS \
|
|
|
|
FCONF_POPULATOR \
|
|
|
|
PMF_SVC_DESCS \
|
|
|
|
PARSER_LIB_DESCS \
|
|
|
|
CPU_OPS \
|
2020-03-26 04:18:48 +00:00
|
|
|
GOT \
|
|
|
|
BASE_XLAT_TABLE_RO
|
linker_script: replace common read-only data with RODATA_COMMON
The common section data are repeated in many linker scripts (often
twice in each script to support SEPARATE_CODE_AND_RODATA). When you
add a new read-only data section, you end up with touching lots of
places.
After this commit, you will only need to touch bl_common.ld.h when
you add a new section to RODATA_COMMON.
Replace a series of RO section with RODATA_COMMON, which contains
6 sections, some of which did not exist before.
This is not a big deal because unneeded data should not be compiled
in the first place. I believe this should be controlled by BL*_SOURCES
in Makefiles, not by linker scripts.
When I was working on this commit, the BL1 image size increased
due to the fconf_populator. Commit c452ba159c14 ("fconf: exclude
fconf_dyn_cfg_getter.c from BL1_SOURCES") fixed this issue.
I investigated BL1, BL2, BL2U, BL31 for plat=fvp, and BL2-AT-EL3,
BL31, BL31 for plat=uniphier. I did not see any more unexpected
code addition.
Change-Id: I5d14d60dbe3c821765bce3ae538968ef266f1460
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-03-26 01:57:12 +00:00
|
|
|
|
linker_script: move .data section to bl_common.ld.h
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>
2020-04-22 02:50:12 +01:00
|
|
|
/*
|
|
|
|
* .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__ = .; \
|
|
|
|
}
|
|
|
|
|
2020-04-22 03:27:55 +01:00
|
|
|
/*
|
|
|
|
* .rela.dyn needs to come after .data for the read-elf utility to parse
|
|
|
|
* this section correctly.
|
|
|
|
*/
|
2020-10-05 10:02:54 +01:00
|
|
|
#if __aarch64__
|
|
|
|
#define RELA_DYN_NAME .rela.dyn
|
|
|
|
#define RELOC_SECTIONS_PATTERN *(.rela*)
|
|
|
|
#else
|
|
|
|
#define RELA_DYN_NAME .rel.dyn
|
|
|
|
#define RELOC_SECTIONS_PATTERN *(.rel*)
|
|
|
|
#endif
|
|
|
|
|
2020-04-22 03:27:55 +01:00
|
|
|
#define RELA_SECTION \
|
2020-10-05 10:02:54 +01:00
|
|
|
RELA_DYN_NAME : ALIGN(STRUCT_ALIGN) { \
|
2020-04-22 03:27:55 +01:00
|
|
|
__RELA_START__ = .; \
|
2020-10-05 10:02:54 +01:00
|
|
|
RELOC_SECTIONS_PATTERN \
|
2020-04-22 03:27:55 +01:00
|
|
|
__RELA_END__ = .; \
|
|
|
|
}
|
|
|
|
|
2020-05-30 17:33:26 +01:00
|
|
|
#if !(defined(IMAGE_BL31) && RECLAIM_INIT_CODE)
|
2020-03-26 01:51:39 +00:00
|
|
|
#define STACK_SECTION \
|
|
|
|
stacks (NOLOAD) : { \
|
|
|
|
__STACKS_START__ = .; \
|
|
|
|
*(tzfw_normal_stacks) \
|
|
|
|
__STACKS_END__ = .; \
|
|
|
|
}
|
2020-05-30 17:33:26 +01:00
|
|
|
#endif
|
2020-03-26 01:51:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If BL doesn't use any bakery lock then __PERCPU_BAKERY_LOCK_SIZE__
|
|
|
|
* will be zero. For this reason, the only two valid values for
|
|
|
|
* __PERCPU_BAKERY_LOCK_SIZE__ are 0 or the platform defined value
|
|
|
|
* PLAT_PERCPU_BAKERY_LOCK_SIZE.
|
|
|
|
*/
|
|
|
|
#ifdef PLAT_PERCPU_BAKERY_LOCK_SIZE
|
|
|
|
#define BAKERY_LOCK_SIZE_CHECK \
|
|
|
|
ASSERT((__PERCPU_BAKERY_LOCK_SIZE__ == 0) || \
|
|
|
|
(__PERCPU_BAKERY_LOCK_SIZE__ == PLAT_PERCPU_BAKERY_LOCK_SIZE), \
|
|
|
|
"PLAT_PERCPU_BAKERY_LOCK_SIZE does not match bakery lock requirements");
|
|
|
|
#else
|
|
|
|
#define BAKERY_LOCK_SIZE_CHECK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bakery locks are stored in normal .bss memory
|
|
|
|
*
|
|
|
|
* Each lock's data is spread across multiple cache lines, one per CPU,
|
|
|
|
* but multiple locks can share the same cache line.
|
|
|
|
* The compiler will allocate enough memory for one CPU's bakery locks,
|
|
|
|
* the remaining cache lines are allocated by the linker script
|
|
|
|
*/
|
|
|
|
#if !USE_COHERENT_MEM
|
|
|
|
#define BAKERY_LOCK_NORMAL \
|
|
|
|
. = ALIGN(CACHE_WRITEBACK_GRANULE); \
|
|
|
|
__BAKERY_LOCK_START__ = .; \
|
|
|
|
__PERCPU_BAKERY_LOCK_START__ = .; \
|
|
|
|
*(bakery_lock) \
|
|
|
|
. = ALIGN(CACHE_WRITEBACK_GRANULE); \
|
|
|
|
__PERCPU_BAKERY_LOCK_END__ = .; \
|
|
|
|
__PERCPU_BAKERY_LOCK_SIZE__ = ABSOLUTE(__PERCPU_BAKERY_LOCK_END__ - __PERCPU_BAKERY_LOCK_START__); \
|
|
|
|
. = . + (__PERCPU_BAKERY_LOCK_SIZE__ * (PLATFORM_CORE_COUNT - 1)); \
|
|
|
|
__BAKERY_LOCK_END__ = .; \
|
|
|
|
BAKERY_LOCK_SIZE_CHECK
|
|
|
|
#else
|
|
|
|
#define BAKERY_LOCK_NORMAL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Time-stamps are stored in normal .bss memory
|
|
|
|
*
|
|
|
|
* The compiler will allocate enough memory for one CPU's time-stamps,
|
|
|
|
* the remaining memory for other CPUs is allocated by the
|
|
|
|
* linker script
|
|
|
|
*/
|
|
|
|
#define PMF_TIMESTAMP \
|
|
|
|
. = ALIGN(CACHE_WRITEBACK_GRANULE); \
|
|
|
|
__PMF_TIMESTAMP_START__ = .; \
|
|
|
|
KEEP(*(pmf_timestamp_array)) \
|
|
|
|
. = ALIGN(CACHE_WRITEBACK_GRANULE); \
|
|
|
|
__PMF_PERCPU_TIMESTAMP_END__ = .; \
|
|
|
|
__PERCPU_TIMESTAMP_SIZE__ = ABSOLUTE(. - __PMF_TIMESTAMP_START__); \
|
|
|
|
. = . + (__PERCPU_TIMESTAMP_SIZE__ * (PLATFORM_CORE_COUNT - 1)); \
|
|
|
|
__PMF_TIMESTAMP_END__ = .;
|
|
|
|
|
linker_script: move bss section to bl_common.ld.h
Move the bss section to the common header. This adds BAKERY_LOCK_NORMAL
and PMF_TIMESTAMP, which previously existed only in BL31. This is not
a big deal because unused data should not be compiled in the first
place. I believe this should be controlled by BL*_SOURCES in Makefiles,
not by linker scripts.
I investigated BL1, BL2, BL2U, BL31 for plat=fvp, and BL2-AT-EL3,
BL31, BL31 for plat=uniphier. I did not see any more unexpected
code addition.
The bss section has bigger alignment. I added BSS_ALIGN for this.
Currently, SORT_BY_ALIGNMENT() is missing in sp_min.ld.S, and with this
change, the BSS symbols in SP_MIN will be sorted by the alignment.
This is not a big deal (or, even better in terms of the image size).
Change-Id: I680ee61f84067a559bac0757f9d03e73119beb33
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-03-26 04:16:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The .bss section gets initialised to 0 at runtime.
|
|
|
|
* Its base address has bigger alignment for better performance of the
|
|
|
|
* zero-initialization code.
|
|
|
|
*/
|
|
|
|
#define BSS_SECTION \
|
|
|
|
.bss (NOLOAD) : ALIGN(BSS_ALIGN) { \
|
|
|
|
__BSS_START__ = .; \
|
|
|
|
*(SORT_BY_ALIGNMENT(.bss*)) \
|
|
|
|
*(COMMON) \
|
|
|
|
BAKERY_LOCK_NORMAL \
|
|
|
|
PMF_TIMESTAMP \
|
2020-03-26 04:18:48 +00:00
|
|
|
BASE_XLAT_TABLE_BSS \
|
linker_script: move bss section to bl_common.ld.h
Move the bss section to the common header. This adds BAKERY_LOCK_NORMAL
and PMF_TIMESTAMP, which previously existed only in BL31. This is not
a big deal because unused data should not be compiled in the first
place. I believe this should be controlled by BL*_SOURCES in Makefiles,
not by linker scripts.
I investigated BL1, BL2, BL2U, BL31 for plat=fvp, and BL2-AT-EL3,
BL31, BL31 for plat=uniphier. I did not see any more unexpected
code addition.
The bss section has bigger alignment. I added BSS_ALIGN for this.
Currently, SORT_BY_ALIGNMENT() is missing in sp_min.ld.S, and with this
change, the BSS symbols in SP_MIN will be sorted by the alignment.
This is not a big deal (or, even better in terms of the image size).
Change-Id: I680ee61f84067a559bac0757f9d03e73119beb33
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-03-26 04:16:33 +00:00
|
|
|
__BSS_END__ = .; \
|
|
|
|
}
|
|
|
|
|
2020-03-09 08:39:48 +00:00
|
|
|
/*
|
|
|
|
* The xlat_table section is for full, aligned page tables (4K).
|
|
|
|
* Removing them from .bss avoids forcing 4K alignment on
|
|
|
|
* the .bss section. The tables are initialized to zero by the translation
|
|
|
|
* tables library.
|
|
|
|
*/
|
|
|
|
#define XLAT_TABLE_SECTION \
|
|
|
|
xlat_table (NOLOAD) : { \
|
|
|
|
*(xlat_table) \
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* BL_COMMON_LD_H */
|